From: Xionggui Chen <evers_chen@163.com>
To: palmer@dabbelt.com, alex@ghiti.fr
Cc: evers_chen@163.com, chenxionggui@lanxincomputing.com,
pjw@kernel.org, aou@eecs.berkeley.edu, rppt@kernel.org,
akpm@linux-foundation.org, jszhang@kernel.org, david@kernel.org,
wangruikang@iscas.ac.cn, muchun.song@linux.dev,
guoren@kernel.org, troy@kernel.org, troy.mitchell@linux.dev,
namcao@linutronix.de, cuiyunhui@bytedance.com,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] riscv: mm: Disable GCOV instrumentation in set_satp_mode()
Date: Fri, 4 Dec 2026 03:37:18 +0000 [thread overview]
Message-ID: <20261204033718.5858-1-evers_chen@163.com> (raw)
From: Xionggui Chen <chenxionggui@lanxincomputing.com>
When CONFIG_GCOV_PROFILE_ALL is enabled, GCC instruments
set_satp_mode() with GCOV counter updates.
The function temporarily enables an identity mapping to probe
supported SATP modes. GCOV instrumentation may access counters
outside this temporary mapping while SATP is enabled, causing
a Store/AMO page fault during early boot.
On QEMU virt with Linux 7.4.0-rc1, the fault occurs immediately
after writing satp. The faulting instruction is an amoadd.d
updating a GCOV counter in set_satp_mode().
Mark set_satp_mode() with __no_profile to prevent GCOV counter
accesses during SATP probing, while preserving GCOV coverage
for the other functions in init.c.
Without this change, QEMU fails during early boot. With this
change, the kernel reaches root filesystem mounting.
The fix was also verified on RISC-V hardware with Linux 7.2.0.
Fixes: e8a62cc26ddf ("riscv: Implement sv48 support")
Signed-off-by: Xionggui Chen <chenxionggui@lanxincomputing.com>
Tested-by: Yunhui Cui <cuiyunhui@bytedance.com>
Reviewed-by: Yunhui Cui <cuiyunhui@bytedance.com>
Reviewed-by: GUO Ren (XuanTie) <guoren@kernel.org>
Acked-by: Muchun Song (ByteDance) <muchun.song@linux.dev>
Reviewed-by: Troy Mitchell <troy@kernel.org>
---
Changes in v2:
- Add Fixes tag as suggested by Troy Mitchell.
- Collect Tested-by, Reviewed-by and Acked-by tags.
- No code changes.
v1: https://lore.kernel.org/r/20261119050049.174124-1-evers_chen@163.com/
arch/riscv/mm/init.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 070ee69eabb3..f1c778a82157 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -833,8 +833,11 @@ static bool __init is_vaddr_valid(unsigned long va)
* The maximum SATP mode is limited by both the command line and the "mmu-type"
* property in the device tree, since some platforms may hang if an unsupported
* SATP mode is attempted.
+ *
+ * GCOV instrumentation must be disabled because the temporary identity
+ * mapping does not cover GCOV counters while probing SATP modes.
*/
-static __init void set_satp_mode(uintptr_t dtb_pa)
+static __init __no_profile void set_satp_mode(uintptr_t dtb_pa)
{
u64 identity_satp, hw_satp;
uintptr_t set_satp_mode_pmd = ((unsigned long)set_satp_mode) & PMD_MASK;
--
2.53.0
reply other threads:[~2026-12-04 3:39 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=20261204033718.5858-1-evers_chen@163.com \
--to=evers_chen@163.com \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=chenxionggui@lanxincomputing.com \
--cc=cuiyunhui@bytedance.com \
--cc=david@kernel.org \
--cc=guoren@kernel.org \
--cc=jszhang@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=muchun.song@linux.dev \
--cc=namcao@linutronix.de \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=rppt@kernel.org \
--cc=troy.mitchell@linux.dev \
--cc=troy@kernel.org \
--cc=wangruikang@iscas.ac.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®