* [PATCH bpf-next v2] selftests/bpf: Enable signed overflow and small value tests for LoongArch
@ 2026-10-30 9:13 Tiezhu Yang
2026-10-30 19:50 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Tiezhu Yang @ 2026-10-30 9:13 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
Eduard Zingerman, Kumar Kartikeya Dwivedi
Cc: bpf, loongarch, linux-kernel
The LoongArch hardware divider handles signed overflow boundaries (such
as INT_MIN/-1 or LLONG_MIN/-1) natively and perfectly well on physical
silicon: (1) for division operations, it naturally returns the dividend
itself; (2) for modulo operations, it returns 0.
Furthermore, small value signed calculations with negative divisors work
correctly as expected.
Thus add the __arch_loongarch macro tag to these 16 test cases to enable
them for LoongArch in verifier_sdiv.c.
Before:
$ sudo ./test_progs -t verifier_sdiv | tail -1
Summary: 1/128 PASSED, 16 SKIPPED, 0/0 FAILED
After:
$ sudo ./test_progs -t verifier_sdiv | tail -1
Summary: 1/144 PASSED, 0 SKIPPED, 0/0 FAILED
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
.../testing/selftests/bpf/progs/verifier_sdiv.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/verifier_sdiv.c b/tools/testing/selftests/bpf/progs/verifier_sdiv.c
index d6cbe1e27fd6..4ac92335da91 100644
--- a/tools/testing/selftests/bpf/progs/verifier_sdiv.c
+++ b/tools/testing/selftests/bpf/progs/verifier_sdiv.c
@@ -775,6 +775,7 @@ SEC("socket")
__description("SDIV64, overflow r/r, LLONG_MIN/-1")
__success __retval(1)
__arch_x86_64
+__arch_loongarch
__xlated("0: r2 = 0x8000000000000000")
__xlated("2: r3 = -1")
__xlated("3: r4 = r2")
@@ -810,6 +811,7 @@ SEC("socket")
__description("SDIV64, r/r, small_val/-1")
__success __retval(-5)
__arch_x86_64
+__arch_loongarch
__xlated("0: r2 = 5")
__xlated("1: r3 = -1")
__xlated("2: r12 = r3")
@@ -839,6 +841,7 @@ SEC("socket")
__description("SDIV64, overflow r/i, LLONG_MIN/-1")
__success __retval(1)
__arch_x86_64
+__arch_loongarch
__xlated("0: r2 = 0x8000000000000000")
__xlated("2: r4 = r2")
__xlated("3: r2 = -r2")
@@ -865,6 +868,7 @@ SEC("socket")
__description("SDIV64, r/i, small_val/-1")
__success __retval(-5)
__arch_x86_64
+__arch_loongarch
__xlated("0: r2 = 5")
__xlated("1: r4 = r2")
__xlated("2: r2 = -r2")
@@ -887,6 +891,7 @@ SEC("socket")
__description("SDIV32, overflow r/r, INT_MIN/-1")
__success __retval(1)
__arch_x86_64
+__arch_loongarch
__xlated("0: w2 = -2147483648")
__xlated("1: w3 = -1")
__xlated("2: w4 = w2")
@@ -922,6 +927,7 @@ SEC("socket")
__description("SDIV32, r/r, small_val/-1")
__success __retval(5)
__arch_x86_64
+__arch_loongarch
__xlated("0: w2 = -5")
__xlated("1: w3 = -1")
__xlated("2: w4 = w2")
@@ -953,6 +959,7 @@ SEC("socket")
__description("SDIV32, overflow r/i, INT_MIN/-1")
__success __retval(1)
__arch_x86_64
+__arch_loongarch
__xlated("0: w2 = -2147483648")
__xlated("1: w4 = w2")
__xlated("2: w2 = -w2")
@@ -979,6 +986,7 @@ SEC("socket")
__description("SDIV32, r/i, small_val/-1")
__success __retval(-5)
__arch_x86_64
+__arch_loongarch
__xlated("0: w2 = 5")
__xlated("1: w4 = w2")
__xlated("2: w2 = -w2")
@@ -1001,6 +1009,7 @@ SEC("socket")
__description("SMOD64, overflow r/r, LLONG_MIN/-1")
__success __retval(0)
__arch_x86_64
+__arch_loongarch
__xlated("0: r2 = 0x8000000000000000")
__xlated("2: r3 = -1")
__xlated("3: r4 = r2")
@@ -1031,6 +1040,7 @@ SEC("socket")
__description("SMOD64, r/r, small_val/-1")
__success __retval(0)
__arch_x86_64
+__arch_loongarch
__xlated("0: r2 = 5")
__xlated("1: r3 = -1")
__xlated("2: r4 = r2")
@@ -1061,6 +1071,7 @@ SEC("socket")
__description("SMOD64, overflow r/i, LLONG_MIN/-1")
__success __retval(0)
__arch_x86_64
+__arch_loongarch
__xlated("0: r2 = 0x8000000000000000")
__xlated("2: r4 = r2")
__xlated("3: w2 = 0")
@@ -1083,6 +1094,7 @@ SEC("socket")
__description("SMOD64, r/i, small_val/-1")
__success __retval(0)
__arch_x86_64
+__arch_loongarch
__xlated("0: r2 = 5")
__xlated("1: r4 = r2")
__xlated("2: w2 = 0")
@@ -1105,6 +1117,7 @@ SEC("socket")
__description("SMOD32, overflow r/r, INT_MIN/-1")
__success __retval(0)
__arch_x86_64
+__arch_loongarch
__xlated("0: w2 = -2147483648")
__xlated("1: w3 = -1")
__xlated("2: w4 = w2")
@@ -1137,6 +1150,7 @@ SEC("socket")
__description("SMOD32, r/r, small_val/-1")
__success __retval(0)
__arch_x86_64
+__arch_loongarch
__xlated("0: w2 = -5")
__xlated("1: w3 = -1")
__xlated("2: w4 = w2")
@@ -1169,6 +1183,7 @@ SEC("socket")
__description("SMOD32, overflow r/i, INT_MIN/-1")
__success __retval(0)
__arch_x86_64
+__arch_loongarch
__xlated("0: w2 = -2147483648")
__xlated("1: w4 = w2")
__xlated("2: w2 = 0")
@@ -1191,6 +1206,7 @@ SEC("socket")
__description("SMOD32, r/i, small_val/-1")
__success __retval(0)
__arch_x86_64
+__arch_loongarch
__xlated("0: w2 = 5")
__xlated("1: w4 = w2")
__xlated("2: w2 = 0")
--
2.42.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH bpf-next v2] selftests/bpf: Enable signed overflow and small value tests for LoongArch
2026-10-30 9:13 [PATCH bpf-next v2] selftests/bpf: Enable signed overflow and small value tests for LoongArch Tiezhu Yang
@ 2026-10-30 19:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-10-30 19:50 UTC (permalink / raw)
To: Tiezhu Yang
Cc: ast, daniel, andrii, eddyz87, memxor, bpf, loongarch, linux-kernel
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Fri, 30 Oct 2026 17:13:05 +0800 you wrote:
> The LoongArch hardware divider handles signed overflow boundaries (such
> as INT_MIN/-1 or LLONG_MIN/-1) natively and perfectly well on physical
> silicon: (1) for division operations, it naturally returns the dividend
> itself; (2) for modulo operations, it returns 0.
>
> Furthermore, small value signed calculations with negative divisors work
> correctly as expected.
>
> [...]
Here is the summary with links:
- [bpf-next,v2] selftests/bpf: Enable signed overflow and small value tests for LoongArch
https://git.kernel.org/bpf/bpf-next/c/aef18c73c961
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-30 19:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 9:13 [PATCH bpf-next v2] selftests/bpf: Enable signed overflow and small value tests for LoongArch Tiezhu Yang
2026-10-30 19:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®