From: Eduard Zingerman <eddyz87@gmail.com>
To: KaFai Wan <kafai.wan@linux.dev>,
puranjay@kernel.org, xukuohai@huaweicloud.com
Cc: ast@kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com,
andrii@kernel.org, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, mykolal@fb.com,
shuah@kernel.org, mrpre@163.com, linux-kernel@vger.kernel.org,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf v2 2/2] selftests/bpf: Add socket filter attach test
Date: Wed, 13 Aug 2025 17:35:01 -0700 [thread overview]
Message-ID: <eb6f9ba4acccc7685596a8f1b282667a43d51ca8.camel@gmail.com> (raw)
In-Reply-To: <20250813152958.3107403-3-kafai.wan@linux.dev>
[-- Attachment #1: Type: text/plain, Size: 925 bytes --]
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.wan@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?
[...]
[-- Attachment #2: filter-show-prog.diff --]
[-- Type: text/x-patch, Size: 1041 bytes --]
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;
[-- Attachment #3: socket-filter-prog.txt --]
[-- Type: text/plain, Size: 6800 bytes --]
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
next prev parent reply other threads:[~2025-08-14 0:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 15:29 [PATCH bpf v2 0/2] bpf: Allow fall back to interpreter for programs with stack size <= 512 KaFai Wan
2025-08-13 15:29 ` [PATCH bpf v2 1/2] " KaFai Wan
2025-08-13 15:29 ` [PATCH bpf v2 2/2] selftests/bpf: Add socket filter attach test KaFai Wan
2025-08-14 0:35 ` Eduard Zingerman [this message]
2025-08-14 11:23 ` Puranjay Mohan
2025-08-14 16:06 ` Eduard Zingerman
2025-08-16 15:14 ` KaFai Wan
2025-08-25 19:27 ` Puranjay Mohan
2025-08-25 19:32 ` Eduard Zingerman
2025-08-27 11:16 ` Puranjay Mohan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb6f9ba4acccc7685596a8f1b282667a43d51ca8.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kafai.wan@linux.dev \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mrpre@163.com \
--cc=mykolal@fb.com \
--cc=puranjay@kernel.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=xukuohai@huaweicloud.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).