Skip to content

Commit 3cbe204

Browse files
Daniel Borkmanndavem330
authored andcommitted
ARM: net: bpf_jit_32: add XOR instruction for BPF JIT
This patch is a follow-up for patch "filter: add XOR instruction for use with X/K" that implements BPF ARM JIT parts for the BPF XOR operation. Signed-off-by: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch> Cc: Mircea Gherzan <mgherzan@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de> Acked-by: Mircea Gherzan <mgherzan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 910cc72 commit 3cbe204

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

‎arch/arm/net/bpf_jit_32.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,16 @@ static int build_body(struct jit_ctx *ctx)
646646
update_on_xread(ctx);
647647
emit(ARM_ORR_R(r_A, r_A, r_X), ctx);
648648
break;
649+
case BPF_S_ALU_XOR_K:
650+
/* A ^= K; */
651+
OP_IMM3(ARM_EOR, r_A, r_A, k, ctx);
652+
break;
653+
case BPF_S_ANC_ALU_XOR_X:
654+
case BPF_S_ALU_XOR_X:
655+
/* A ^= X */
656+
update_on_xread(ctx);
657+
emit(ARM_EOR_R(r_A, r_A, r_X), ctx);
658+
break;
649659
case BPF_S_ALU_AND_K:
650660
/* A &= K */
651661
OP_IMM3(ARM_AND, r_A, r_A, k, ctx);
@@ -762,11 +772,6 @@ static int build_body(struct jit_ctx *ctx)
762772
update_on_xread(ctx);
763773
emit(ARM_MOV_R(r_A, r_X), ctx);
764774
break;
765-
case BPF_S_ANC_ALU_XOR_X:
766-
/* A ^= X */
767-
update_on_xread(ctx);
768-
emit(ARM_EOR_R(r_A, r_A, r_X), ctx);
769-
break;
770775
case BPF_S_ANC_PROTOCOL:
771776
/* A = ntohs(skb->protocol) */
772777
ctx->seen |= SEEN_SKB;

‎arch/arm/net/bpf_jit_32.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#define ARM_INST_CMP_I 0x03500000
7070

7171
#define ARM_INST_EOR_R 0x00200000
72+
#define ARM_INST_EOR_I 0x02200000
7273

7374
#define ARM_INST_LDRB_I 0x05d00000
7475
#define ARM_INST_LDRB_R 0x07d00000
@@ -135,6 +136,7 @@
135136
#define ARM_CMP_I(rn, imm) _AL3_I(ARM_INST_CMP, 0, rn, imm)
136137

137138
#define ARM_EOR_R(rd, rn, rm) _AL3_R(ARM_INST_EOR, rd, rn, rm)
139+
#define ARM_EOR_I(rd, rn, imm) _AL3_I(ARM_INST_EOR, rd, rn, imm)
138140

139141
#define ARM_LDR_I(rt, rn, off) (ARM_INST_LDR_I | (rt) << 12 | (rn) << 16 \
140142
| (off))

0 commit comments

Comments
 (0)