On 9/10/26 11:22 PM, [email protected] wrote:
selftests/bpf: cover the low-32 link for sign-extending movs

Five programs, mirroring the zero-extending set:

  - sext_mov_wide_src: narrowing the source reaches the destination, and
    the value that arrives is sign-extended rather than zero-extended
  - sext_self_mov_keeps_link: r0 = (s32)r0 on an already-linked register
    stays in its set, the shape a sign-extended int return takes
  - sext_self_mov_no_link: the same mov on an unlinked register mints no id
  - sext_no_sync_when_base_has_delta: a delta on the base stops propagation
  - sext_no_sync_from_subreg_base: narrowing the link does not run
    backwards into the rest of the set
  - sext_kinds_reach_different_values: the same low half reaches -1 through
    a sign extension and 0xffffffff through a zero extension

Each guards a div by zero that is only unreachable if the propagation
happened, so losing the link is a verification failure rather than a test
that quietly stops checking anything.
This isn't a bug, but should the count read "six programs", and could the
closing sentence be scoped to the two __success programs, since
sext_self_mov_no_link has no div and the __failure ones expect it to be
reachable?

OK.

diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h 
b/tools/testing/selftests/bpf/progs/bpf_misc.h
index eb88d9ce6c34..45bfa02a5338 100644
--- a/tools/testing/selftests/bpf/progs/bpf_misc.h
+++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
@@ -269,6 +269,14 @@
  #define CAN_USE_BPF_ST
  #endif

+#if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) ||     \
+     (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) ||           \
+     defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390) ||      \
+     defined(__TARGET_ARCH_loongarch)) &&                              \
+       (__clang_major__ >= 18 || defined(__BPF_FEATURE_MOVSX))
+#define CAN_USE_MOVSX
+#endif
+
This isn't a bug, but now that the gate lives in bpf_misc.h, would it be
worth switching verifier_movsx.c's inline #if over to #ifdef CAN_USE_MOVSX
so the arch/feature list exists in one place?

Yes.

Thx,
-Vineet

diff --git a/tools/testing/selftests/bpf/progs/verifier_linked_scalars.c 
b/tools/testing/selftests/bpf/progs/verifier_linked_scalars.c
index 65cb0efd268f..9d060d8b0c1f 100644
[ ... ]


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/34506184282


Reply via email to