Messages in this thread | | | Subject | Re: [PATCH bpf-next,v3] riscv, bpf: Add BPF exception tables | From | tongtiangen <> | Date | Thu, 28 Oct 2021 08:59:58 +0800 |
| |
On 2021/10/28 0:55, Björn Töpel wrote: > On Wed, 27 Oct 2021 at 13:03, Tong Tiangen <tongtiangen@huawei.com> wrote: >> >> 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: >> commit 800834285361 ("bpf, arm64: Add BPF exception tables") >> >> Signed-off-by: Tong Tiangen <tongtiangen@huawei.com> >> Tested-by: Pu Lehui <pulehui@huawei.com> >> --- >> v3: >> Modify according to Björn's comments, mainly code optimization. > > Thank you! > > I ran this patch against the test_bpf.ko, and selftests/bpf -- no > regressions, and after the patch is applied more tests passes. Yay!
Exciting test result, Thanks!
> > On a related note. The RISC-V selftests/bpf is in a pretty lousy > state. I'll send a cleanup patch for them soonish. E.g.: > > * RISC-V is missing in bpf_tracing.h (libbpf) > * Some programs don't converge in 16 steps, I had to increase it to ~32 > * The selftest/bpf Makefile needed some RV specific changes > * ...a lot of tests still don't pass, and needs to be looked in to > > Feel free to add: > > Acked-by: Björn Töpel <bjorn@kernel.org> > >> v2: >> Modify according to Björn's comments, mainly removes redundant head files >> extable.h and some code style issues. >> >> arch/riscv/mm/extable.c | 19 +++- >> arch/riscv/net/bpf_jit.h | 1 + >> arch/riscv/net/bpf_jit_comp64.c | 185 +++++++++++++++++++++++++------- >> arch/riscv/net/bpf_jit_core.c | 19 ++-- >> 4 files changed, 177 insertions(+), 47 deletions(-) >> > > [...] > > Björn > . >
| |