test_bpf: extend tests for 32-bit endianness conversion
authorXi Wang <xi.wang@gmail.com>
Wed, 8 Jul 2015 21:00:56 +0000 (14:00 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Jul 2015 23:19:53 +0000 (16:19 -0700)
Currently "ALU_END_FROM_BE 32" and "ALU_END_FROM_LE 32" do not test if
the upper bits of the result are zeros (the arm64 JIT had such bugs).
Extend the two tests to catch this.

Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/test_bpf.c

index 7f58c735d745049025407806e972bb4c7f124888..9198f28a5528f2a27158e2ac67c5b06a44949c2e 100644 (file)
@@ -3674,6 +3674,9 @@ static struct bpf_test tests[] = {
                .u.insns_int = {
                        BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
                        BPF_ENDIAN(BPF_FROM_BE, R0, 32),
+                       BPF_ALU64_REG(BPF_MOV, R1, R0),
+                       BPF_ALU64_IMM(BPF_RSH, R1, 32),
+                       BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */
                        BPF_EXIT_INSN(),
                },
                INTERNAL,
@@ -3708,6 +3711,9 @@ static struct bpf_test tests[] = {
                .u.insns_int = {
                        BPF_LD_IMM64(R0, 0x0123456789abcdefLL),
                        BPF_ENDIAN(BPF_FROM_LE, R0, 32),
+                       BPF_ALU64_REG(BPF_MOV, R1, R0),
+                       BPF_ALU64_IMM(BPF_RSH, R1, 32),
+                       BPF_ALU32_REG(BPF_ADD, R0, R1), /* R1 = 0 */
                        BPF_EXIT_INSN(),
                },
                INTERNAL,