selftests/bpf: add "any alignment" annotation for some tests
authorBjörn Töpel <bjorn.topel@gmail.com>
Tue, 5 Feb 2019 12:41:25 +0000 (13:41 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 5 Feb 2019 15:56:10 +0000 (16:56 +0100)
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: Björn Töpel <bjorn.topel@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/verifier/ctx_sk_msg.c
tools/testing/selftests/bpf/verifier/ctx_skb.c
tools/testing/selftests/bpf/verifier/jmp32.c
tools/testing/selftests/bpf/verifier/jset.c
tools/testing/selftests/bpf/verifier/spill_fill.c
tools/testing/selftests/bpf/verifier/spin_lock.c
tools/testing/selftests/bpf/verifier/value_ptr_arith.c

index b019577..c6c6922 100644 (file)
        .errstr = "invalid bpf_context access",
        .result = REJECT,
        .prog_type = BPF_PROG_TYPE_SK_MSG,
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "invalid read past end of SK_MSG",
index 881f1c7..c660deb 100644 (file)
        },
        .errstr = "invalid bpf_context access",
        .result = REJECT,
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "check skb->hash half load not permitted, unaligned 3",
index ceb39ff..f0961c5 100644 (file)
@@ -27,6 +27,7 @@
                  .data64 = { 1ULL << 63 | 1, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jset32: BPF_X",
@@ -58,6 +59,7 @@
                  .data64 = { 1ULL << 63 | 1, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jset32: min/max deduction",
@@ -93,6 +95,7 @@
                  .data64 = { -1, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jeq32: BPF_X",
                  .data64 = { 1ULL << 63 | 1, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jeq32: min/max deduction",
                  .data64 = { -1, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jne32: BPF_X",
                  .data64 = { 1ULL << 63 | 2, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jne32: min/max deduction",
                  .data64 = { 0, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jge32: BPF_X",
                  .data64 = { (UINT_MAX - 1) | 2ULL << 32, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jge32: min/max deduction",
                  .data64 = { 0, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jgt32: BPF_X",
                  .data64 = { (UINT_MAX - 1) | 2ULL << 32, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jgt32: min/max deduction",
                  .data64 = { INT_MAX, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jle32: BPF_X",
                  .data64 = { UINT_MAX, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jle32: min/max deduction",
                  .data64 = { INT_MAX - 1, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jlt32: BPF_X",
                  .data64 = { (INT_MAX - 1) | 3ULL << 32, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jlt32: min/max deduction",
                  .data64 = { -2, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jsge32: BPF_X",
                  .data64 = { -2, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jsge32: min/max deduction",
                  .data64 = { 1, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jsgt32: BPF_X",
                  .data64 = { 0x7fffffff, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jsgt32: min/max deduction",
                  .data64 = { 1, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jsle32: BPF_X",
                  .data64 = { 0x7fffffff | 2ULL << 32, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jsle32: min/max deduction",
                  .data64 = { 1, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jslt32: BPF_X",
                  .data64 = { 0x7fffffff | 2ULL << 32, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jslt32: min/max deduction",
index 7e14037..8dcd4e0 100644 (file)
@@ -53,6 +53,7 @@
                  .data64 = { ~0ULL, }
                },
        },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jset: sign-extend",
@@ -70,6 +71,7 @@
        .result = ACCEPT,
        .retval = 2,
        .data = { 1, 0, 0, 0, 0, 0, 0, 1, },
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "jset: known const compare",
index d58db72..45d43bf 100644 (file)
@@ -46,6 +46,7 @@
        .errstr_unpriv = "attempt to corrupt spilled",
        .errstr = "R0 invalid mem access 'inv",
        .result = REJECT,
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "check corrupted spill/fill, LSB",
index d829eef..781621f 100644 (file)
@@ -83,6 +83,7 @@
        .result_unpriv = REJECT,
        .errstr_unpriv = "",
        .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "spin_lock: test4 direct ld/st",
        .result_unpriv = REJECT,
        .errstr_unpriv = "",
        .prog_type = BPF_PROG_TYPE_CGROUP_SKB,
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "spin_lock: test5 call within a locked region",
index 9ab5ace..4b721a7 100644 (file)
        .fixup_map_array_48b = { 3 },
        .result = ACCEPT,
        .retval = 0xabcdef12,
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "map access: unknown scalar += value_ptr, 3",
        .result_unpriv = REJECT,
        .errstr_unpriv = "R0 pointer arithmetic of map value goes out of range",
        .retval = 0xabcdef12,
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "map access: unknown scalar += value_ptr, 4",
        .result = REJECT,
        .errstr = "R1 max value is outside of the array 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",
        .fixup_map_array_48b = { 3 },
        .result = ACCEPT,
        .retval = 0xabcdef12,
+       .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS,
 },
 {
        "map access: value_ptr += unknown scalar, 3",