All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nam Cao <namcao@linutronix.de>
To: Xiaofeng Yuan <xiaofengmian@163.com>, pjw@kernel.org
Cc: palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr,
	broonie@kernel.org, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Xiaofeng Yuan <xiaofengmian@163.com>
Subject: Re: [PATCH v2 2/2] riscv: patch: skip fixmap mapping when kernel text is already writable
Date: Sun, 19 Jul 2026 10:25:28 +0200	[thread overview]
Message-ID: <87h5lv75dz.fsf@yellow.woof> (raw)
In-Reply-To: <20260719081037.5749-3-xiaofengmian@163.com>

Xiaofeng Yuan <xiaofengmian@163.com> writes:

> ...
>
> Signed-off-by: Xiaofeng Yuan <xiaofengmian@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

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Nam Cao <namcao@linutronix.de>
To: Xiaofeng Yuan <xiaofengmian@163.com>, pjw@kernel.org
Cc: palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr,
	broonie@kernel.org, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Xiaofeng Yuan <xiaofengmian@163.com>
Subject: Re: [PATCH v2 2/2] riscv: patch: skip fixmap mapping when kernel text is already writable
Date: Sun, 19 Jul 2026 10:25:28 +0200	[thread overview]
Message-ID: <87h5lv75dz.fsf@yellow.woof> (raw)
In-Reply-To: <20260719081037.5749-3-xiaofengmian@163.com>

Xiaofeng Yuan <xiaofengmian@163.com> writes:

> ...
>
> Signed-off-by: Xiaofeng Yuan <xiaofengmian@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

  reply	other threads:[~2026-07-19  8:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-19  8:10 [PATCH v2 0/2] riscv: fix kprobes on minimal kernel configs Xiaofeng Yuan
2026-07-19  8:10 ` Xiaofeng Yuan
2026-07-19  8:10 ` [PATCH v2 1/2] riscv: mm: make EXECMEM_KPROBES writable without CONFIG_STRICT_MODULE_RWX Xiaofeng Yuan
2026-07-19  8:10   ` Xiaofeng Yuan
2026-07-19  8:18   ` Nam Cao
2026-07-19  8:18     ` Nam Cao
2026-07-19  8:10 ` [PATCH v2 2/2] riscv: patch: skip fixmap mapping when kernel text is already writable Xiaofeng Yuan
2026-07-19  8:10   ` Xiaofeng Yuan
2026-07-19  8:25   ` Nam Cao [this message]
2026-07-19  8:25     ` Nam Cao

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=87h5lv75dz.fsf@yellow.woof \
    --to=namcao@linutronix.de \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=xiaofengmian@163.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.