| From: |
| George Guo <dongtai.guo-AT-linux.dev> |
| To: |
| Huacai Chen <chenhuacai-AT-kernel.org>, Tiezhu Yang <yangtiezhu-AT-loongson.cn>, Hengqi Chen <hengqi.chen-AT-gmail.com> |
| Subject: |
| [PATCH v1 0/2] LoongArch: BPF: per-CPU addr MOV and timed may_goto |
| Date: |
| Tue, 09 Jun 2026 12:14:05 +0800 |
| Message-ID: |
| <20260609041407.122384-1-dongtai.guo@linux.dev> |
| Cc: |
| WANG Xuerui <kernel-AT-xen0n.name>, Alexei Starovoitov <ast-AT-kernel.org>, Daniel Borkmann <daniel-AT-iogearbox.net>, Andrii Nakryiko <andrii-AT-kernel.org>, Martin KaFai Lau <martin.lau-AT-linux.dev>, Eduard Zingerman <eddyz87-AT-gmail.com>, Kumar Kartikeya Dwivedi <memxor-AT-gmail.com>, Song Liu <song-AT-kernel.org>, Yonghong Song <yonghong.song-AT-linux.dev>, Jiri Olsa <jolsa-AT-kernel.org>, loongarch-AT-lists.linux.dev, bpf-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org, George Guo <guodongtai-AT-kylinos.cn> |
| Archive-link: |
| Article |
From: George Guo <guodongtai@kylinos.cn>
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