[PATCH RFC v4 02/12] riscv/mm: add untagged_addr_remote_unlocked()
John Hubbard
jhubbard at nvidia.com
Mon Jul 27 18:44:35 PDT 2026
On 7/24/26 3:29 PM, Rik van Riel wrote:
...
> index b2df7f72241a..6ae7552fed09 100644
> --- a/arch/riscv/kernel/process.c
> +++ b/arch/riscv/kernel/process.c
> @@ -357,13 +357,15 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg)
> if (mmap_write_lock_killable(mm))
> return -EINTR;
>
> - if (test_bit(MM_CONTEXT_LOCK_PMLEN, &mm->context.flags) && mm->context.pmlen != pmlen) {
> - mmap_write_unlock(mm);
> - return -EBUSY;
> + if (test_bit(MM_CONTEXT_LOCK_PMLEN, &mm->context.flags)) {
> + if (READ_ONCE(mm->context.pmlen) != pmlen) {
I think you should remove this misleading READ_ONCE, because it
implies a race that is not there. The code is happening under
mmap_write_lock_*(), and so does the only writer to pmlen (below),
so they cannot race with each other.
> + mmap_write_unlock(mm);
> + return -EBUSY;
> + }
> }
>
> envcfg_update_bits(task, ENVCFG_PMM, pmm);
> - mm->context.pmlen = pmlen;
> + WRITE_ONCE(mm->context.pmlen, pmlen);
>
> mmap_write_unlock(mm);
>
> @@ -394,7 +396,7 @@ long get_tagged_addr_ctrl(struct task_struct *task)
> break;
> }
>
> - if (task->mm->context.pmlen)
> + if (READ_ONCE(task->mm->context.pmlen))
> ret |= PR_TAGGED_ADDR_ENABLE;
>
> return ret;
thanks,
--
John Hubbard
More information about the linux-riscv
mailing list