Skip to contentSkip to conversation

x86: bpf_jit_comp: add XOR instruction for BPF JIT

PATCH Applied Daniel Borkmann 3 participants 3 messages Sep 24, 2012

Subsystems (5)
Networking Network drivers x86 BPF +1 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 arch/x86/net/bpf_jit_comp.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
arch/x86/net/bpf_jit_comp.c +9 -0
index 106c578..520d2bd 100644
@@ -335,9 +335,18 @@ void bpf_jit_compile(struct sk_filter *fp)
 					EMIT1_off32(0x0d, K);	/* or imm32,%eax */
 				break;
 			case BPF_S_ANC_ALU_XOR_X: /* A ^= X; */
+			case BPF_S_ALU_XOR_X:
 				seen |= SEEN_XREG;
 				EMIT2(0x31, 0xd8);		/* xor %ebx,%eax */
 				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; */
 				seen |= SEEN_XREG;
 				EMIT4(0x89, 0xd9, 0xd3, 0xe0);	/* mov %ebx,%ecx; shl %cl,%eax */
maintainer Applied
#2 lore raw

From: Eric Dumazet <[email protected]>
Date: Mon, 24 Sep 2012 19:44:07 +0200

Quoted 10 lines · Daniel Borkmann
Quoted 7 lines

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.

---
 arch/x86/net/bpf_jit_comp.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

Applied, thanks everyone.