Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PPC: net: bpf_jit_comp: 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 PowerPC JIT parts for the BPF XOR operation.

Signed-off-by: Daniel Borkmann <daniel.borkmann@tik.ee.ethz.ch>
Cc: Matt Evans <matt@ozlabs.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Daniel Borkmann and committed by
David S. Miller
02871903 18d359ce

+20
+3
arch/powerpc/include/asm/ppc-opcode.h
··· 168 168 #define PPC_INST_AND 0x7c000038 169 169 #define PPC_INST_ANDDOT 0x7c000039 170 170 #define PPC_INST_OR 0x7c000378 171 + #define PPC_INST_XOR 0x7c000278 171 172 #define PPC_INST_ANDI 0x70000000 172 173 #define PPC_INST_ORI 0x60000000 173 174 #define PPC_INST_ORIS 0x64000000 175 + #define PPC_INST_XORI 0x68000000 176 + #define PPC_INST_XORIS 0x6c000000 174 177 #define PPC_INST_NEG 0x7c0000d0 175 178 #define PPC_INST_BRANCH 0x48000000 176 179 #define PPC_INST_BRANCH_COND 0x40800000
+6
arch/powerpc/net/bpf_jit.h
··· 134 134 ___PPC_RS(a) | IMM_L(i)) 135 135 #define PPC_ORIS(d, a, i) EMIT(PPC_INST_ORIS | ___PPC_RA(d) | \ 136 136 ___PPC_RS(a) | IMM_L(i)) 137 + #define PPC_XOR(d, a, b) EMIT(PPC_INST_XOR | ___PPC_RA(d) | \ 138 + ___PPC_RS(a) | ___PPC_RB(b)) 139 + #define PPC_XORI(d, a, i) EMIT(PPC_INST_XORI | ___PPC_RA(d) | \ 140 + ___PPC_RS(a) | IMM_L(i)) 141 + #define PPC_XORIS(d, a, i) EMIT(PPC_INST_XORIS | ___PPC_RA(d) | \ 142 + ___PPC_RS(a) | IMM_L(i)) 137 143 #define PPC_SLW(d, a, s) EMIT(PPC_INST_SLW | ___PPC_RA(d) | \ 138 144 ___PPC_RS(a) | ___PPC_RB(s)) 139 145 #define PPC_SRW(d, a, s) EMIT(PPC_INST_SRW | ___PPC_RA(d) | \
+11
arch/powerpc/net/bpf_jit_comp.c
··· 232 232 if (K >= 65536) 233 233 PPC_ORIS(r_A, r_A, IMM_H(K)); 234 234 break; 235 + case BPF_S_ANC_ALU_XOR_X: 236 + case BPF_S_ALU_XOR_X: /* A ^= X */ 237 + ctx->seen |= SEEN_XREG; 238 + PPC_XOR(r_A, r_A, r_X); 239 + break; 240 + case BPF_S_ALU_XOR_K: /* A ^= K */ 241 + if (IMM_L(K)) 242 + PPC_XORI(r_A, r_A, IMM_L(K)); 243 + if (K >= 65536) 244 + PPC_XORIS(r_A, r_A, IMM_H(K)); 245 + break; 235 246 case BPF_S_ALU_LSH_X: /* A <<= X; */ 236 247 ctx->seen |= SEEN_XREG; 237 248 PPC_SLW(r_A, r_A, r_X);