From: Xionggui Chen <evers_chen@163.com>
To: Palmer Dabbelt <palmer@dabbelt.com>, Alexandre Ghiti <alex@ghiti.fr>
Cc: Xionggui Chen <chenxionggui@lanxincomputing.com>,
Paul Walmsley <pjw@kernel.org>, Albert Ou <aou@eecs.berkeley.edu>,
"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Jisheng Zhang <jszhang@kernel.org>,
"David Hildenbrand (Arm)" <david@kernel.org>,
Vivian Wang <wangruikang@iscas.ac.cn>,
Muchun Song <muchun.song@linux.dev>,
"Guo Ren (Alibaba DAMO Academy)" <guoren@kernel.org>,
Troy Mitchell <troy.mitchell@linux.dev>,
Nam Cao <namcao@linutronix.de>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] riscv: mm: Disable GCOV instrumentation in set_satp_mode()
Date: Thu, 19 Nov 2026 05:00:41 +0000 [thread overview]
Message-ID: <20261119050049.174124-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.
Signed-off-by: Xionggui Chen <chenxionggui@lanxincomputing.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-11-19 5:02 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=20261119050049.174124-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=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=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®