Commit 53e33f99 authored by Johan Almbladh's avatar Johan Almbladh Committed by Daniel Borkmann

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: default avatarJohan Almbladh <johan.almbladh@anyfinetworks.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210809091829.810076-12-johan.almbladh@anyfinetworks.com
parent 66e5eb84
...@@ -2092,6 +2092,22 @@ static struct bpf_test tests[] = { ...@@ -2092,6 +2092,22 @@ static struct bpf_test tests[] = {
#undef NUMER #undef NUMER
#undef DENOM #undef DENOM
}, },
#ifdef CONFIG_32BIT
{
"INT: 32-bit context pointer word order and zero-extension",
.u.insns_int = {
BPF_ALU32_IMM(BPF_MOV, R0, 0),
BPF_JMP32_IMM(BPF_JEQ, R1, 0, 3),
BPF_ALU64_IMM(BPF_RSH, R1, 32),
BPF_JMP32_IMM(BPF_JNE, R1, 0, 1),
BPF_ALU32_IMM(BPF_MOV, R0, 1),
BPF_EXIT_INSN(),
},
INTERNAL,
{ },
{ { 0, 1 } }
},
#endif
{ {
"check: missing ret", "check: missing ret",
.u.insns = { .u.insns = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment