From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=220.197.31.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796355554; b=e+swJQYEsUok9+4hffvPIou6nkFdFGbQW0EcpUI4MiHk3vPqqhEV+eSJQfVTzkectFSm Diq1hbGERF4lI9ELmIFvRDr9dt/9/KYsachp4rsRlRygjTePaw1PMQwMbzk9MmduUb7f2 oSnX6OCy4yf/0mZacFOiprIE+EwiA62HzpB+6y909+iiGsLc40UJIvF2Tf+QX5tozdOL3 MYk42PcnDFRYZTfEZhLIjvD/8GiUn91kh7B4B5JCul4rvIM3dqy8S4cp7GBS4puUGQgBK kKPlPKCbc5dC4uPV3snO6lF3g+pGgAY92c3EjVoCXICc2sy2Qg6BePoH048XABTm1Lg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796355554; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=SsaH2iGulda3qPHJfI5phu20oC5sjCGu0hkenuoP64s=; b=ea5u+5J+w2APtsQhzIXErHysN5UaBNiAPkyAYJ7OzF9Nq9cyVJY231AUKy7Ag9THU5u3 6tKccPkpywOqBN4giFQ8fykSkm4KBct1cWptUQhEfUfDBKdULLAi42ejVQFj6COO/8rWG +PwUuwDxOuGw8ZLQH6BF8N3Cgcs7JvRbbDpi7zHHKNoN6ZjyRWV7TBcZoLT+sGRP3bnkN XbAPE2NZZU4nJTXX07M/fWE+T/pTjR3dmTqChCTjaJU9g6Li3pcr3ZCdrCUE/dkBD4hBx fEUNNgBpVVErKSIhd2AnnRElFg7xyds/ArIE8XQfINSJGxeMBXF9+slR3z9Mu/KwsKA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=gFKes0J4; arc=none smtp.remote-ip=220.197.31.4 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79D6A606A322 for ; Fri, 4 Dec 2026 03:39:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 79D6A606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=gFKes0J4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=Ss aH2iGulda3qPHJfI5phu20oC5sjCGu0hkenuoP64s=; b=gFKes0J4z6E8UhmjWh 3yDZ7Pmp4VqXf3ySE7OE7kXSzLG2man1NdWaz331yN3DE0ZamT8jotPduhmGexUS wEZW3xJOsMgn28x6kM9tOXaDTb0tqMDafMHCmNnBxqfj3puJHbBRnWfngPmL6OES MnkI3Y6iBoJRnQTIHGf1s0GRY= Received: from 5219-2604 (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wD3P190NRJruBXmLw--.10833S2; Fri, 04 Dec 2026 11:37:45 +0800 (CST) From: Xionggui Chen 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 Message-ID: <20261204033718.5858-1-evers_chen@163.com> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3P190NRJruBXmLw--.10833S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Aw1fXFy7GF1DuFWDWFy5twb_yoW5JrWxpF W8CanY9FWjqr97KF97C34xurW7A3Wkt343GrWUK34kXw4qyF1Fq3ya9w1Yv34DXrWxua48 Xa1a9ryfuFWDA3JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0p_jg4JUUUUU= X-CM-SenderInfo: xhyh22pbfkv0i6rwjhhfrp/xtbC7AvO2GsSNYvGKwAA3b From: Xionggui Chen 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 Tested-by: Yunhui Cui Reviewed-by: Yunhui Cui Reviewed-by: GUO Ren (XuanTie) Acked-by: Muchun Song (ByteDance) Reviewed-by: Troy Mitchell --- 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