From: Karl Mehltretter <kmehltretter@gmail.com>
To: Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
Alexandre Ghiti <alex@ghiti.fr>
Cc: Karl Mehltretter <kmehltretter@gmail.com>,
Aleksa Paunovic <aleksa.paunovic@htecgroup.com>,
Djordje Todorovic <djordje.todorovic@htecgroup.com>,
Michael Neuling <mikey@neuling.org>,
Raj Vishwanathan4 <rvishwanathan@mips.com>,
Aleksandar Rikalo <arikalo@gmail.com>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] riscv: errata: mips: Skip vendor extension lookup during early alternatives
Date: Thu, 19 Nov 2026 03:43:10 +0100 [thread overview]
Message-ID: <20261119024310.37980-1-kmehltretter@gmail.com> (raw)
When an enabled erratum selects RISCV_ALTERNATIVE_EARLY,
apply_early_boot_alternatives() calls the MIPS errata callback from
setup_vm() with the MMU disabled. Each enabled P8700 probe calls
riscv_isa_vendor_extension_available() before rejecting
RISCV_ALTERNATIVES_EARLY_BOOT, although neither workaround is applied in
that stage.
KASAN instrumentation in __riscv_isa_vendor_extension_available() reads
shadow memory with satp=0. On QEMU's mips-p8700 model and on a Boston
board with a MIPS P8700 CPU under KASAN_INLINE, this faults during early
boot before console output starts.
Move the existing early-stage rejection before the extension lookup in both
probes. All later stages retain their existing lookup and patch selection.
Fixes: 0b0ca959d206 ("riscv: errata: Fix the PAUSE Opcode for MIPS P8700")
Fixes: 2cf0b2992203 ("riscv: Add ERRATA_MIPS_P8700_WFI to replace WFI with mips.pause")
Tested-by: Aleksa Paunovic <aleksa.paunovic@htecgroup.com>
Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
---
Assisted by an LLM.
Reposting without RFT after Aleksa Paunovic reproduced the bug and
verified the fix on a Boston board with a single-core MIPS P8700 CPU
under KASAN_INLINE.
Changes since the RFT [1]:
- Dropped the RFT tag and added Aleksa Paunovic's Tested-by.
- Rebased onto riscv/fixes (5c52d52b1b8a); no code changes.
- Dropped the removed Assisted-by trailer.
[1] https://lore.kernel.org/r/20261016203052.2026-1-kmehltretter@gmail.com
arch/riscv/errata/mips/errata.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/riscv/errata/mips/errata.c b/arch/riscv/errata/mips/errata.c
index 6e71555274..9bb1c3de95 100644
--- a/arch/riscv/errata/mips/errata.c
+++ b/arch/riscv/errata/mips/errata.c
@@ -18,10 +18,10 @@ static inline bool errata_probe_pause(unsigned int stage)
if (!IS_ENABLED(CONFIG_ERRATA_MIPS_P8700_PAUSE_OPCODE))
return false;
- if (!riscv_isa_vendor_extension_available(MIPS_VENDOR_ID, XMIPSEXECTL))
+ if (stage == RISCV_ALTERNATIVES_EARLY_BOOT)
return false;
- if (stage == RISCV_ALTERNATIVES_EARLY_BOOT)
+ if (!riscv_isa_vendor_extension_available(MIPS_VENDOR_ID, XMIPSEXECTL))
return false;
return true;
@@ -32,10 +32,10 @@ static inline bool errata_probe_wfi(unsigned int stage)
if (!IS_ENABLED(CONFIG_ERRATA_MIPS_P8700_WFI))
return false;
- if (!riscv_isa_vendor_extension_available(MIPS_VENDOR_ID, XMIPSEXECTL))
+ if (stage == RISCV_ALTERNATIVES_EARLY_BOOT)
return false;
- if (stage == RISCV_ALTERNATIVES_EARLY_BOOT)
+ if (!riscv_isa_vendor_extension_available(MIPS_VENDOR_ID, XMIPSEXECTL))
return false;
return true;
base-commit: 5c52d52b1b8a2f884b8fdfe3c74741ad5b48f2ce
--
2.39.5 (Apple Git-154)
reply other threads:[~2026-11-19 2:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261119024310.37980-1-kmehltretter@gmail.com \
--to=kmehltretter@gmail.com \
--cc=aleksa.paunovic@htecgroup.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=arikalo@gmail.com \
--cc=djordje.todorovic@htecgroup.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=mikey@neuling.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=rvishwanathan@mips.com \
/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®