riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set
authorZishun Yi <vulab@iscas.ac.cn>
Sun, 22 Mar 2026 16:00:22 +0000 (00:00 +0800)
committerPaul Walmsley <pjw@kernel.org>
Sun, 5 Apr 2026 00:37:45 +0000 (18:37 -0600)
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>
Reviewed-by: Samuel Holland <samuel.holland@sifive.com>
Link: https://patch.msgid.link/20260322160022.21908-1-vulab@iscas.ac.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org>
arch/riscv/kernel/process.c

index aacb239..5957eff 100644 (file)
@@ -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;