All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Guo <dongtai.guo@linux.dev>
To: chenhuacai@kernel.org, yangtiezhu@loongson.cn
Cc: hengqi.chen@gmail.com, guodongtai@kylinos.cn,
	bpf@vger.kernel.org, loongarch@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: [PATCH v4 0/6] LoongArch: BPF: Add private stack, exceptions, large stack and arena support
Date: Tue,  1 Dec 2026 01:51:00 -0800	[thread overview]
Message-ID: <20261201095106.468000-1-dongtai.guo@linux.dev> (raw)

From: George Guo <guodongtai@kylinos.cn>

This series adds the following features to the LoongArch BPF JIT:

  - private stack
  - 2 KiB of stack for programs, the same as on x86-64 and arm64
  - exceptions (bpf_throw)
  - sign-extending loads from arena (BPF_PROBE_MEM32SX)
  - atomics on arena pointers (BPF_PROBE_ATOMIC)

The series is based on 7.4-rc5 with the following patches applied:

  1. My 1 fix patch:
     LoongArch: BPF: Fix the offset of stptr.w and stptr.d stores
     https://lore.kernel.org/loongarch/20261118071444.10258-1-dongtai.guo@linux.dev/

  2. Tiezhu's 1 optimization patch:
     LoongArch: BPF: Optimize doubleword loads with ld.d and ldptr.d
     https://lore.kernel.org/loongarch/20261118081201.10498-1-yangtiezhu@loongson.cn/

  3. Tiezhu's 4 feature patches:
     LoongArch: BPF: Support instructions array, indirect jumps and calls
     https://lore.kernel.org/loongarch/20261123043907.20225-1-yangtiezhu@loongson.cn/

"LoongArch: BPF: Allow programs 2 KiB of stack" needs the stptr fix:
stack stores beyond the signed 12-bit offset range use stptr.{w/d}.

With this series, the following tests passed on a Loongson-3C6000:

  $ sudo ./test_progs -t exceptions
  Summary: 1/119 PASSED, 0 SKIPPED, 0/0 FAILED

  $ sudo ./test_progs -a verifier_large_stack
  Summary: 1/17 PASSED, 1 SKIPPED, 0/0 FAILED

  $ sudo ./test_progs -t tailcalls
  Summary: 1/43 PASSED, 0 SKIPPED, 0/0 FAILED

  $ sudo ./test_progs -t struct_ops_private_stack
  Summary: 1/4 PASSED, 0 SKIPPED, 0/0 FAILED

  $ sudo ./test_progs -t verifier_ldsx | tail -1
  Summary: 1/24 PASSED, 0 SKIPPED, 0/0 FAILED

  $ sudo ./test_progs -t arena_atomics | tail -1
  Summary: 1/11 PASSED, 0 SKIPPED, 0/0 FAILED

  $ sudo ./test_progs -t libarena | tail -1
  Summary: 2/43 PASSED, 0 SKIPPED, 0/0 FAILED

The skipped verifier_large_stack test only runs without large stack
support.

libarena also needs commit 27f2cf406a35 ("selftests/bpf: libarena: Raise
arena spinlock CPU limits") from bpf-next, since CONFIG_NR_CPUS is 2048
by default on LoongArch.

The struct_ops_private_stack, arena_atomics load-acquire/store-release
and libarena parallel tests, the arena tests in verifier_ldsx and the
"private stack: two frames of 2048 bytes" test in verifier_large_stack
are not enabled for LoongArch in mainline yet. They were enabled locally
for these runs, and the selftests patches will go to bpf-next once this
series is merged.

Changes since v3:
  - Move "Allow programs 2 KiB of stack" before "Add support for
    exceptions", so that the exception frame changes are added only
    once in jit_save_area_size() (Tiezhu).
  - Patch 3: save and restore $s7 and $s8 for the exception boundary
    and callback programs, since bpf_throw() skips the epilogues of the
    C functions it unwinds (Sashiko).
  - New patch 5: consolidate the five zero-extensions of src in
    emit_atomic_rmw() into one, as a no-op preparation for patch 6
    (Tiezhu).
  - Patch 6: keep only the arena atomics changes.
  - Test the arena atomics with LAMCAS and SCQ reported by the CPU under
    KVM, instead of forcing them on in cpu_probe_common().
  - Rebase onto 7.4-rc5.

v3: https://lore.kernel.org/loongarch/20261126034048.7370-1-dongtai.guo@linux.dev/
v2: https://lore.kernel.org/loongarch/20260702022322.51033-1-dongtai.guo@linux.dev/

George Guo (6):
  LoongArch: BPF: Add support for private stack
  LoongArch: BPF: Allow programs 2 KiB of stack
  LoongArch: BPF: Add support for exceptions
  LoongArch: BPF: Add support for signed arena loads
  LoongArch: BPF: Consolidate zero-extension in emit_atomic_rmw()
  LoongArch: BPF: Add support for arena atomics

 Documentation/bpf/bpf_design_QA.rst |  13 +-
 arch/loongarch/include/asm/inst.h   |   4 +
 arch/loongarch/net/bpf_jit.c        | 421 ++++++++++++++++++++++++----
 arch/loongarch/net/bpf_jit.h        |   1 +
 4 files changed, 386 insertions(+), 53 deletions(-)


base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
prerequisite-patch-id: ee451ad20d651112f42e66d7ba6fa4242b124fb4
prerequisite-patch-id: 403cb992a7f660379bedce79e3068f1bc6facf05
prerequisite-patch-id: 221fa3fc56a55b9a7462ae7b21330a660240c8d2
prerequisite-patch-id: 08e033b51cefbf1d41f2e5325d591ff900ab81ef
prerequisite-patch-id: ffd6050832069f626c1f55492f0a1898137f6aa4
prerequisite-patch-id: 25f0b3ea5219dfd0676bdf22466453f2bf5dd5ea
-- 
2.53.0


             reply	other threads:[~2026-12-01  9:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:51 George Guo [this message]
2026-12-01  9:51 ` [PATCH v4 1/6] LoongArch: BPF: Add support for private stack George Guo
2026-12-01  9:51 ` [PATCH v4 2/6] LoongArch: BPF: Allow programs 2 KiB of stack George Guo
2026-12-01  9:51 ` [PATCH v4 3/6] LoongArch: BPF: Add support for exceptions George Guo
2026-12-01  9:51 ` [PATCH v4 4/6] LoongArch: BPF: Add support for signed arena loads George Guo
2026-12-01  9:51 ` [PATCH v4 5/6] LoongArch: BPF: Consolidate zero-extension in emit_atomic_rmw() George Guo
2026-12-01  9:51 ` [PATCH v4 6/6] LoongArch: BPF: Add support for arena atomics George Guo
2026-12-01 10:11   ` sashiko-bot

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=20261201095106.468000-1-dongtai.guo@linux.dev \
    --to=dongtai.guo@linux.dev \
    --cc=bpf@vger.kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=guodongtai@kylinos.cn \
    --cc=hengqi.chen@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=yangtiezhu@loongson.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.