On Wed, 2025-08-13 at 23:29 +0800, KaFai Wan wrote: > This test verifies socket filter attachment functionality on architectures > supporting either BPF JIT compilation or the interpreter. > > It specifically validates the fallback to interpreter behavior when JIT fails, > particularly targeting ARMv6 devices with the following configuration: > # CONFIG_BPF_JIT_ALWAYS_ON is not set > CONFIG_BPF_JIT_DEFAULT_ON=y > > Signed-off-by: KaFai Wan <kafai....@linux.dev> > ---
This test should not be landed as-is, first let's do an analysis for why the program fails to jit compile on arm. I modified kernel to dump BPF program before jit attempt, but don't see anything obviously wrong with it. The patch to get disassembly and disassembly itself with resolved kallsyms are attached. Can someone with access to ARM vm/machine take a looks at this? Puranjay, Xu, would you have some time? [...]
diff --git a/net/core/filter.c b/net/core/filter.c index da391e2b0788..790923ebaa7f 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -85,6 +85,7 @@ #include <linux/un.h> #include <net/xdp_sock_drv.h> #include <net/inet_dscp.h> +#include "../../kernel/bpf/disasm.h" #include "dev.h" @@ -1265,6 +1266,26 @@ bool sk_filter_charge(struct sock *sk, struct sk_filter *fp) return true; } +static void printk_wrapper(void *_, const char *fmt, ...) +{ + va_list args; + + va_start(args, fmt); + vprintk(fmt, args); + va_end(args); +} + +static void show_prog(struct bpf_prog *fp) +{ + struct bpf_insn_cbs cbs = { + .cb_print = printk_wrapper + }; + int i, len = fp->len; + + for (i = 0; i < len; i++) + print_bpf_insn(&cbs, &fp->insnsi[i], true); +} + static struct bpf_prog *bpf_migrate_filter(struct bpf_prog *fp) { struct sock_filter *old_prog; @@ -1325,6 +1346,8 @@ static struct bpf_prog *bpf_migrate_filter(struct bpf_prog *fp) if (err) goto out_err_free; + show_prog(fp); + kfree(old_prog); return fp;
w0 ^= w0 w7 ^= w7 r6 = r1 r8 = *(u64 *)(r6 +200) r9 = *(u32 *)(r6 +112) r2 = *(u32 *)(r6 +116) w9 -= w2 r2 = r9 r2 -= 8 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +8) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 8 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x121a2b3c goto pc+15 r2 = r9 r2 -= 6 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +6) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 6 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0x3c37 goto pc+446 r2 = r9 r2 -= 2 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +2) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 2 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x121a2b3c goto pc+14 r2 = r9 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +0) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 0 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0x3c37 goto pc+417 r2 = r9 r2 -= 8 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +8) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 8 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit w2 = -875943366 if r0 != r2 goto pc+15 r2 = r9 r2 -= 6 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +6) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 6 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0x184e goto pc+386 r2 = r9 r2 -= 2 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +2) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 2 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit w2 = -875943366 if r0 != r2 goto pc+14 r2 = r9 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +0) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 0 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0x184e goto pc+356 r2 = r9 r2 -= 8 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +8) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 8 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0xb4d3f47 goto pc+15 r2 = r9 r2 -= 6 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +6) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 6 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0x1413 goto pc+326 r2 = r9 r2 -= 2 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +2) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 2 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0xb4d3f47 goto pc+14 r2 = r9 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +0) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 0 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0x1413 goto pc+297 r2 = r9 r2 -= 8 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +8) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 8 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x1cf440b7 goto pc+15 r2 = r9 r2 -= 6 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +6) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 6 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0xf0f6 goto pc+267 r2 = r9 r2 -= 2 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +2) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 2 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x1cf440b7 goto pc+14 r2 = r9 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +0) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 0 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0xf0f6 goto pc+238 r2 = r9 r2 -= 8 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +8) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 8 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x4dedf471 goto pc+15 r2 = r9 r2 -= 6 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +6) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 6 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0xa84b goto pc+208 r2 = r9 r2 -= 2 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +2) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 2 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x4dedf471 goto pc+14 r2 = r9 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +0) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 0 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0xa84b goto pc+179 r2 = r9 r2 -= 8 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +8) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 8 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit w2 = -1105731113 if r0 != r2 goto pc+15 r2 = r9 r2 -= 6 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +6) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 6 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0xd022 goto pc+148 r2 = r9 r2 -= 2 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +2) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 2 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit w2 = -1105731113 if r0 != r2 goto pc+14 r2 = r9 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +0) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 0 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0xd022 goto pc+118 r2 = r9 r2 -= 8 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +8) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 8 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x7967208b goto pc+15 r2 = r9 r2 -= 6 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +6) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 6 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0x5c49 goto pc+88 r2 = r9 r2 -= 2 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +2) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 2 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x7967208b goto pc+14 r2 = r9 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +0) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 0 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0x5c49 goto pc+59 r2 = r9 r2 -= 8 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +8) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 8 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x55784d5b goto pc+15 r2 = r9 r2 -= 6 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +6) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 6 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 == 0x7066 goto pc+29 r2 = r9 r2 -= 2 if r2 s< 0x4 goto pc+3 r0 = *(u32 *)(r8 +2) r0 = be32 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 2 call bpf_skb_load_helper_32 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x55784d5b goto pc+16 r2 = r9 if r2 s< 0x2 goto pc+3 r0 = *(u16 *)(r8 +0) r0 = be16 r0 goto pc+8 r1 = r6 r2 = r8 r3 = r9 r4 = 0 call bpf_skb_load_helper_16 if r0 s>= 0x0 goto pc+2 w0 ^= w0 exit if r0 != 0x7066 goto pc+2 w0 = 0 exit w0 = 262144 exit