[PATCH -next] riscv: Enable ARCH_HAVE_NMI_SAFE_CMPXCHG

Pu Lehui pulehui at huawei.com
Wed Jul 16 19:00:51 PDT 2025



On 2025/7/11 17:04, Pu Lehui wrote:
> From: Pu Lehui <pulehui at huawei.com>
> 
> The implement of cmpxchg() in riscv is based on atomic primitives and
> has NMI-safe features, so it can be used safely in the in_nmi context.
> ftrace's ringbuffer relies on NMI-safe cmpxchg() in the NMI context.
> Currently, in_nmi() is true when riscv kprobe is in trap-based mode, so
> this config needs to be selected, otherwise kprobetrace will not be

Gentle ping~

The issue can be reproduced by the following steps:

cd /sys/kernel/debug/tracing/
echo 'p do_nanosleep' > kprobe_events
echo 1 > events/kprobes/enable
sleep 1
cat trace # trace log will not show without this patch

> available.
> 
> Signed-off-by: Pu Lehui <pulehui at huawei.com>
> ---
>   arch/riscv/Kconfig | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
> index 36061f4732b7..0e2dfa98338a 100644
> --- a/arch/riscv/Kconfig
> +++ b/arch/riscv/Kconfig
> @@ -23,6 +23,7 @@ config RISCV
>   	select ARCH_ENABLE_MEMORY_HOTREMOVE if MEMORY_HOTPLUG
>   	select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
>   	select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE
> +	select ARCH_HAVE_NMI_SAFE_CMPXCHG
>   	select ARCH_HAS_BINFMT_FLAT
>   	select ARCH_HAS_CRC32 if RISCV_ISA_ZBC
>   	select ARCH_HAS_CRC64 if 64BIT && RISCV_ISA_ZBC



More information about the linux-riscv mailing list