From: Imre Kaloz <kaloz@kernel.org>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
linux-mips@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 1/5] MIPS: lib/uncached: fix run_uncached()'s stack switch
Date: Mon, 26 Oct 2026 14:45:39 +0100 [thread overview]
Message-ID: <20261026134543.27207-2-kaloz@kernel.org> (raw)
In-Reply-To: <20261026134543.27207-1-kaloz@kernel.org>
run_uncached() derives the uncached stack pointer for FUNC from $sp and
then spills $16 and $31 into a frame of its own. The compiler may read
$sp before the prologue that allocates that frame, in which case FUNC's
stack starts at the caller's sp and its frame overlaps the saved
registers.
Move the uncached stack pointer down by the two spilled registers.
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
---
arch/mips/lib/uncached.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/mips/lib/uncached.c b/arch/mips/lib/uncached.c
index f80a67c092b6..acfc489698f0 100644
--- a/arch/mips/lib/uncached.c
+++ b/arch/mips/lib/uncached.c
@@ -56,6 +56,13 @@ unsigned long run_uncached(void *func)
BUG();
usp = sp;
}
+
+ /*
+ * "sp" may have been read before the prologue allocated the slots
+ * for $16 and $31 spilled below; keep FUNC's stack clear of them.
+ */
+ usp -= 2 * sizeof(long);
+
if (lfunc >= (long)CKSEG0 && lfunc < (long)CKSEG2)
ufunc = CKSEG1ADDR(lfunc);
#ifdef CONFIG_64BIT
--
2.47.3
next prev parent reply other threads:[~2026-10-26 13:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-26 13:45 [PATCH 0/5] MIPS: SGI updates Imre Kaloz
2026-10-26 13:45 ` Imre Kaloz [this message]
2026-10-26 13:45 ` [PATCH 2/5] MIPS: sgi-ip22: Add prototype for ip22_eisa_init() to header Imre Kaloz
2026-10-26 13:45 ` [PATCH 3/5] MIPS: ip22_defconfig: correct CPU type, add EISA and refresh config Imre Kaloz
2026-10-26 13:45 ` [PATCH 4/5] MIPS: ip30_defconfig: drop add-in drivers, enable the LED driver Imre Kaloz
2026-10-26 13:45 ` [PATCH 5/5] MIPS: ip32_defconfig: drop dead options and add-in drivers, add audio Imre Kaloz
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=20261026134543.27207-2-kaloz@kernel.org \
--to=kaloz@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=tsbogend@alpha.franken.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®