Skip to content

Commit 53e33f9

Browse files
Johan Almbladhborkmann
authored andcommitted
bpf, tests: Add test for 32-bit context pointer argument passing
On a 32-bit architecture, the context pointer will occupy the low half of R1, and the other half will be zero. Signed-off-by: Johan Almbladh <johan.almbladh@anyfinetworks.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210809091829.810076-12-johan.almbladh@anyfinetworks.com
1 parent 66e5eb8 commit 53e33f9

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/test_bpf.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,22 @@ static struct bpf_test tests[] = {
20922092
#undef NUMER
20932093
#undef DENOM
20942094
},
2095+
#ifdef CONFIG_32BIT
2096+
{
2097+
"INT: 32-bit context pointer word order and zero-extension",
2098+
.u.insns_int = {
2099+
BPF_ALU32_IMM(BPF_MOV, R0, 0),
2100+
BPF_JMP32_IMM(BPF_JEQ, R1, 0, 3),
2101+
BPF_ALU64_IMM(BPF_RSH, R1, 32),
2102+
BPF_JMP32_IMM(BPF_JNE, R1, 0, 1),
2103+
BPF_ALU32_IMM(BPF_MOV, R0, 1),
2104+
BPF_EXIT_INSN(),
2105+
},
2106+
INTERNAL,
2107+
{ },
2108+
{ { 0, 1 } }
2109+
},
2110+
#endif
20952111
{
20962112
"check: missing ret",
20972113
.u.insns = {

0 commit comments

Comments
 (0)