From: George Guo <dongtai.guo@linux.dev>
To: Huacai Chen <chenhuacai@kernel.org>,
Tiezhu Yang <yangtiezhu@loongson.cn>,
Hengqi Chen <hengqi.chen@gmail.com>
Cc: WANG Xuerui <kernel@xen0n.name>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
loongarch@lists.linux.dev, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org, George Guo <guodongtai@kylinos.cn>
Subject: [PATCH v1 0/2] LoongArch: BPF: per-CPU addr MOV and timed may_goto
Date: Tue, 9 Jun 2026 12:14:05 +0800 [thread overview]
Message-ID: <20260609041407.122384-1-dongtai.guo@linux.dev> (raw)
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
next reply other threads:[~2026-06-09 4:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 4:14 George Guo [this message]
2026-06-09 4:14 ` [PATCH v1 1/2] LoongArch: BPF: Support internal-only MOV to resolve per-CPU addrs George Guo
2026-06-09 4:14 ` [PATCH v1 2/2] LoongArch: BPF: Add timed may_goto support George Guo
2026-06-13 3:09 ` [PATCH v1 0/2] LoongArch: BPF: per-CPU addr MOV and timed may_goto Huacai Chen
2026-06-15 9:08 ` Tiezhu Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260609041407.122384-1-dongtai.guo@linux.dev \
--to=dongtai.guo@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=guodongtai@kylinos.cn \
--cc=hengqi.chen@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel@xen0n.name \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=song@kernel.org \
--cc=yangtiezhu@loongson.cn \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox