BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Feng Jiang" <jiangfeng@kylinos.cn>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v2 1/2] bpf, riscv: add support for timed may_goto
Date: Tue, 14 Jul 2026 12:46:12 +0000	[thread overview]
Message-ID: <20260714124612.CB0C21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714-riscv-bpf-timed-may-goto-v2-1-eeb6201aedcc@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The assembly trampoline `arch_bpf_timed_may_goto` does not set up a frame pointer (`s0`), which breaks stack unwinding when `CONFIG_FRAME_POINTER` is enabled and omits the BPF program from stack traces.
--

--- Patch [1]: [PATCH v2 1/2] bpf, riscv: add support for timed may_goto ---
commit 08fb72c94674edd23d2e12eda1b3dd76cb372fdc
Author: Feng Jiang <jiangfeng@kylinos.cn>

bpf, riscv: add support for timed may_goto

Implement arch_bpf_timed_may_goto() for the RV64 JIT. The argument and
return value are carried in BPF_REG_AX, and BPF R0-R5 are preserved
across the call to the generic bpf_check_timed_may_goto(). Enable
bpf_jit_supports_timed_may_goto() so the verifier uses the timed
expansion path.

> diff --git a/arch/riscv/net/bpf_timed_may_goto.S b/arch/riscv/net/bpf_timed_may_goto.S
> new file mode 100644
> index 0000000000000..f54f389d921e0
> --- /dev/null
> +++ b/arch/riscv/net/bpf_timed_may_goto.S
> @@ -0,0 +1,44 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +/* Copyright (c) 2026 Feng Jiang <jiangfeng@kylinos.cn> */
> +
> +#include <linux/linkage.h>
> +#include <asm/asm.h>
> +
> +/*
> + * Trampoline for the BPF timed may_goto loop bound. Custom calling convention:
> + *	- input:  stack offset in BPF_REG_AX (t0)
> + *	- output: updated count in BPF_REG_AX (t0)
> + *
> + * Calls bpf_check_timed_may_goto(ptr) with the standard RISC-V ABI, where
> + * ptr = BPF_REG_FP (s5) + BPF_REG_AX (t0). BPF R0-R5 (a5, a0-a4) are saved
> + * across the call; BPF_REG_FP (s5) is callee-saved and needs no saving.
> + */
> +
> +SYM_FUNC_START(arch_bpf_timed_may_goto)
> +	addi	sp, sp, -64
> +	sd	ra, 56(sp)

[Severity: Medium]
Does this code need to set up a frame pointer (s0)?

When CONFIG_FRAME_POINTER is enabled on RISC-V, the unwinder relies on
the frame pointer to chain frames. Because arch_bpf_timed_may_goto() allocates
stack space and saves ra but fails to save the caller's s0 or update s0 to
point to its own stack frame, stack traces triggered from within
bpf_check_timed_may_goto() (or functions it calls) might omit the JITed BPF
program.

> +
> +	/* Save BPF registers R0-R5 (a5, a0-a4) */
> +	sd	a5, 48(sp)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-riscv-bpf-timed-may-goto-v2-0-eeb6201aedcc@kylinos.cn?part=1

  reply	other threads:[~2026-07-14 12:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 12:16 [PATCH v2 0/2] bpf, riscv: add timed may_goto support Feng Jiang
2026-07-14 12:16 ` [PATCH v2 1/2] bpf, riscv: add support for timed may_goto Feng Jiang
2026-07-14 12:46   ` sashiko-bot [this message]
2026-07-14 12:16 ` [PATCH v2 2/2] selftests/bpf: enable timed may_goto tests for riscv64 Feng Jiang

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=20260714124612.CB0C21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jiangfeng@kylinos.cn \
    --cc=sashiko-reviews@lists.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