aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_bpf.c
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@plumgrid.com>2014-08-25 15:27:02 -0400
committerDavid S. Miller <davem@davemloft.net>2014-08-25 20:33:56 -0400
commit72b603ee8cfc6be587f301568d79ce38e7ed735d (patch)
tree0e02d3f1fe59b146dcaf2c2c3ef62b424485af72 /lib/test_bpf.c
parent9785820e6dba63a26a3640b3faebcfec6ca286cc (diff)
bpf: x86: add missing 'shift by register' instructions to x64 eBPF JIT
'shift by register' operations are supported by eBPF interpreter, but were accidently left out of x64 JIT compiler. Fix it and add a testcase. Reported-by: Brendan Gregg <brendan.d.gregg@gmail.com> Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Fixes: 622582786c9e ("net: filter: x86: internal BPF JIT") Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/test_bpf.c')
-rw-r--r--lib/test_bpf.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/test_bpf.c b/lib/test_bpf.c
index 89e0345733bd..8c66c6aace04 100644
--- a/lib/test_bpf.c
+++ b/lib/test_bpf.c
@@ -1342,6 +1342,44 @@ static struct bpf_test tests[] = {
1342 { { 0, -1 } } 1342 { { 0, -1 } }
1343 }, 1343 },
1344 { 1344 {
1345 "INT: shifts by register",
1346 .u.insns_int = {
1347 BPF_MOV64_IMM(R0, -1234),
1348 BPF_MOV64_IMM(R1, 1),
1349 BPF_ALU32_REG(BPF_RSH, R0, R1),
1350 BPF_JMP_IMM(BPF_JEQ, R0, 0x7ffffd97, 1),
1351 BPF_EXIT_INSN(),
1352 BPF_MOV64_IMM(R2, 1),
1353 BPF_ALU64_REG(BPF_LSH, R0, R2),
1354 BPF_MOV32_IMM(R4, -1234),
1355 BPF_JMP_REG(BPF_JEQ, R0, R4, 1),
1356 BPF_EXIT_INSN(),
1357 BPF_ALU64_IMM(BPF_AND, R4, 63),
1358 BPF_ALU64_REG(BPF_LSH, R0, R4), /* R0 <= 46 */
1359 BPF_MOV64_IMM(R3, 47),
1360 BPF_ALU64_REG(BPF_ARSH, R0, R3),
1361 BPF_JMP_IMM(BPF_JEQ, R0, -617, 1),
1362 BPF_EXIT_INSN(),
1363 BPF_MOV64_IMM(R2, 1),
1364 BPF_ALU64_REG(BPF_LSH, R4, R2), /* R4 = 46 << 1 */
1365 BPF_JMP_IMM(BPF_JEQ, R4, 92, 1),
1366 BPF_EXIT_INSN(),
1367 BPF_MOV64_IMM(R4, 4),
1368 BPF_ALU64_REG(BPF_LSH, R4, R4), /* R4 = 4 << 4 */
1369 BPF_JMP_IMM(BPF_JEQ, R4, 64, 1),
1370 BPF_EXIT_INSN(),
1371 BPF_MOV64_IMM(R4, 5),
1372 BPF_ALU32_REG(BPF_LSH, R4, R4), /* R4 = 5 << 5 */
1373 BPF_JMP_IMM(BPF_JEQ, R4, 160, 1),
1374 BPF_EXIT_INSN(),
1375 BPF_MOV64_IMM(R0, -1),
1376 BPF_EXIT_INSN(),
1377 },
1378 INTERNAL,
1379 { },
1380 { { 0, -1 } }
1381 },
1382 {
1345 "INT: DIV + ABS", 1383 "INT: DIV + ABS",
1346 .u.insns_int = { 1384 .u.insns_int = {
1347 BPF_ALU64_REG(BPF_MOV, R6, R1), 1385 BPF_ALU64_REG(BPF_MOV, R6, R1),