[PATCH v7] ARM: net: JIT compiler for packet filters

STALE5264d

3 messages, 2 authors, 2012-03-15 · open the first message on its own page

[PATCH v7] ARM: net: JIT compiler for packet filters

From: Mircea Gherzan <hidden>
Date: 2012-02-13 15:36:29

Hi,

Am 07.01.2012 12:52, schrieb Mircea Gherzan:
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.

Signed-off-by: Mircea Gherzan <redacted>
---

Changes in v7:
 * fix the intruction generation for LDX_MSH, OR_X, LSH_K,
   RSH_K and JMP_JA
 * fix the condition for saving the A register
 * use fls() instead of the compiler builtin
 * punt to the interpreter on absolute loads with K < 0
 * check for invalid data references
 * support the NEG opcode
 * clear X in the prologue based on a context flag
 * simplify the conditional jumps

Changes in v6:
 * fix the code generation for the ANC_CPU opcode

Changes in v5:
 * replace SEEN_LEN with SEEN_SKB
 * set ctx->seen when handling some ancillary data opcodes

Changes in v4:
 * first check if the JIT compiler is enabled
 * fix the code generation for the LDX_MSH opcode

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 only 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 |  912 +++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/net/bpf_jit_32.h |  190 ++++++++++
 5 files changed, 1107 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
Gentle ping. This patch has been in the tracking system for over a
month. Is there any reason not to apply it in arm/for-next?

Thanks,
Mircea

[PATCH v7] ARM: net: JIT compiler for packet filters

From: Russell King - ARM Linux <hidden>
Date: 2012-02-13 16:02:49

On Mon, Feb 13, 2012 at 04:36:29PM +0100, Mircea Gherzan wrote:
Gentle ping. This patch has been in the tracking system for over a
month. Is there any reason not to apply it in arm/for-next?
Yes.  It needs quite a review to make sure that there's absolutely no
possibility for userspace to be able to generate malicious ARM code
and then have it executed.  Or put it another way: security paranoia.

I'm afraid that I've not been able to look at it at all yet, and I
haven't seen anyone looking at the code from that aspect.

[PATCH v7] ARM: net: JIT compiler for packet filters

From: Mircea Gherzan <hidden>
Date: 2012-03-15 07:23:43

Am 13.02.2012 17:02, schrieb Russell King - ARM Linux:
On Mon, Feb 13, 2012 at 04:36:29PM +0100, Mircea Gherzan wrote:
quoted
Gentle ping. This patch has been in the tracking system for over a
month. Is there any reason not to apply it in arm/for-next?
Yes.  It needs quite a review to make sure that there's absolutely no
possibility for userspace to be able to generate malicious ARM code
and then have it executed.  Or put it another way: security paranoia.
Are there any specific security aspects you're thinking of? Leaks to
userspace, divisions by zero and invalid packet offsets are already
taken care of.
I'm afraid that I've not been able to look at it at all yet, and I
haven't seen anyone looking at the code from that aspect.
Thanks,
Mircea
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help