diff options
author | Daniel Borkmann <dxchgb@gmail.com> | 2012-11-08 06:39:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-17 22:12:47 -0500 |
commit | 02871903a1fcdf306a906c38566ca0d48a45a431 (patch) | |
tree | ed61bd5960d1eded043f1d1e6cf73995e06d83b9 /arch | |
parent | 18d359ceb04485df0e387e04b0e52a761c4c58a0 (diff) |
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/include/asm/ppc-opcode.h | 3 | ||||
-rw-r--r-- | arch/powerpc/net/bpf_jit.h | 6 | ||||
-rw-r--r-- | arch/powerpc/net/bpf_jit_comp.c | 11 |
3 files changed, 20 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h index 5f73ce63fcae..42b1f43b943b 100644 --- a/arch/powerpc/include/asm/ppc-opcode.h +++ b/arch/powerpc/include/asm/ppc-opcode.h | |||
@@ -168,9 +168,12 @@ | |||
168 | #define PPC_INST_AND 0x7c000038 | 168 | #define PPC_INST_AND 0x7c000038 |
169 | #define PPC_INST_ANDDOT 0x7c000039 | 169 | #define PPC_INST_ANDDOT 0x7c000039 |
170 | #define PPC_INST_OR 0x7c000378 | 170 | #define PPC_INST_OR 0x7c000378 |
171 | #define PPC_INST_XOR 0x7c000278 | ||
171 | #define PPC_INST_ANDI 0x70000000 | 172 | #define PPC_INST_ANDI 0x70000000 |
172 | #define PPC_INST_ORI 0x60000000 | 173 | #define PPC_INST_ORI 0x60000000 |
173 | #define PPC_INST_ORIS 0x64000000 | 174 | #define PPC_INST_ORIS 0x64000000 |
175 | #define PPC_INST_XORI 0x68000000 | ||
176 | #define PPC_INST_XORIS 0x6c000000 | ||
174 | #define PPC_INST_NEG 0x7c0000d0 | 177 | #define PPC_INST_NEG 0x7c0000d0 |
175 | #define PPC_INST_BRANCH 0x48000000 | 178 | #define PPC_INST_BRANCH 0x48000000 |
176 | #define PPC_INST_BRANCH_COND 0x40800000 | 179 | #define PPC_INST_BRANCH_COND 0x40800000 |
diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h index 1fc8109bf2f9..8a5dfaf5c6b7 100644 --- a/arch/powerpc/net/bpf_jit.h +++ b/arch/powerpc/net/bpf_jit.h | |||
@@ -134,6 +134,12 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh); | |||
134 | ___PPC_RS(a) | IMM_L(i)) | 134 | ___PPC_RS(a) | IMM_L(i)) |
135 | #define PPC_ORIS(d, a, i) EMIT(PPC_INST_ORIS | ___PPC_RA(d) | \ | 135 | #define PPC_ORIS(d, a, i) EMIT(PPC_INST_ORIS | ___PPC_RA(d) | \ |
136 | ___PPC_RS(a) | IMM_L(i)) | 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 | #define PPC_SLW(d, a, s) EMIT(PPC_INST_SLW | ___PPC_RA(d) | \ | 143 | #define PPC_SLW(d, a, s) EMIT(PPC_INST_SLW | ___PPC_RA(d) | \ |
138 | ___PPC_RS(a) | ___PPC_RB(s)) | 144 | ___PPC_RS(a) | ___PPC_RB(s)) |
139 | #define PPC_SRW(d, a, s) EMIT(PPC_INST_SRW | ___PPC_RA(d) | \ | 145 | #define PPC_SRW(d, a, s) EMIT(PPC_INST_SRW | ___PPC_RA(d) | \ |
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c index dd1130642d07..b9434de8222b 100644 --- a/arch/powerpc/net/bpf_jit_comp.c +++ b/arch/powerpc/net/bpf_jit_comp.c | |||
@@ -232,6 +232,17 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image, | |||
232 | if (K >= 65536) | 232 | if (K >= 65536) |
233 | PPC_ORIS(r_A, r_A, IMM_H(K)); | 233 | PPC_ORIS(r_A, r_A, IMM_H(K)); |
234 | break; | 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 | case BPF_S_ALU_LSH_X: /* A <<= X; */ | 246 | case BPF_S_ALU_LSH_X: /* A <<= X; */ |
236 | ctx->seen |= SEEN_XREG; | 247 | ctx->seen |= SEEN_XREG; |
237 | PPC_SLW(r_A, r_A, r_X); | 248 | PPC_SLW(r_A, r_A, r_X); |