[PATCH v2 2/2] riscv: patch: skip fixmap mapping when kernel text is already writable

Nam Cao namcao at linutronix.de
Sun Jul 19 01:25:28 PDT 2026


Xiaofeng Yuan <xiaofengmian at 163.com> writes:

> ...
>
> Signed-off-by: Xiaofeng Yuan <xiaofengmian at 163.com>

Also missing commit description.

> ---
>  arch/riscv/kernel/patch.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/patch.c b/arch/riscv/kernel/patch.c
> index 16b243376f..b6e8e1e83e 100644
> --- a/arch/riscv/kernel/patch.c
> +++ b/arch/riscv/kernel/patch.c
> @@ -44,7 +44,8 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap)
>  	uintptr_t uintaddr = (uintptr_t) addr;
>  	phys_addr_t phys;
>  
> -	if (core_kernel_text(uintaddr) || is_kernel_exittext(uintaddr)) {
> +	if (IS_ENABLED(CONFIG_STRICT_KERNEL_RWX) &&
> +	    (core_kernel_text(uintaddr) || is_kernel_exittext(uintaddr))) {
>  		phys = __pa_symbol(addr);
>  	} else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) {
>  		struct page *page = vmalloc_to_page(addr);

Probably cleaner to have

if (!IS_ENABLED(CONFIG_STRICT_MODULE_RWX))
	return addr;

at the beginning of this function. And get rid of
CONFIG_STRICT_MODULE_RWX for the rest.

But looks functionally correct to me.

Nam



More information about the linux-riscv mailing list