From: Ramin Moussavi <lordrasmus@gmail.com>
To: Michal Simek <monstr@monstr.eu>
Cc: linux-kernel@vger.kernel.org,
Ramin Moussavi <lordrasmus@gmail.com>,
Ramin Moussavi <ramin.moussavi@yacoub.de>
Subject: [PATCH v2 2/2] microblaze: reserve the ABI argument-home area in the signal frame
Date: Fri, 5 Jun 2026 10:20:50 +0200 [thread overview]
Message-ID: <13d7f86e7e5d56a138646c4beb4150fa7d5a5008.1780647609.git.lordrasmus@gmail.com> (raw)
In-Reply-To: <cover.1780647609.git.lordrasmus@gmail.com>
The MicroBlaze procedure call standard reserves [r1+0] for the return
address and lets a callee store its incoming register arguments r5..r10
into the caller-provided home slots at [r1+4]..[r1+24]. When the kernel
enters a signal handler it sets r1 to point at struct rt_sigframe, whose
leading members are the siginfo and ucontext prepared for the handler.
A handler that homes its arguments - which an unoptimised (-O0) build
always does - therefore overwrites the start of siginfo/ucontext,
corrupting the signal state that the handler and sys_rt_sigreturn()
depend on.
Reserve the home area by making a seven-word gap the first member of
struct rt_sigframe, so the handler's argument stores land in scratch
space instead of clobbering siginfo.
Tested on qemu-system-microblazeel (petalogix-s3adsp1800) with the
uClibc-ng NPTL test suite: tst-timer4, tst-timer5, tst-mqueue5 and
tst-signal6 pass; before this change they failed because the handler
clobbered the signal frame.
Signed-off-by: Ramin Moussavi <ramin.moussavi@yacoub.de>
---
arch/microblaze/kernel/signal.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/microblaze/kernel/signal.c b/arch/microblaze/kernel/signal.c
index c78a0ff48..9cca06d60 100644
--- a/arch/microblaze/kernel/signal.c
+++ b/arch/microblaze/kernel/signal.c
@@ -49,6 +49,14 @@ struct sigframe {
};
struct rt_sigframe {
+ /*
+ * Home area for the handler's register arguments: the MicroBlaze
+ * ABI reserves [r1+0] for the return address and lets the callee
+ * store r5..r10 at [r1+4]..[r1+24], and r1 points at this frame
+ * when the handler is entered. Without the gap those stores
+ * corrupt info/uc.
+ */
+ unsigned long abi_gap[7];
struct siginfo info;
struct ucontext uc;
unsigned long tramp[2]; /* signal trampoline */
--
2.53.0
next prev parent reply other threads:[~2026-06-05 8:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-04 15:37 [PATCH 0/2] microblaze: fix signal-frame handling for NPTL Ramin Moussavi
2026-06-04 15:37 ` [PATCH 1/2] microblaze: wire up sigaltstack Ramin Moussavi
2026-06-04 15:37 ` [PATCH 2/2] microblaze: reserve the ABI argument-home area in the signal frame Ramin Moussavi
2026-06-05 6:42 ` Michal Simek
[not found] ` <CAJxQxNCFym69FGxuDh_1gt+v91btBq3bvEnc=5eSApfMP=3pAA@mail.gmail.com>
2026-06-05 7:54 ` Michal Simek
2026-06-05 8:20 ` [PATCH v2 0/2] microblaze: fix signal-frame handling for NPTL Ramin Moussavi
2026-06-05 8:20 ` [PATCH v2 1/2] microblaze: wire up sigaltstack Ramin Moussavi
2026-06-05 8:20 ` Ramin Moussavi [this message]
2026-06-05 8:34 ` [PATCH v2 0/2] microblaze: fix signal-frame handling for NPTL Michal Simek
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=13d7f86e7e5d56a138646c4beb4150fa7d5a5008.1780647609.git.lordrasmus@gmail.com \
--to=lordrasmus@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=monstr@monstr.eu \
--cc=ramin.moussavi@yacoub.de \
/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®