mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	bpf, riscv: add BPF JIT for RV64G
This commit adds a BPF JIT for RV64G. The JIT is a two-pass JIT, and has a dynamic prolog/epilogue (similar to the MIPS64 BPF JIT) instead of static ones (e.g. x86_64). At the moment the RISC-V Linux port does not support CONFIG_HAVE_KPROBES, which means that CONFIG_BPF_EVENTS is not supported. Thus, no tests involving BPF_PROG_TYPE_TRACEPOINT, BPF_PROG_TYPE_PERF_EVENT, BPF_PROG_TYPE_KPROBE and BPF_PROG_TYPE_RAW_TRACEPOINT passes. The implementation does not support "far branching" (>4KiB). Test results: # modprobe test_bpf test_bpf: Summary: 378 PASSED, 0 FAILED, [366/366 JIT'ed] # echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled # ./test_verifier ... Summary: 761 PASSED, 507 SKIPPED, 2 FAILED Note that "test_verifier" was run with one build with CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y and one without, otherwise many of the the tests that require unaligned access were skipped. CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS=y: # echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled # ./test_verifier | grep -c 'NOTE.*unknown align' 0 No CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS: # echo 1 > /proc/sys/kernel/unprivileged_bpf_disabled # ./test_verifier | grep -c 'NOTE.*unknown align' 59 The two failing test_verifier tests are: "ld_abs: vlan + abs, test 1" "ld_abs: jump around ld_abs" This is due to that "far branching" involved in those tests. All tests where done on QEMU (QEMU emulator version 3.1.50 (v3.1.0-688-g8ae951fbc106)). Signed-off-by: Björn Töpel <bjorn.topel@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
		
							parent
							
								
									31de389707
								
							
						
					
					
						commit
						2353ecc6f9
					
				
					 4 changed files with 1605 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -49,6 +49,7 @@ config RISCV
 | 
			
		|||
	select RISCV_TIMER
 | 
			
		||||
	select GENERIC_IRQ_MULTI_HANDLER
 | 
			
		||||
	select ARCH_HAS_PTE_SPECIAL
 | 
			
		||||
	select HAVE_EBPF_JIT if 64BIT
 | 
			
		||||
 | 
			
		||||
config MMU
 | 
			
		||||
	def_bool y
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,7 +77,7 @@ KBUILD_IMAGE	:= $(boot)/Image.gz
 | 
			
		|||
 | 
			
		||||
head-y := arch/riscv/kernel/head.o
 | 
			
		||||
 | 
			
		||||
core-y += arch/riscv/kernel/ arch/riscv/mm/
 | 
			
		||||
core-y += arch/riscv/kernel/ arch/riscv/mm/ arch/riscv/net/
 | 
			
		||||
 | 
			
		||||
libs-y += arch/riscv/lib/
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1
									
								
								arch/riscv/net/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								arch/riscv/net/Makefile
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
obj-$(CONFIG_BPF_JIT) += bpf_jit_comp.o
 | 
			
		||||
							
								
								
									
										1602
									
								
								arch/riscv/net/bpf_jit_comp.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1602
									
								
								arch/riscv/net/bpf_jit_comp.c
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
		Loading…
	
		Reference in a new issue