selftests/bpf: Fix endianness issues in atomic tests
Subsystems (3)
PATCH 1/1 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.
--- tools/testing/selftests/bpf/verifier/atomic_and.c | 2 +- tools/testing/selftests/bpf/verifier/atomic_or.c | 2 +- tools/testing/selftests/bpf/verifier/atomic_xor.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/verifier/atomic_and.c +1 -1
@@ -7,7 +7,7 @@BPF_MOV64_IMM (BPF_REG_1 ,0x011 ),BPF_ATOMIC_OP (BPF_DW ,BPF_AND ,BPF_REG_10 ,BPF_REG_1 ,-8 ),/* if (val != 0x010) exit(2); */ -BPF_LDX_MEM (BPF_W ,BPF_REG_0 ,BPF_REG_10 ,-8 ), +BPF_LDX_MEM (BPF_DW ,BPF_REG_0 ,BPF_REG_10 ,-8 ),BPF_JMP_IMM (BPF_JEQ ,BPF_REG_0 ,0x010 ,2 ),BPF_MOV64_IMM (BPF_REG_0 ,2 ), BPF_EXIT_INSN(),
tools/testing/selftests/bpf/verifier/atomic_or.c +1 -1
@@ -7,7 +7,7 @@BPF_MOV64_IMM (BPF_REG_1 ,0x011 ),BPF_ATOMIC_OP (BPF_DW ,BPF_OR ,BPF_REG_10 ,BPF_REG_1 ,-8 ),/* if (val != 0x111) exit(2); */ -BPF_LDX_MEM (BPF_W ,BPF_REG_0 ,BPF_REG_10 ,-8 ), +BPF_LDX_MEM (BPF_DW ,BPF_REG_0 ,BPF_REG_10 ,-8 ),BPF_JMP_IMM (BPF_JEQ ,BPF_REG_0 ,0x111 ,2 ),BPF_MOV64_IMM (BPF_REG_0 ,2 ), BPF_EXIT_INSN(),
tools/testing/selftests/bpf/verifier/atomic_xor.c +1 -1
@@ -7,7 +7,7 @@BPF_MOV64_IMM (BPF_REG_1 ,0x011 ),BPF_ATOMIC_OP (BPF_DW ,BPF_XOR ,BPF_REG_10 ,BPF_REG_1 ,-8 ),/* if (val != 0x101) exit(2); */ -BPF_LDX_MEM (BPF_W ,BPF_REG_0 ,BPF_REG_10 ,-8 ), +BPF_LDX_MEM (BPF_DW ,BPF_REG_0 ,BPF_REG_10 ,-8 ),BPF_JMP_IMM (BPF_JEQ ,BPF_REG_0 ,0x101 ,2 ),BPF_MOV64_IMM (BPF_REG_0 ,2 ), BPF_EXIT_INSN(),
Signature · 1 line
2.29.2
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf-next.git (refs/heads/master):
Quoted 9 lines · On Wed, 10 Feb 2021 03:07:13 +0100 you wrote:
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 <[email protected]>Fixes 98d666d05a1d ("bpf: Add tests for new BPF atomic operations")[...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Fix endianness issues in atomic tests
https://git.kernel.org/bpf/bpf-next/c/45df30526825
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Andrii Nakryiko
AppliedQuoted 9 lines · Ilya Leoshkevich
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 <[email protected]>Fixes 98d666d05a1d ("bpf: Add tests for new BPF atomic operations")---
Applied to bpf-next.
Quoted 5 lines
tools/testing/selftests/bpf/verifier/atomic_and.c | 2 +- tools/testing/selftests/bpf/verifier/atomic_or.c | 2 +- tools/testing/selftests/bpf/verifier/atomic_xor.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)