Commit e2c6f50e authored by Björn Töpel's avatar Björn Töpel Committed by Daniel Borkmann

selftests/bpf: add "any alignment" annotation for some tests

RISC-V does, in-general, not have "efficient unaligned access". When
testing the RISC-V BPF JIT, some selftests failed in the verification
due to misaligned access. Annotate these tests with the
F_NEEDS_EFFICIENT_UNALIGNED_ACCESS flag.
Signed-off-by: default avatarBjörn Töpel <bjorn.topel@gmail.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent e8cb0167
...@@ -100,6 +100,7 @@ ...@@ -100,6 +100,7 @@
.errstr = "invalid bpf_context access", .errstr = "invalid bpf_context access",
.result = REJECT, .result = REJECT,
.prog_type = BPF_PROG_TYPE_SK_MSG, .prog_type = BPF_PROG_TYPE_SK_MSG,
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"invalid read past end of SK_MSG", "invalid read past end of SK_MSG",
......
...@@ -687,6 +687,7 @@ ...@@ -687,6 +687,7 @@
}, },
.errstr = "invalid bpf_context access", .errstr = "invalid bpf_context access",
.result = REJECT, .result = REJECT,
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"check skb->hash half load not permitted, unaligned 3", "check skb->hash half load not permitted, unaligned 3",
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
.data64 = { 1ULL << 63 | 1, } .data64 = { 1ULL << 63 | 1, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jset32: BPF_X", "jset32: BPF_X",
...@@ -58,6 +59,7 @@ ...@@ -58,6 +59,7 @@
.data64 = { 1ULL << 63 | 1, } .data64 = { 1ULL << 63 | 1, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jset32: min/max deduction", "jset32: min/max deduction",
...@@ -93,6 +95,7 @@ ...@@ -93,6 +95,7 @@
.data64 = { -1, } .data64 = { -1, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jeq32: BPF_X", "jeq32: BPF_X",
...@@ -119,6 +122,7 @@ ...@@ -119,6 +122,7 @@
.data64 = { 1ULL << 63 | 1, } .data64 = { 1ULL << 63 | 1, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jeq32: min/max deduction", "jeq32: min/max deduction",
...@@ -154,6 +158,7 @@ ...@@ -154,6 +158,7 @@
.data64 = { -1, } .data64 = { -1, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jne32: BPF_X", "jne32: BPF_X",
...@@ -180,6 +185,7 @@ ...@@ -180,6 +185,7 @@
.data64 = { 1ULL << 63 | 2, } .data64 = { 1ULL << 63 | 2, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jne32: min/max deduction", "jne32: min/max deduction",
...@@ -218,6 +224,7 @@ ...@@ -218,6 +224,7 @@
.data64 = { 0, } .data64 = { 0, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jge32: BPF_X", "jge32: BPF_X",
...@@ -244,6 +251,7 @@ ...@@ -244,6 +251,7 @@
.data64 = { (UINT_MAX - 1) | 2ULL << 32, } .data64 = { (UINT_MAX - 1) | 2ULL << 32, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jge32: min/max deduction", "jge32: min/max deduction",
...@@ -284,6 +292,7 @@ ...@@ -284,6 +292,7 @@
.data64 = { 0, } .data64 = { 0, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jgt32: BPF_X", "jgt32: BPF_X",
...@@ -310,6 +319,7 @@ ...@@ -310,6 +319,7 @@
.data64 = { (UINT_MAX - 1) | 2ULL << 32, } .data64 = { (UINT_MAX - 1) | 2ULL << 32, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jgt32: min/max deduction", "jgt32: min/max deduction",
...@@ -350,6 +360,7 @@ ...@@ -350,6 +360,7 @@
.data64 = { INT_MAX, } .data64 = { INT_MAX, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jle32: BPF_X", "jle32: BPF_X",
...@@ -376,6 +387,7 @@ ...@@ -376,6 +387,7 @@
.data64 = { UINT_MAX, } .data64 = { UINT_MAX, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jle32: min/max deduction", "jle32: min/max deduction",
...@@ -416,6 +428,7 @@ ...@@ -416,6 +428,7 @@
.data64 = { INT_MAX - 1, } .data64 = { INT_MAX - 1, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jlt32: BPF_X", "jlt32: BPF_X",
...@@ -442,6 +455,7 @@ ...@@ -442,6 +455,7 @@
.data64 = { (INT_MAX - 1) | 3ULL << 32, } .data64 = { (INT_MAX - 1) | 3ULL << 32, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jlt32: min/max deduction", "jlt32: min/max deduction",
...@@ -482,6 +496,7 @@ ...@@ -482,6 +496,7 @@
.data64 = { -2, } .data64 = { -2, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jsge32: BPF_X", "jsge32: BPF_X",
...@@ -508,6 +523,7 @@ ...@@ -508,6 +523,7 @@
.data64 = { -2, } .data64 = { -2, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jsge32: min/max deduction", "jsge32: min/max deduction",
...@@ -548,6 +564,7 @@ ...@@ -548,6 +564,7 @@
.data64 = { 1, } .data64 = { 1, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jsgt32: BPF_X", "jsgt32: BPF_X",
...@@ -574,6 +591,7 @@ ...@@ -574,6 +591,7 @@
.data64 = { 0x7fffffff, } .data64 = { 0x7fffffff, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jsgt32: min/max deduction", "jsgt32: min/max deduction",
...@@ -614,6 +632,7 @@ ...@@ -614,6 +632,7 @@
.data64 = { 1, } .data64 = { 1, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jsle32: BPF_X", "jsle32: BPF_X",
...@@ -640,6 +659,7 @@ ...@@ -640,6 +659,7 @@
.data64 = { 0x7fffffff | 2ULL << 32, } .data64 = { 0x7fffffff | 2ULL << 32, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jsle32: min/max deduction", "jsle32: min/max deduction",
...@@ -680,6 +700,7 @@ ...@@ -680,6 +700,7 @@
.data64 = { 1, } .data64 = { 1, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jslt32: BPF_X", "jslt32: BPF_X",
...@@ -706,6 +727,7 @@ ...@@ -706,6 +727,7 @@
.data64 = { 0x7fffffff | 2ULL << 32, } .data64 = { 0x7fffffff | 2ULL << 32, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jslt32: min/max deduction", "jslt32: min/max deduction",
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
.data64 = { ~0ULL, } .data64 = { ~0ULL, }
}, },
}, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jset: sign-extend", "jset: sign-extend",
...@@ -70,6 +71,7 @@ ...@@ -70,6 +71,7 @@
.result = ACCEPT, .result = ACCEPT,
.retval = 2, .retval = 2,
.data = { 1, 0, 0, 0, 0, 0, 0, 1, }, .data = { 1, 0, 0, 0, 0, 0, 0, 1, },
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"jset: known const compare", "jset: known const compare",
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
.errstr_unpriv = "attempt to corrupt spilled", .errstr_unpriv = "attempt to corrupt spilled",
.errstr = "R0 invalid mem access 'inv", .errstr = "R0 invalid mem access 'inv",
.result = REJECT, .result = REJECT,
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"check corrupted spill/fill, LSB", "check corrupted spill/fill, LSB",
......
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
.result_unpriv = REJECT, .result_unpriv = REJECT,
.errstr_unpriv = "", .errstr_unpriv = "",
.prog_type = BPF_PROG_TYPE_CGROUP_SKB, .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"spin_lock: test4 direct ld/st", "spin_lock: test4 direct ld/st",
...@@ -112,6 +113,7 @@ ...@@ -112,6 +113,7 @@
.result_unpriv = REJECT, .result_unpriv = REJECT,
.errstr_unpriv = "", .errstr_unpriv = "",
.prog_type = BPF_PROG_TYPE_CGROUP_SKB, .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"spin_lock: test5 call within a locked region", "spin_lock: test5 call within a locked region",
......
...@@ -512,6 +512,7 @@ ...@@ -512,6 +512,7 @@
.fixup_map_array_48b = { 3 }, .fixup_map_array_48b = { 3 },
.result = ACCEPT, .result = ACCEPT,
.retval = 0xabcdef12, .retval = 0xabcdef12,
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"map access: unknown scalar += value_ptr, 3", "map access: unknown scalar += value_ptr, 3",
...@@ -537,6 +538,7 @@ ...@@ -537,6 +538,7 @@
.result_unpriv = REJECT, .result_unpriv = REJECT,
.errstr_unpriv = "R0 pointer arithmetic of map value goes out of range", .errstr_unpriv = "R0 pointer arithmetic of map value goes out of range",
.retval = 0xabcdef12, .retval = 0xabcdef12,
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"map access: unknown scalar += value_ptr, 4", "map access: unknown scalar += value_ptr, 4",
...@@ -559,6 +561,7 @@ ...@@ -559,6 +561,7 @@
.result = REJECT, .result = REJECT,
.errstr = "R1 max value is outside of the array range", .errstr = "R1 max value is outside of the array range",
.errstr_unpriv = "R1 pointer arithmetic of map value goes out of range", .errstr_unpriv = "R1 pointer arithmetic of map value goes out of range",
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"map access: value_ptr += unknown scalar, 1", "map access: value_ptr += unknown scalar, 1",
...@@ -598,6 +601,7 @@ ...@@ -598,6 +601,7 @@
.fixup_map_array_48b = { 3 }, .fixup_map_array_48b = { 3 },
.result = ACCEPT, .result = ACCEPT,
.retval = 0xabcdef12, .retval = 0xabcdef12,
.flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
}, },
{ {
"map access: value_ptr += unknown scalar, 3", "map access: value_ptr += unknown scalar, 3",
......
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