mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set
@ 2026-03-22 16:00 Zishun Yi
  2026-03-23  4:06 ` Samuel Holland
  2026-03-25 18:57 ` Paul Walmsley
  0 siblings, 2 replies; 3+ messages in thread
From: Zishun Yi @ 2026-03-22 16:00 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou
  Cc: Alexandre Ghiti, Deepak Gupta, Zong Li, Thomas Gleixner,
	Charlie Jenkins, Clément Léger, Nam Cao,
	Samuel Holland, Simon Schuster, linux-riscv, linux-kernel,
	Zishun Yi

In set_tagged_addr_ctrl(), when PR_TAGGED_ADDR_ENABLE is not set, pmlen
is correctly set to 0, but it forgets to reset pmm. This results in the
CPU pmm state not corresponding to the software pmlen state.

Fix this by resetting pmm along with pmlen.

Fixes: 2e1743085887 ("riscv: Add support for the tagged address ABI")
Signed-off-by: Zishun Yi <vulab@iscas.ac.cn>
---
 arch/riscv/kernel/process.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index aacb23978f93..5957effab57c 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -347,8 +347,10 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg)
 	if (arg & PR_TAGGED_ADDR_ENABLE && (tagged_addr_disabled || !pmlen))
 		return -EINVAL;
 
-	if (!(arg & PR_TAGGED_ADDR_ENABLE))
+	if (!(arg & PR_TAGGED_ADDR_ENABLE)) {
 		pmlen = PMLEN_0;
+		pmm = ENVCFG_PMM_PMLEN_0;
+	}
 
 	if (mmap_write_lock_killable(mm))
 		return -EINTR;
-- 
2.51.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set
  2026-03-22 16:00 [PATCH] riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set Zishun Yi
@ 2026-03-23  4:06 ` Samuel Holland
  2026-03-25 18:57 ` Paul Walmsley
  1 sibling, 0 replies; 3+ messages in thread
From: Samuel Holland @ 2026-03-23  4:06 UTC (permalink / raw)
  To: Zishun Yi, Paul Walmsley, Palmer Dabbelt, Albert Ou
  Cc: Alexandre Ghiti, Deepak Gupta, Zong Li, Thomas Gleixner,
	Charlie Jenkins, Clément Léger, Nam Cao,
	Simon Schuster, linux-riscv, linux-kernel

On 2026-03-22 11:00 AM, Zishun Yi wrote:
> In set_tagged_addr_ctrl(), when PR_TAGGED_ADDR_ENABLE is not set, pmlen
> is correctly set to 0, but it forgets to reset pmm. This results in the
> CPU pmm state not corresponding to the software pmlen state.
> 
> Fix this by resetting pmm along with pmlen.
> 
> Fixes: 2e1743085887 ("riscv: Add support for the tagged address ABI")
> Signed-off-by: Zishun Yi <vulab@iscas.ac.cn>

Thanks for the fix!

Reviewed-by: Samuel Holland <samuel.holland@sifive.com>

> ---
>  arch/riscv/kernel/process.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
> index aacb23978f93..5957effab57c 100644
> --- a/arch/riscv/kernel/process.c
> +++ b/arch/riscv/kernel/process.c
> @@ -347,8 +347,10 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg)
>  	if (arg & PR_TAGGED_ADDR_ENABLE && (tagged_addr_disabled || !pmlen))
>  		return -EINVAL;
>  
> -	if (!(arg & PR_TAGGED_ADDR_ENABLE))
> +	if (!(arg & PR_TAGGED_ADDR_ENABLE)) {
>  		pmlen = PMLEN_0;
> +		pmm = ENVCFG_PMM_PMLEN_0;
> +	}
>  
>  	if (mmap_write_lock_killable(mm))
>  		return -EINTR;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set
  2026-03-22 16:00 [PATCH] riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set Zishun Yi
  2026-03-23  4:06 ` Samuel Holland
@ 2026-03-25 18:57 ` Paul Walmsley
  1 sibling, 0 replies; 3+ messages in thread
From: Paul Walmsley @ 2026-03-25 18:57 UTC (permalink / raw)
  To: Zishun Yi
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Deepak Gupta, Zong Li, Thomas Gleixner, Charlie Jenkins,
	Clément Léger, Nam Cao, Samuel Holland, Simon Schuster,
	linux-riscv, linux-kernel

On Mon, 23 Mar 2026, Zishun Yi wrote:

> In set_tagged_addr_ctrl(), when PR_TAGGED_ADDR_ENABLE is not set, pmlen
> is correctly set to 0, but it forgets to reset pmm. This results in the
> CPU pmm state not corresponding to the software pmlen state.
> 
> Fix this by resetting pmm along with pmlen.
> 
> Fixes: 2e1743085887 ("riscv: Add support for the tagged address ABI")
> Signed-off-by: Zishun Yi <vulab@iscas.ac.cn>

Thanks, queued for v7.0-rc.


- Paul

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-25 18:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-22 16:00 [PATCH] riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set Zishun Yi
2026-03-23  4:06 ` Samuel Holland
2026-03-25 18:57 ` Paul Walmsley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®