Skip to contentSkip to conversation

ARM: net: JIT compiler for packet filters

PATCH Superseded Mircea Gherzan 2 participants 4 messages Dec 20, 2011 – Dec 28, 2011

Subsystems (5)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ARM: net: JIT compiler for packet filters

Based of Matt Evans's PPC64 implementation.

The compiler generates ARM instructions but interworking is supported for Thumb2 kernels.

Supports both little and big endian. Unaligned loads are emitted for ARMv6+. Not all the BPF opcodes that deal with ancillary data are supported. The scratch memory of the filter lives on the stack. Hardware integer division is used if it is available.

Enabled in the same way as for x86-64 and PPC64:

echo 1 > /proc/sys/net/core/bpf_jit_enable

A value greater than 1 enables opcode output.

---

Changes in v3:
* no longer depend on EABI and !Thumb2
* add BLX "emulation" for ARMv4 without Thumb
* use the integer divide instruction on Cortex-A15
* fix the handling of the DIV_K opcode
* use a C wrapper for __aeabi_uidiv
* fix the generation of the epilogue (non-FP case)

Changes in v2:
* enable the compiler ony for ARMv5+ because of the BLX instruction
* use the same comparison for the ARM version checks
* use misaligned accesses on ARMv6
* fix the SEEN_MEM
* fix the mem_words_used()

 arch/arm/Kconfig          |    1 +
 arch/arm/Makefile         |    1 +
 arch/arm/net/Makefile     |    3 +
 arch/arm/net/bpf_jit_32.c |  876 +++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/net/bpf_jit_32.h |  180 ++++++++++
 5 files changed, 1061 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/net/Makefile
 create mode 100644 arch/arm/net/bpf_jit_32.c
 create mode 100644 arch/arm/net/bpf_jit_32.h
arch/arm/Kconfig +1 -0
index abba5b8..0014b4b 100644
@@ -30,6 +30,7 @@ config ARM
 	select HAVE_SPARSE_IRQ
 	select GENERIC_IRQ_SHOW
 	select CPU_PM if (SUSPEND || CPU_IDLE)
+	select HAVE_BPF_JIT
 	help
 	  The ARM series is a line of low-power-consumption RISC chip designs
 	  licensed by ARM Ltd and targeted at embedded applications and
arch/arm/Makefile +1 -0
index dfcf3b0..8810a10 100644
@@ -255,6 +255,7 @@ core-$(CONFIG_VFP)		+= arch/arm/vfp/
 
 # If we have a machine-specific directory, then include it in the build.
 core-y				+= arch/arm/kernel/ arch/arm/mm/ arch/arm/common/
+core-y				+= arch/arm/net/
 core-y				+= $(machdirs) $(platdirs)
 
 drivers-$(CONFIG_OPROFILE)      += arch/arm/oprofile/
arch/arm/net/Makefile new file +3 -0
new file mode 100644
index 0000000..c2c1084
@@ -0,0 +1,3 @@
+# ARM-specific networking code
+
+obj-$(CONFIG_BPF_JIT) += bpf_jit_32.o
arch/arm/net/bpf_jit_32.c new file +876 -0

876 lines not on this page · raw message

arch/arm/net/bpf_jit_32.h new file +180 -0

180 lines not on this page · raw message

Signature · 1 line
1.7.7.3
maintainer Acked-by on v3 1/1
#1 lore raw

From: Mircea Gherzan <[email protected]>
Date: Tue, 20 Dec 2011 19:04:23 +0100

Quoted 10 lines

Based of Matt Evans's PPC64 implementation.

The compiler generates ARM instructions but interworking is supported for Thumb2 kernels.

Supports both little and big endian. Unaligned loads are emitted for ARMv6+. Not all the BPF opcodes that deal with ancillary data are supported. The scratch memory of the filter lives on the stack. Hardware integer division is used if it is available.

Quoted 7 lines

Enabled in the same way as for x86-64 and PPC64:

echo 1 > /proc/sys/net/core/bpf_jit_enable

A value greater than 1 enables opcode output.

I'm happy with this going in via the ARM tree once all the details are worked out:

#2 lore raw

Am 20.12.2011 19:55, schrieb David Miller:

Quoted 15 lines

From: Mircea Gherzan<[email protected]>
Date: Tue, 20 Dec 2011 19:04:23 +0100

Quoted 12 lines

Based of Matt Evans's PPC64 implementation.

The compiler generates ARM instructions but interworking is supported for Thumb2 kernels.

Supports both little and big endian. Unaligned loads are emitted for ARMv6+. Not all the BPF opcodes that deal with ancillary data are supported. The scratch memory of the filter lives on the stack. Hardware integer division is used if it is available.

Enabled in the same way as for x86-64 and PPC64:

Quoted 8 lines
Quoted 5 lines

echo 1> /proc/sys/net/core/bpf_jit_enable

A value greater than 1 enables opcode output.

I'm happy with this going in via the ARM tree once all the details are worked out:

I do not really care that much about the tree where this is going, as long as it gets into 3.3 :) If you want to take it via the -net tree, please synchronize with Russell (I've uploaded the patch to his tracking system [1]).

Thanks,
Mircea

[1] http://www.arm.linux.org.uk/developer/patche/viewpatch.php?id=7259/1

Quoted 1 line
maintainer Acked-by
#3 lore raw

From: Mircea Gherzan <[email protected]>
Date: Wed, 28 Dec 2011 16:51:34 +0100

Quoted 22 lines

Am 20.12.2011 19:55, schrieb David Miller:

Quoted 21 lines

From: Mircea Gherzan<[email protected]>
Date: Tue, 20 Dec 2011 19:04:23 +0100

Quoted 17 lines

Based of Matt Evans's PPC64 implementation.

The compiler generates ARM instructions but interworking is supported for Thumb2 kernels.

Supports both little and big endian. Unaligned loads are emitted for ARMv6+. Not all the BPF opcodes that deal with ancillary data are supported. The scratch memory of the filter lives on the stack. Hardware integer division is used if it is available.

Enabled in the same way as for x86-64 and PPC64:

echo 1> /proc/sys/net/core/bpf_jit_enable

A value greater than 1 enables opcode output.

Quoted 7 lines
Quoted 2 lines

I'm happy with this going in via the ARM tree once all the details are worked out:

I do not really care that much about the tree where this is going, as long as it gets into 3.3 :) If you want to take it via the -net tree, please synchronize with Russell (I've uploaded the patch to his tracking system [1]).

I think it's much easier if this goes via the ARM tree, so I ask that the ARM folks pull this patch in.

Thanks.