Skip to contentSkip to conversation

m68k, bpf: Add initial BPF JIT compiler support

PATCH Superseded Kuan-Wei Chiu 1 participant 1 message Jun 12

Subsystems (2)

v4 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 m68k, bpf: Add initial BPF JIT compiler support

Add a BPF JIT compiler for the m68k architecture.

The JIT generates m68k machine code targeting m68020+ processors. It currently excludes 68000/68010 and coldfire processors, as it relies on 32 bit branch displacements (b<cc>.l) to handle large bpf programs.

Tested with the test_bpf.ko:
test_bpf: Summary: 1053 PASSED, 0 FAILED, [1041/1041 JIT'ed]
test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]

---
Changes in v4:
- Fix bpf2bpf call
- Fix LLONG_MIN / -1 edge case
- Change kcalloc() -> kvcalloc()
- Optimize code generation for signed extension

 MAINTAINERS                  |    6 +
 arch/m68k/Kbuild             |    2 +-
 arch/m68k/Kconfig            |    1 +
 arch/m68k/net/Makefile       |    2 +
 arch/m68k/net/bpf_jit_comp.c | 1630 ++++++++++++++++++++++++++++++++++
 5 files changed, 1640 insertions(+), 1 deletion(-)
 create mode 100644 arch/m68k/net/Makefile
 create mode 100644 arch/m68k/net/bpf_jit_comp.c
MAINTAINERS +6 -0
index 2fb1c75afd16..530551834c16 100644
@@ -4701,6 +4701,12 @@ L:	[email protected]
 S:	Maintained
 F:	arch/loongarch/net/
 
+BPF JIT for M68K
+M:	Kuan-Wei Chiu <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	arch/m68k/net/
+
 BPF JIT for MIPS (32-BIT AND 64-BIT)
 M:	Johan Almbladh <[email protected]>
 M:	Paul Burton <[email protected]>
arch/m68k/Kbuild +1 -1
index 7762af9f6def..058ad41a728c 100644
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-only
-obj-y				+= kernel/ mm/
+obj-y				+= kernel/ mm/ net/
 obj-$(CONFIG_Q40)		+= q40/
 obj-$(CONFIG_AMIGA)		+= amiga/
 obj-$(CONFIG_ATARI)		+= atari/
arch/m68k/Kconfig +1 -0
index 11835eb59d94..da43d6660c5c 100644
@@ -8,6 +8,7 @@ config M68K
 	select ARCH_HAS_CPU_FINALIZE_INIT if MMU
 	select ARCH_HAS_CURRENT_STACK_POINTER
 	select ARCH_HAS_DMA_PREP_COHERENT if M68K_NONCOHERENT_DMA && !COLDFIRE
+	select HAVE_EBPF_JIT if (!COLDFIRE && !M68000)
 	select ARCH_HAS_SYNC_DMA_FOR_DEVICE if M68K_NONCOHERENT_DMA
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG if RMW_INSNS
 	select ARCH_MIGHT_HAVE_PC_PARPORT if ISA
arch/m68k/net/Makefile new file +2 -0
new file mode 100644
index 000000000000..ec5b14763316
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+obj-$(CONFIG_BPF_JIT) += bpf_jit_comp.o
arch/m68k/net/bpf_jit_comp.c new file +1630 -0

1,630 lines not on this page · raw message

Signature · 1 line
2.54.0.1136.gdb2ca164c4-goog