[PATCH v3 0/3] LoongArch: BPF: Refine move_imm() and optimize 32-bit operations

From: Tiezhu Yang

Date: Fri Oct 16 2026 - 04:18:43 EST


v3:
-- Add a prerequisite patch to detect CPUCFG2_DIV32 feature.
-- Fix a hardware compatibility bug by checking cpu_has_div32
before emitting native 32-bit div/mod instructions.

This version is based on v7.3-rc7 and has been tested on Loongson-3A6000
and Loongson-3A5000 physical machines.

All of the testcases of test_bpf passed on Loongson-3A6000 (with DIV32)
and Loongson-3A5000 (without DIV32), here are the test results:

$ sudo modprobe test_bpf
$ dmesg -t | grep Summary
test_bpf: Summary: 1061 PASSED, 0 FAILED, [1049/1049 JIT'ed]
test_bpf: test_tail_calls: Summary: 10 PASSED, 0 FAILED, [10/10 JIT'ed]
test_bpf: test_skb_segment: Summary: 2 PASSED, 0 FAILED

For the BPF selftests test_verifier and test_progs, there are no any
regressions.

Tiezhu Yang (3):
LoongArch: Add CPUCFG2 DIV32 feature detection
LoongArch: BPF: Clean up and decouple is32 parameter from move_imm()
LoongArch: BPF: Optimize 32-bit operations using native instructions

arch/loongarch/include/asm/cpu-features.h | 1 +
arch/loongarch/include/asm/cpu.h | 2 +
arch/loongarch/include/asm/inst.h | 6 +
arch/loongarch/include/uapi/asm/hwcap.h | 1 +
arch/loongarch/kernel/cpu-probe.c | 4 +
arch/loongarch/kernel/proc.c | 2 +
arch/loongarch/net/bpf_jit.c | 381 ++++++++++++----------
arch/loongarch/net/bpf_jit.h | 25 +-
8 files changed, 234 insertions(+), 188 deletions(-)

--
2.42.0