diff options
author | Tong Tiangen <tongtiangen@huawei.com> | 2021-10-27 11:18:22 +0000 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2021-10-28 01:02:44 +0200 |
commit | 252c765bd764a246a8bd516fabf6d6123df4a24f (patch) | |
tree | 47ba312f3ec4698cd0829237b01d3f2bbc5ee492 /arch/riscv/net/bpf_jit.h | |
parent | 03e6a7a94001b9582ef6549e5709f3d684217b28 (diff) | |
download | linux-252c765bd764a246a8bd516fabf6d6123df4a24f.tar.gz linux-252c765bd764a246a8bd516fabf6d6123df4a24f.tar.bz2 linux-252c765bd764a246a8bd516fabf6d6123df4a24f.zip |
riscv, bpf: Add BPF exception tables
When a tracing BPF program attempts to read memory without using the
bpf_probe_read() helper, the verifier marks the load instruction with
the BPF_PROBE_MEM flag. Since the riscv JIT does not currently recognize
this flag it falls back to the interpreter.
Add support for BPF_PROBE_MEM, by appending an exception table to the
BPF program. If the load instruction causes a data abort, the fixup
infrastructure finds the exception table and fixes up the fault, by
clearing the destination register and jumping over the faulting
instruction.
A more generic solution would add a "handler" field to the table entry,
like on x86 and s390. The same issue in ARM64 is fixed in 800834285361
("bpf, arm64: Add BPF exception tables").
Signed-off-by: Tong Tiangen <tongtiangen@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: Pu Lehui <pulehui@huawei.com>
Tested-by: Björn Töpel <bjorn@kernel.org>
Acked-by: Björn Töpel <bjorn@kernel.org>
Link: https://lore.kernel.org/bpf/20211027111822.3801679-1-tongtiangen@huawei.com
Diffstat (limited to 'arch/riscv/net/bpf_jit.h')
-rw-r--r-- | arch/riscv/net/bpf_jit.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/riscv/net/bpf_jit.h b/arch/riscv/net/bpf_jit.h index 75c1e9996867..f42d9cd3b64d 100644 --- a/arch/riscv/net/bpf_jit.h +++ b/arch/riscv/net/bpf_jit.h @@ -71,6 +71,7 @@ struct rv_jit_context { int ninsns; int epilogue_offset; int *offset; /* BPF to RV */ + int nexentries; unsigned long flags; int stack_size; }; |