Re: [PATCH v1 0/2] LoongArch: BPF: per-CPU addr MOV and timed may_goto
From: Huacai Chen
Date: Fri Jun 12 2026 - 23:09:45 EST
Hi, Tiezhu and Hengqi,
Any comments about this series?
Huacai
On Tue, Jun 9, 2026 at 12:14 PM George Guo <dongtai.guo@xxxxxxxxx> wrote:
>
> From: George Guo <guodongtai@xxxxxxxxxx>
>
> This series enables two independent BPF JIT features on LoongArch, each
> advertised to the verifier via the corresponding bpf_jit_supports_*()
> hook:
>
> Patch 1 implements the internal-only BPF_MOV that resolves a per-CPU
> address from its per-CPU offset. LoongArch keeps the current CPU's
> per-CPU offset in $r21 (__my_cpu_offset), so the resolution is a single
> add of $r21 to the source register. This is used by verifier/JIT
> inlining (e.g. bpf_get_smp_processor_id() and per-CPU map lookups) and
> is not exposed to BPF users.
>
> Patch 2 implements arch_bpf_timed_may_goto() (in a small assembly stub
> with a custom calling convention passing the count/timestamp slot offset
> in BPF_REG_AX) and advertises it, so the verifier lowers may_goto into
> the timed, wall-clock-bounded variant instead of a fixed iteration
> counter.
>
> Tested on a LoongArch (Loongson-3A5000) QEMU/KVM guest with
> CONFIG_PAGE_SIZE_16KB and CONFIG_UNWINDER_ORC:
> - patch 1: test_progs cpumask and percpu map cases pass;
> - patch 2: test_progs iters (incl. the cond_break / may_goto loop
> cases) all pass.
>
> George Guo (2):
> LoongArch: BPF: Support internal-only MOV to resolve per-CPU addrs
> LoongArch: BPF: Add timed may_goto support
>
> arch/loongarch/include/asm/inst.h | 1 +
> arch/loongarch/net/Makefile | 2 +-
> arch/loongarch/net/bpf_jit.c | 27 ++++++++++++++-
> arch/loongarch/net/bpf_timed_may_goto.S | 44 +++++++++++++++++++++++++
> 4 files changed, 72 insertions(+), 2 deletions(-)
> create mode 100644 arch/loongarch/net/bpf_timed_may_goto.S
>
> --
> 2.25.1
>