Re: [PATCH] riscv: mm: Disable GCOV instrumentation in set_satp_mode()

From: Muchun Song

Date: Thu Dec 03 2026 - 07:26:00 EST




> On Nov 19, 2026, at 13:00, Xionggui Chen <evers_chen@xxxxxxx> wrote:
>
> From: Xionggui Chen <chenxionggui@xxxxxxxxxxxxxxxxxxx>
>
> 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@xxxxxxxxxxxxxxxxxxx>

Acked-by: Muchun Song (ByteDance) <muchun.song@xxxxxxxxx>

Thanks.