Skip to content

Commit 7791ee8

Browse files
iii-ikernel-patches-bot
authored andcommitted
selftests/bpf: Fix endianness issues in atomic tests
Atomic tests store a DW, but then load it back as a W from the same address. This doesn't work on big-endian systems, and since the point of those tests is not testing narrow loads, fix simply by loading a DW. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Fixes: 98d666d ("bpf: Add tests for new BPF atomic operations")
1 parent 32c4ce5 commit 7791ee8

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

tools/testing/selftests/bpf/verifier/atomic_and.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
BPF_MOV64_IMM(BPF_REG_1, 0x011),
88
BPF_ATOMIC_OP(BPF_DW, BPF_AND, BPF_REG_10, BPF_REG_1, -8),
99
/* if (val != 0x010) exit(2); */
10-
BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_10, -8),
10+
BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_10, -8),
1111
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0x010, 2),
1212
BPF_MOV64_IMM(BPF_REG_0, 2),
1313
BPF_EXIT_INSN(),

tools/testing/selftests/bpf/verifier/atomic_or.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
BPF_MOV64_IMM(BPF_REG_1, 0x011),
88
BPF_ATOMIC_OP(BPF_DW, BPF_OR, BPF_REG_10, BPF_REG_1, -8),
99
/* if (val != 0x111) exit(2); */
10-
BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_10, -8),
10+
BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_10, -8),
1111
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0x111, 2),
1212
BPF_MOV64_IMM(BPF_REG_0, 2),
1313
BPF_EXIT_INSN(),

tools/testing/selftests/bpf/verifier/atomic_xor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
BPF_MOV64_IMM(BPF_REG_1, 0x011),
88
BPF_ATOMIC_OP(BPF_DW, BPF_XOR, BPF_REG_10, BPF_REG_1, -8),
99
/* if (val != 0x101) exit(2); */
10-
BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_10, -8),
10+
BPF_LDX_MEM(BPF_DW, BPF_REG_0, BPF_REG_10, -8),
1111
BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0x101, 2),
1212
BPF_MOV64_IMM(BPF_REG_0, 2),
1313
BPF_EXIT_INSN(),

0 commit comments

Comments
 (0)