BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch
@ 2026-11-26  5:53 George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

This series enables the BPF selftests for the new LoongArch JIT
features, and fixes a libarena build failure with clang 19.

Patch 1 fixes the build of the libarena buddy allocator selftests with
clang 19, which refuses the signed remainder in test_buddy_alloc_free().

Patches 2-5 enable the following tests for LoongArch:

  - the 2 KiB private stack test in verifier_large_stack
  - the struct_ops private stack tests
  - the arena LDSX tests in verifier_ldsx
  - the arena load-acquire and store-release tests in arena_atomics, and
    the libarena spmc and bitmap parallel tests

The LoongArch JIT support for these features is in the following series,
which goes through the LoongArch tree:

  LoongArch: BPF: Add private stack, exceptions, large stack and arena support
  https://lore.kernel.org/loongarch/20261126034048.7370-1-dongtai.guo@linux.dev/T/#u

These patches were part of v2 of the LoongArch BPF series:
https://lore.kernel.org/loongarch/20260702022322.51033-1-dongtai.guo@linux.dev/

Since then:
  - Split the selftests patches out of the LoongArch series and rebase
    them onto bpf-next.
  - New patch 1: use an unsigned loop counter in test_buddy_alloc_free.
  - New patch 2: enable the 2 KiB private stack test.
  - Patch 5: also enable the libarena spmc test, which has the same
    guard as arena_atomics (Sashiko), and the libarena bitmap test,
    which needs cmpxchg on arena too.
  - Drop "selftests/bpf: Add LoongArch deny list" (Tiezhu).
  - Reword the subjects and commit messages.

George Guo (5):
  selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free
  selftests/bpf: Enable 2 KiB private stack test for LoongArch
  selftests/bpf: Enable struct_ops private stack tests for LoongArch
  selftests/bpf: Enable arena LDSX tests for LoongArch
  selftests/bpf: Enable arena atomics tests for LoongArch

 .../bpf/libarena/selftests/test_buddy.bpf.c     |  3 ++-
 .../selftests/test_parallel_bitmap.bpf.c        |  1 +
 .../libarena/selftests/test_parallel_spmc.bpf.c |  1 +
 .../bpf/prog_tests/struct_ops_private_stack.c   |  3 ++-
 .../testing/selftests/bpf/progs/arena_atomics.c |  3 +++
 .../selftests/bpf/progs/verifier_large_stack.c  |  1 +
 .../testing/selftests/bpf/progs/verifier_ldsx.c | 17 +++++++++++++++++
 7 files changed, 27 insertions(+), 2 deletions(-)


base-commit: 486b5ce7184f7449ef2fe1e951455b0b8a114060
-- 
2.53.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch George Guo
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

test_buddy_alloc_free() picks an allocation size with
alloc_free_sizes[(i * 5) % 8], where i is a signed int. That is a
signed remainder, which clang 19 refuses to compile for BPF without
-mcpu=v4:

  test_buddy.bpf.c:80:54: error: unsupported signed division, please convert to unsigned div/mod.

i only counts up from zero, so make it a u32, like the loop counter in
test_buddy_alloc_multiple() and the u32 zero it starts from. The
remainder becomes unsigned and the selected sizes are unchanged.

