[PATCH bpf-next,v3] riscv, bpf: Add BPF exception tables
tongtiangen at huawei.com
Wed Oct 27 18:01:54 PDT 2021
On 2021/10/28 7:11, Daniel Borkmann wrote:
> On 10/27/21 6:55 PM, Björn Töpel wrote:
>> On Wed, 27 Oct 2021 at 13:03, Tong Tiangen <tongtiangen at 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
>>> 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 at huawei.com>
>>> Tested-by: Pu Lehui <pulehui at huawei.com>
>>> 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!
>> 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.:
> Thanks for testing!
>> * 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
> Sounds good, please ship them. ;)
>> Feel free to add:
>> Acked-by: Björn Töpel <bjorn at kernel.org>
> Applied, thanks! Tong, if you have a chance, please follow up with Mark's
> suggestion to align the extable infra to arm64/x86.
Thanks, Mark's suggestion is good. I will improve this part if I have the opportunity.
More information about the linux-riscv