Skip to contentSkip to conversation

riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set

PATCH In review Zishun Yi 3 participants 3 messages Mar 22 – Mar 25 RISC-V

lore
Share & tools
lore

Zishun Yi

author
#0 lore raw

PATCH 1/1 riscv: Reset pmm when PR_TAGGED_ADDR_ENABLE is not set

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")
---
 arch/riscv/kernel/process.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/kernel/process.c +3 -1
index aacb23978f93..5957effab57c 100644
@@ -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;
Signature · 1 line
2.51.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · 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")

Thanks for the fix!

Quoted 20 lines
---
 arch/riscv/kernel/process.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/kernel/process.c +3 -1
index aacb23978f93..5957effab57c 100644
@@ -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;
maintainer
#2 lore raw
In reply to Zishun Yi
Quoted 8 lines · 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")

Thanks, queued for v7.0-rc.

- Paul