Fixes: b1487dc1b181 ("selftests/bpf: Add selftests for libarena buddy allocator")
Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 .../testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c
index 886a09019566..00f1efe931af 100644
--- a/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c
+++ b/tools/testing/selftests/bpf/libarena/selftests/test_buddy.bpf.c
@@ -99,7 +99,8 @@ __weak int test_buddy_alloc_free(void)
 {
 	const int iters = 800;
 	void __arena *mem;
-	int ret, i;
+	int ret;
+	u32 i;
 
 	ret = buddy_init(&buddy);
 	if (ret)
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  6:04   ` sashiko-bot
  2026-11-26  5:53 ` [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests " George Guo
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

As the LoongArch JIT supports both private stack and large stack, enable
the "private stack: two frames of 2048 bytes" test in
verifier_large_stack for LoongArch.

With this patch:
  $ sudo ./test_progs -a "verifier_large_stack/private stack: two frames of 2048 bytes" | tail -1
  Summary: 1/1 PASSED, 0 SKIPPED, 0/0 FAILED

Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 tools/testing/selftests/bpf/progs/verifier_large_stack.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/bpf/progs/verifier_large_stack.c b/tools/testing/selftests/bpf/progs/verifier_large_stack.c
index cbabb41d973c..f25455d628d5 100644
--- a/tools/testing/selftests/bpf/progs/verifier_large_stack.c
+++ b/tools/testing/selftests/bpf/progs/verifier_large_stack.c
@@ -248,6 +248,7 @@ __description("private stack: two frames of 2048 bytes")
 __load_if_large_stack()
 __arch_x86_64
 __arch_arm64
+__arch_loongarch
 __success __log_level(4)
 __msg("stack depth max 2048")
 __msg("subprog 0 (private_stack_two_frames) main {{.*}} stack 2048")
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
  2026-11-26  5:53 ` [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  6:05   ` sashiko-bot
  2026-11-26  5:53 ` [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX " George Guo
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

As the LoongArch JIT supports private stack, enable the struct_ops
private stack tests for LoongArch.

With this patch:
  $ sudo ./test_progs -t struct_ops_private_stack | tail -1
  Summary: 1/4 PASSED, 0 SKIPPED, 0/0 FAILED

Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 .../selftests/bpf/prog_tests/struct_ops_private_stack.c        | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
index 103179ff8733..730d5741591c 100644
--- a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
+++ b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
@@ -7,7 +7,8 @@
 #include "struct_ops_private_stack_large.skel.h"
 
 #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
-	(defined(__riscv) && __riscv_xlen == 64)
+	(defined(__riscv) && __riscv_xlen == 64) || \
+	(defined(__loongarch__) && __loongarch_grlen == 64)
 static void test_private_stack(void)
 {
 	struct struct_ops_private_stack *skel;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX tests for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
                   ` (2 preceding siblings ...)
  2026-11-26  5:53 ` [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests " George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  6:03   ` sashiko-bot
  2026-11-26  5:53 ` [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics " George Guo
  2026-11-26  6:06 ` [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena " Alexei Starovoitov
  5 siblings, 1 reply; 11+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

As the LoongArch JIT supports signed arena loads, enable the arena LDSX
tests in verifier_ldsx for LoongArch, and add the expected LoongArch JIT
disassembly for the arena_ldsx_disasm test.

With this patch:
  $ sudo ./test_progs -t verifier_ldsx | tail -1
  Summary: 1/24 PASSED, 0 SKIPPED, 0/0 FAILED

Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 .../testing/selftests/bpf/progs/verifier_ldsx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tools/testing/selftests/bpf/progs/verifier_ldsx.c b/tools/testing/selftests/bpf/progs/verifier_ldsx.c
index 232082428cb9..ad7ae015b39d 100644
--- a/tools/testing/selftests/bpf/progs/verifier_ldsx.c
+++ b/tools/testing/selftests/bpf/progs/verifier_ldsx.c
@@ -299,6 +299,19 @@ __jited("add	t2, a0, s7")
 __jited("lh	s4, 0x18(t2)")
 __jited("add	t2, a0, s7")
 __jited("lb	s4, 0x20(t2)")
+__arch_loongarch
+__jited("add.d	$t2, $a5, $s6")
+__jited("ld.w	$s2, $t2, 16")
+__jited("add.d	$t2, $a5, $s6")
+__jited("ld.h	$s2, $t2, 24")
+__jited("add.d	$t2, $a5, $s6")
+__jited("ld.b	$s2, $t2, 32")
+__jited("add.d	$t2, $a0, $s6")
+__jited("ld.w	$s3, $t2, 16")
+__jited("add.d	$t2, $a0, $s6")
+__jited("ld.h	$s3, $t2, 24")
+__jited("add.d	$t2, $a0, $s6")
+__jited("ld.b	$s3, $t2, 32")
 __naked void arena_ldsx_disasm(void *ctx)
 {
 	asm volatile (
@@ -331,6 +344,7 @@ __success __retval(0)
 __arch_x86_64
 __arch_arm64
 __arch_riscv64
+__arch_loongarch
 __naked void arena_ldsx_exception(void *ctx)
 {
 	asm volatile (
@@ -353,6 +367,7 @@ __success __retval(-1)
 __arch_x86_64
 __arch_arm64
 __arch_riscv64
+__arch_loongarch
 __naked void arena_ldsx_s8(void *ctx)
 {
 	asm volatile (
@@ -385,6 +400,7 @@ __success __retval(-1)
 __arch_x86_64
 __arch_arm64
 __arch_riscv64
+__arch_loongarch
 __naked void arena_ldsx_s16(void *ctx)
 {
 	asm volatile (
@@ -417,6 +433,7 @@ __success __retval(-1)
 __arch_x86_64
 __arch_arm64
 __arch_riscv64
+__arch_loongarch
 __naked void arena_ldsx_s32(void *ctx)
 {
 	asm volatile (
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics tests for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
                   ` (3 preceding siblings ...)
  2026-11-26  5:53 ` [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX " George Guo
@ 2026-11-26  5:53 ` George Guo
  2026-11-26  6:06   ` sashiko-bot
  2026-11-26  6:06 ` [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena " Alexei Starovoitov
  5 siblings, 1 reply; 11+ messages in thread
From: George Guo @ 2026-11-26  5:53 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

From: George Guo <guodongtai@kylinos.cn>

As the LoongArch JIT supports arena atomics, add LoongArch to the
architecture guards of the load-acquire and store-release tests in
arena_atomics, and of the spmc and bitmap parallel tests in libarena,
which use atomics on arena too.

With this patch:
  $ sudo ./test_progs -t arena_atomics | tail -1
  Summary: 1/11 PASSED, 0 SKIPPED, 0/0 FAILED

  $ sudo ./test_progs -t libarena | tail -1
  Summary: 2/43 PASSED, 0 SKIPPED, 0/0 FAILED

Signed-off-by: George Guo <guodongtai@kylinos.cn>
---
 .../bpf/libarena/selftests/test_parallel_bitmap.bpf.c          | 1 +
 .../selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c  | 1 +
 tools/testing/selftests/bpf/progs/arena_atomics.c              | 3 +++
 3 files changed, 5 insertions(+)

diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c
index 017add229bef..722971b1eba8 100644
--- a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c
+++ b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c
@@ -24,6 +24,7 @@ static volatile bool test_abort;
 	(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
 	 defined(__TARGET_ARCH_s390) || \
 	 defined(__TARGET_ARCH_powerpc) ||				  \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64))
 static bool bitmap_tests_enabled(void)
 {
diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
index 5fa96eb74095..af577e1e5050 100644
--- a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
+++ b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
@@ -70,6 +70,7 @@ static volatile u64 round_steals;
  */
 #if defined(ENABLE_ATOMICS_TESTS) &&		  \
 	(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64))
 static bool spmc_tests_enabled(void)
 {
diff --git a/tools/testing/selftests/bpf/progs/arena_atomics.c b/tools/testing/selftests/bpf/progs/arena_atomics.c
index 2a9664f54399..fcb70b984434 100644
--- a/tools/testing/selftests/bpf/progs/arena_atomics.c
+++ b/tools/testing/selftests/bpf/progs/arena_atomics.c
@@ -30,6 +30,7 @@ bool skip_all_tests = true;
 	defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \
 	(defined(__TARGET_ARCH_arm64) || \
 	 defined(__TARGET_ARCH_x86) || \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
 	 defined(__TARGET_ARCH_s390))
 bool skip_lacq_srel_tests __attribute((__section__(".data"))) = false;
@@ -454,6 +455,7 @@ int load_acquire(const void *ctx)
 	defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \
 	(defined(__TARGET_ARCH_arm64) || \
 	 defined(__TARGET_ARCH_x86) || \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
 	 defined(__TARGET_ARCH_s390))
 
@@ -508,6 +510,7 @@ int store_release(const void *ctx)
 	defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \
 	(defined(__TARGET_ARCH_arm64) || \
 	 defined(__TARGET_ARCH_x86) || \
+	 defined(__TARGET_ARCH_loongarch) || \
 	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
 	 defined(__TARGET_ARCH_s390))
 
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX tests for LoongArch
  2026-11-26  5:53 ` [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX " George Guo
@ 2026-11-26  6:03   ` sashiko-bot
  0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-26  6:03 UTC (permalink / raw)
  To: George Guo; +Cc: bpf

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests/bpf: arena LDSX tests enabled on LoongArch without
  JIT support
--

commit b68bf732b641a949e70ea34125906397162f4821
Author: George Guo <guodongtai@kylinos.cn>

selftests/bpf: Enable arena LDSX tests for LoongArch

This commit enables the arena signed-load tests in verifier_ldsx on
LoongArch and adds the expected LoongArch JIT disassembly for
arena_ldsx_disasm.

> diff --git a/tools/testing/selftests/bpf/progs/verifier_ldsx.c b/tools/testing/selftests/bpf/progs/verifier_ldsx.c
> index 232082428cb96..ad7ae015b39d9 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_ldsx.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_ldsx.c
> @@ -299,6 +299,19 @@ __jited("add	t2, a0, s7")
>  __jited("lh	s4, 0x18(t2)")
>  __jited("add	t2, a0, s7")
>  __jited("lb	s4, 0x20(t2)")
> +__arch_loongarch
> +__jited("add.d	$t2, $a5, $s6")
> +__jited("ld.w	$s2, $t2, 16")
> +__jited("add.d	$t2, $a5, $s6")
> +__jited("ld.h	$s2, $t2, 24")
> +__jited("add.d	$t2, $a5, $s6")
> +__jited("ld.b	$s2, $t2, 32")
> +__jited("add.d	$t2, $a0, $s6")
> +__jited("ld.w	$s3, $t2, 16")
> +__jited("add.d	$t2, $a0, $s6")
> +__jited("ld.h	$s3, $t2, 24")
> +__jited("add.d	$t2, $a0, $s6")
> +__jited("ld.b	$s3, $t2, 32")
>  __naked void arena_ldsx_disasm(void *ctx)
>  {
>  	asm volatile (
> @@ -331,6 +344,7 @@ __success __retval(0)
>  __arch_x86_64
>  __arch_arm64
>  __arch_riscv64
> +__arch_loongarch
>  __naked void arena_ldsx_exception(void *ctx)
>  {
>  	asm volatile (
> @@ -353,6 +367,7 @@ __success __retval(-1)
>  __arch_x86_64
>  __arch_arm64
>  __arch_riscv64
> +__arch_loongarch
>  __naked void arena_ldsx_s8(void *ctx)
>  {
>  	asm volatile (
> @@ -385,6 +400,7 @@ __success __retval(-1)
>  __arch_x86_64
>  __arch_arm64
>  __arch_riscv64
> +__arch_loongarch
>  __naked void arena_ldsx_s16(void *ctx)
>  {
>  	asm volatile (
> @@ -417,6 +433,7 @@ __success __retval(-1)
>  __arch_x86_64
>  __arch_arm64
>  __arch_riscv64
> +__arch_loongarch
>  __naked void arena_ldsx_s32(void *ctx)
>  {
>  	asm volatile (

[Severity: Medium]
Does enabling these five arena signed-load tests depend on a missing
LoongArch JIT patch?

In convert_ctx_accesses(), BPF_MEMSX loads on PTR_TO_ARENA require
bpf_jit_supports_insn(insn, true) to return true before rewriting the
instruction to BPF_PROBE_MEM32SX:

kernel/bpf/fixups.c:convert_ctx_accesses() {
    ...
		case PTR_TO_ARENA:
			if (BPF_MODE(insn->code) == BPF_MEMSX) {
				if (!bpf_jit_supports_insn(insn, true)) {
					verbose(env, "sign extending loads from arena are not supported yet\n");
					return -EOPNOTSUPP;
				}
				insn->code = BPF_CLASS(insn->code) | BPF_PROBE_MEM32SX | BPF_SIZE(insn->code);
    ...
}

arch/loongarch/net/bpf_jit.c does not implement bpf_jit_supports_insn()
or handle BPF_PROBE_MEM32SX in build_insn() and add_exception_handler(),
so LoongArch falls back to the weak default bpf_jit_supports_insn() in
kernel/bpf/core.c that returns false.  As a result, the verifier rejects
all five programs with -EOPNOTSUPP and verifier_ldsx fails on LoongArch
instead of skipping them.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126055355.9967-1-dongtai.guo@linux.dev?part=4

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch
  2026-11-26  5:53 ` [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch George Guo
@ 2026-11-26  6:04   ` sashiko-bot
  0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-26  6:04 UTC (permalink / raw)
  To: George Guo; +Cc: bpf

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests/bpf: private_stack_two_frames() enabled for
  unsupported LoongArch JIT
--

commit 65d887cfcad54f20dce9c27e1aed6c9c9985bbb9
Author: George Guo <guodongtai@kylinos.cn>

selftests/bpf: Enable 2 KiB private stack test for LoongArch

This commit adds __arch_loongarch to the private_stack_two_frames test in
verifier_large_stack.c.

> diff --git a/tools/testing/selftests/bpf/progs/verifier_large_stack.c b/tools/testing/selftests/bpf/progs/verifier_large_stack.c
> index cbabb41d973c8..f25455d628d5c 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_large_stack.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_large_stack.c
> @@ -248,6 +248,7 @@ __description("private stack: two frames of 2048 bytes")
>  __load_if_large_stack()
>  __arch_x86_64
>  __arch_arm64
> +__arch_loongarch
>  __success __log_level(4)
>  __msg("stack depth max 2048")
>  __msg("subprog 0 (private_stack_two_frames) main {{.*}} stack 2048")

[Severity: Medium]
Does this depend on LoongArch JIT patches that are not in the tree yet?

arch/loongarch/net/bpf_jit.c implements neither bpf_jit_supports_large_stack()
nor bpf_jit_supports_private_stack(), so both use the weak defaults in
kernel/bpf/core.c that return false.  As a result, is_large_stack_supported()
returns false and __load_if_large_stack() still causes run_subtest() to skip
private_stack_two_frames on LoongArch, and if large stack support is later
added before private stack support, bpf_enable_priv_stack() will return
NO_PRIV_STACK and the verifier will reject the two 2048-byte frames.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126055355.9967-1-dongtai.guo@linux.dev?part=2

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests for LoongArch
  2026-11-26  5:53 ` [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests " George Guo
@ 2026-11-26  6:05   ` sashiko-bot
  0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-26  6:05 UTC (permalink / raw)
  To: George Guo; +Cc: bpf

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests/bpf: test_private_stack() fails on LoongArch
  lacking JIT support
--

commit a704d33c4d953257fca9dfdc057e22e872b058cc
Author: George Guo <guodongtai@kylinos.cn>

selftests/bpf: Enable struct_ops private stack tests for LoongArch

This commit enables the struct_ops private stack selftests on 64-bit
LoongArch.

> diff --git a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
> index 103179ff8733b..730d5741591c5 100644
> --- a/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
> +++ b/tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
> @@ -7,7 +7,8 @@
>  #include "struct_ops_private_stack_large.skel.h"
>  
>  #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) || \
> -	(defined(__riscv) && __riscv_xlen == 64)
> +	(defined(__riscv) && __riscv_xlen == 64) || \
> +	(defined(__loongarch__) && __loongarch_grlen == 64)
>  static void test_private_stack(void)
>  {
>  	struct struct_ops_private_stack *skel;

[Severity: Medium]
Will test_private_stack() and test_private_stack_recur() fail to load with
-EACCES on 64-bit LoongArch instead of skipping?

Both tests attach struct_ops programs to bpf_testmod_ops3.test_1, for
which st_ops3_check_member() sets prog->aux->priv_stack_requested = true.
arch/loongarch/net/bpf_jit.c does not implement private stack support or
override bpf_jit_supports_private_stack(), so it falls back to the weak
default returning false and check_struct_ops_btf_id() rejects the load:

kernel/bpf/verifier.c:check_struct_ops_btf_id() {
	...
	if (prog->aux->priv_stack_requested && !bpf_jit_supports_private_stack()) {
		verbose(env, "Private stack not supported by jit\n");
		return -EACCES;
	}
	...
}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126055355.9967-1-dongtai.guo@linux.dev?part=3

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics tests for LoongArch
  2026-11-26  5:53 ` [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics " George Guo
@ 2026-11-26  6:06   ` sashiko-bot
  0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-26  6:06 UTC (permalink / raw)
  To: George Guo; +Cc: bpf

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] selftests/bpf: arena atomics enabled on LoongArch without JIT
  support
--

commit 981cacb8f524da5a2f9e574371d2773a0e55c40e
Author: George Guo <guodongtai@kylinos.cn>

selftests/bpf: Enable arena atomics tests for LoongArch

This commit enables the load-acquire and store-release arena atomics
selftests, as well as the libarena parallel bitmap and spmc selftests, on
LoongArch.

> diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c
> index 017add229befe..722971b1eba8f 100644
> --- a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c
> +++ b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_bitmap.bpf.c
> @@ -24,6 +24,7 @@ static volatile bool test_abort;
>  	(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
>  	 defined(__TARGET_ARCH_s390) || \
>  	 defined(__TARGET_ARCH_powerpc) ||				  \
> +	 defined(__TARGET_ARCH_loongarch) || \
>  	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64))
>  static bool bitmap_tests_enabled(void)
>  {
> diff --git a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
> index 5fa96eb740951..af577e1e50508 100644
> --- a/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
> +++ b/tools/testing/selftests/bpf/libarena/selftests/test_parallel_spmc.bpf.c
> @@ -70,6 +70,7 @@ static volatile u64 round_steals;
>   */
>  #if defined(ENABLE_ATOMICS_TESTS) &&		  \
>  	(defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
> +	 defined(__TARGET_ARCH_loongarch) || \
>  	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64))
>  static bool spmc_tests_enabled(void)
>  {
> diff --git a/tools/testing/selftests/bpf/progs/arena_atomics.c b/tools/testing/selftests/bpf/progs/arena_atomics.c
> index 2a9664f543993..fcb70b9844346 100644
> --- a/tools/testing/selftests/bpf/progs/arena_atomics.c
> +++ b/tools/testing/selftests/bpf/progs/arena_atomics.c
> @@ -30,6 +30,7 @@ bool skip_all_tests = true;
>  	defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \
>  	(defined(__TARGET_ARCH_arm64) || \
>  	 defined(__TARGET_ARCH_x86) || \
> +	 defined(__TARGET_ARCH_loongarch) || \
>  	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
>  	 defined(__TARGET_ARCH_s390))
>  bool skip_lacq_srel_tests __attribute((__section__(".data"))) = false;
> @@ -454,6 +455,7 @@ int load_acquire(const void *ctx)
>  	defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \
>  	(defined(__TARGET_ARCH_arm64) || \
>  	 defined(__TARGET_ARCH_x86) || \
> +	 defined(__TARGET_ARCH_loongarch) || \
>  	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
>  	 defined(__TARGET_ARCH_s390))
>  
> @@ -508,6 +510,7 @@ int store_release(const void *ctx)
>  	defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \
>  	(defined(__TARGET_ARCH_arm64) || \
>  	 defined(__TARGET_ARCH_x86) || \
> +	 defined(__TARGET_ARCH_loongarch) || \
>  	 (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
>  	 defined(__TARGET_ARCH_s390))

[Severity: Medium]
Does enabling these arena atomics tests on LoongArch fail verification and
program loading because the LoongArch BPF JIT does not yet support arena
atomics?

For atomic instructions targeting PTR_TO_ARENA, atomic_ptr_type_ok() in
kernel/bpf/verifier.c checks bpf_jit_supports_insn(insn, true):

kernel/bpf/verifier.c:atomic_ptr_type_ok() {
    ...
	if (is_arena_reg(env, regno))
		return bpf_jit_supports_insn(insn, true);
    ...
}

arch/loongarch/net/bpf_jit.c does not implement bpf_jit_supports_insn(), so
LoongArch falls back to the weak default in kernel/bpf/core.c that returns
false, causing the verifier to reject any BPF_ATOMIC instruction on an
arena pointer with -EACCES.

In addition, do_misc_fixups() in kernel/bpf/fixups.c rewrites atomic
instructions on PTR_TO_ARENA to BPF_STX | BPF_PROBE_ATOMIC |
BPF_SIZE(insn->code), which build_insn() in arch/loongarch/net/bpf_jit.c
does not handle.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126055355.9967-1-dongtai.guo@linux.dev?part=5

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch
  2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
                   ` (4 preceding siblings ...)
  2026-11-26  5:53 ` [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics " George Guo
@ 2026-11-26  6:06 ` Alexei Starovoitov
  5 siblings, 0 replies; 11+ messages in thread
From: Alexei Starovoitov @ 2026-11-26  6:06 UTC (permalink / raw)
  To: George Guo, daniel, andrii, eddyz87, memxor
  Cc: bpf, loongarch, linux-kernel, George Guo

On Wed, Nov 25, 2026 at 09:53 PM George Guo <dongtai.guo@linux.dev> wrote:
> This series enables the BPF selftests for the new LoongArch JIT
> features, and fixes a libarena build failure with clang 19.

loongarch folks take JIT patches, so pls don't post
anything to bpf* until trees converge.

pw-bot: cr

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-11-26  6:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  5:53 [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena tests for LoongArch George Guo
2026-11-26  5:53 ` [PATCH bpf-next v1 1/5] selftests/bpf: Use unsigned loop counter in test_buddy_alloc_free George Guo
2026-11-26  5:53 ` [PATCH bpf-next v1 2/5] selftests/bpf: Enable 2 KiB private stack test for LoongArch George Guo
2026-11-26  6:04   ` sashiko-bot
2026-11-26  5:53 ` [PATCH bpf-next v1 3/5] selftests/bpf: Enable struct_ops private stack tests " George Guo
2026-11-26  6:05   ` sashiko-bot
2026-11-26  5:53 ` [PATCH bpf-next v1 4/5] selftests/bpf: Enable arena LDSX " George Guo
2026-11-26  6:03   ` sashiko-bot
2026-11-26  5:53 ` [PATCH bpf-next v1 5/5] selftests/bpf: Enable arena atomics " George Guo
2026-11-26  6:06   ` sashiko-bot
2026-11-26  6:06 ` [PATCH bpf-next v1 0/5] selftests/bpf: Enable private stack, large stack and arena " Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox