Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Verify zero-extension behavior in load-acquire tests

Verify that 8-, 16- and 32-bit load-acquires are zero-extending by using
immediate values with their highest bit set. Do the same for the 64-bit
variant to keep the style consistent.

Acked-by: Björn Töpel <bjorn@kernel.org>
Reviewed-by: Pu Lehui <pulehui@huawei.com>
Tested-by: Björn Töpel <bjorn@rivosinc.com> # QEMU/RVA23
Signed-off-by: Peilin Ye <yepeilin@google.com>
Link: https://lore.kernel.org/r/11097fd515f10308b3941469ee4c86cb8872db3f.1746588351.git.yepeilin@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Peilin Ye and committed by
Alexei Starovoitov
0357f29d 6e492ffc

+4 -4
+4 -4
tools/testing/selftests/bpf/progs/verifier_load_acquire.c
··· 15 15 { 16 16 asm volatile ( 17 17 "r0 = 0;" 18 - "w1 = 0x12;" 18 + "w1 = 0xfe;" 19 19 "*(u8 *)(r10 - 1) = w1;" 20 20 ".8byte %[load_acquire_insn];" // w2 = load_acquire((u8 *)(r10 - 1)); 21 21 "if r2 == r1 goto 1f;" ··· 35 35 { 36 36 asm volatile ( 37 37 "r0 = 0;" 38 - "w1 = 0x1234;" 38 + "w1 = 0xfedc;" 39 39 "*(u16 *)(r10 - 2) = w1;" 40 40 ".8byte %[load_acquire_insn];" // w2 = load_acquire((u16 *)(r10 - 2)); 41 41 "if r2 == r1 goto 1f;" ··· 55 55 { 56 56 asm volatile ( 57 57 "r0 = 0;" 58 - "w1 = 0x12345678;" 58 + "w1 = 0xfedcba09;" 59 59 "*(u32 *)(r10 - 4) = w1;" 60 60 ".8byte %[load_acquire_insn];" // w2 = load_acquire((u32 *)(r10 - 4)); 61 61 "if r2 == r1 goto 1f;" ··· 75 75 { 76 76 asm volatile ( 77 77 "r0 = 0;" 78 - "r1 = 0x1234567890abcdef ll;" 78 + "r1 = 0xfedcba0987654321 ll;" 79 79 "*(u64 *)(r10 - 8) = r1;" 80 80 ".8byte %[load_acquire_insn];" // r2 = load_acquire((u64 *)(r10 - 8)); 81 81 "if r2 == r1 goto 1f;"