From: George Guo <dongtai.guo@linux.dev>
To: yangtiezhu@loongson.cn
Cc: sashiko-reviews@lists.linux.dev, chenhuacai@kernel.org,
hengqi.chen@gmail.com, loongarch@lists.linux.dev,
bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/5] LoongArch: BPF: Add support for exceptions
Date: Tue, 1 Dec 2026 00:08:03 -0800 [thread overview]
Message-ID: <20261201080803.282502-1-dongtai.guo@linux.dev> (raw)
In-Reply-To: <sashiko-outbox-234712@kernel.org>
On 2026/11/26 03:59, sashiko-bot@kernel.org wrote:
> Do build_prologue() and __build_epilogue() also need to save and restore
> LOONGARCH_GPR_S7 and LOONGARCH_GPR_S8 when is_exception_prog is true?
>
> In the LoongArch C ABI, s0 through s8 are callee-saved registers. JITed BPF
> programs normally leave s7 and s8 untouched, and any called C function saves
> and restores them in its own frame. When bpf_throw() unwinds the stack,
> however, bpf_throw() and its callees never run their epilogues; the exception
> callback restores only the boundary frame and returns directly to the
> boundary program's caller, leaving s7 and s8 clobbered if any unwound C
> function used them.
Yes, this is a real issue. The JIT does not save $s7 and $s8 because it
never uses them, but the C functions between the boundary program and
bpf_throw() may use them, and their epilogues never run. So the caller
of the boundary program can get $s7 and $s8 back clobbered.
Will fix in v4: reserve two more slots below the $s6 slot for the
boundary and callback programs, save $s7 and $s8 there in the prologue
and restore them in the epilogue. The callback reuses the frame of the
boundary program, so its epilogue restores the values saved by the
boundary program.
Thanks,
George
next parent reply other threads:[~2026-12-01 8:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <sashiko-outbox-234712@kernel.org>
2026-12-01 8:08 ` George Guo [this message]
2026-11-26 3:40 [PATCH v3 0/5] LoongArch: BPF: Add private stack, exceptions, large stack and arena support George Guo
2026-11-26 3:40 ` [PATCH v3 2/5] LoongArch: BPF: Add support for exceptions George Guo
2026-11-30 11:27 ` 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=20261201080803.282502-1-dongtai.guo@linux.dev \
--to=dongtai.guo@linux.dev \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=hengqi.chen@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=loongarch@lists.linux.dev \
--cc=sashiko-reviews@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®