diff options
| author | Alexei Starovoitov <ast@kernel.org> | 2020-01-22 16:30:11 -0800 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2020-01-22 16:30:15 -0800 |
| commit | 85cc12f85138f2ce3edf24833edd2179690306db (patch) | |
| tree | 0632f77c714898a1ae96619361d986f706979535 /kernel/bpf/verifier.c | |
| parent | 1b2fd38de9fcc73d6994f8f6c7c23ee3435b6a12 (diff) | |
| parent | 6de4a9c430b57c6ebbccd2a1725f42e9be75f592 (diff) | |
| download | talos-op-linux-85cc12f85138f2ce3edf24833edd2179690306db.tar.gz talos-op-linux-85cc12f85138f2ce3edf24833edd2179690306db.zip | |
Merge branch 'bpf_cubic'
Martin KaFai Lau says:
====================
This set adds bpf_cubic.c example. It was separated from the
earlier BPF STRUCT_OPS series. Some highlights since the
last post:
1. It is based on EricD recent fixes to the kernel tcp_cubic. [1]
2. The bpf jiffies reading helper is inlined by the verifier.
Different from the earlier version, it only reads jiffies alone
and does not do usecs/jiffies conversion.
3. The bpf .kconfig map is used to read CONFIG_HZ.
[1]: https://patchwork.ozlabs.org/cover/1215066/
v3:
- Remove __weak from CONFIG_HZ in patch 3. (Andrii)
v2:
- Move inlining to fixup_bpf_calls() in patch 1. (Daniel)
- It is inlined for 64 BITS_PER_LONG and jit_requested
as the map_gen_lookup(). Other cases could be
considered together with map_gen_lookup() if needed.
- Use usec resolution in bictcp_update() calculation in patch 3.
usecs_to_jiffies() is then removed(). (Eric)
====================
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/verifier.c')
| -rw-r--r-- | kernel/bpf/verifier.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 9fe94f64f0ec..734abaa02123 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -9445,6 +9445,30 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) goto patch_call_imm; } + if (prog->jit_requested && BITS_PER_LONG == 64 && + insn->imm == BPF_FUNC_jiffies64) { + struct bpf_insn ld_jiffies_addr[2] = { + BPF_LD_IMM64(BPF_REG_0, + (unsigned long)&jiffies), + }; + + insn_buf[0] = ld_jiffies_addr[0]; + insn_buf[1] = ld_jiffies_addr[1]; + insn_buf[2] = BPF_LDX_MEM(BPF_DW, BPF_REG_0, + BPF_REG_0, 0); + cnt = 3; + + new_prog = bpf_patch_insn_data(env, i + delta, insn_buf, + cnt); + if (!new_prog) + return -ENOMEM; + + delta += cnt - 1; + env->prog = prog = new_prog; + insn = new_prog->insnsi + i + delta; + continue; + } + patch_call_imm: fn = env->ops->get_func_proto(insn->imm, env->prog); /* all functions that have prototype and verifier allowed |

