Commit 82c93fcc authored by Daniel Borkmann's avatar Daniel Borkmann Committed by David S. Miller

x86: 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 x86 JIT parts for the BPF XOR operation.
Signed-off-by: default avatarDaniel Borkmann <daniel.borkmann@tik.ee.ethz.ch>
Acked-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9e49e889
...@@ -335,9 +335,18 @@ void bpf_jit_compile(struct sk_filter *fp) ...@@ -335,9 +335,18 @@ void bpf_jit_compile(struct sk_filter *fp)
EMIT1_off32(0x0d, K); /* or imm32,%eax */ EMIT1_off32(0x0d, K); /* or imm32,%eax */
break; break;
case BPF_S_ANC_ALU_XOR_X: /* A ^= X; */ case BPF_S_ANC_ALU_XOR_X: /* A ^= X; */
case BPF_S_ALU_XOR_X:
seen |= SEEN_XREG; seen |= SEEN_XREG;
EMIT2(0x31, 0xd8); /* xor %ebx,%eax */ EMIT2(0x31, 0xd8); /* xor %ebx,%eax */
break; break;
case BPF_S_ALU_XOR_K: /* A ^= K; */
if (K == 0)
break;
if (is_imm8(K))
EMIT3(0x83, 0xf0, K); /* xor imm8,%eax */
else
EMIT1_off32(0x35, K); /* xor imm32,%eax */
break;
case BPF_S_ALU_LSH_X: /* A <<= X; */ case BPF_S_ALU_LSH_X: /* A <<= X; */
seen |= SEEN_XREG; seen |= SEEN_XREG;
EMIT4(0x89, 0xd9, 0xd3, 0xe0); /* mov %ebx,%ecx; shl %cl,%eax */ EMIT4(0x89, 0xd9, 0xd3, 0xe0); /* mov %ebx,%ecx; shl %cl,%eax */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment