Re: [PATCH 1/3] x86/mm: use READ_ONCE/WRITE_ONCE for mm->context.untag_mask

From: Usama Arif

Date: Thu Jun 18 2026 - 12:41:04 EST


On Tue, 16 Jun 2026 15:02:58 -0400 Rik van Riel <riel@xxxxxxxxxxx> wrote:

> mm->context.untag_mask is written once, when LAM is enabled
> (mm_enable_lam(), under mmap_write_lock and while the process is still
> single-threaded), and is otherwise stable and never reverted.
> untagged_addr_remote() reads it for a remote mm, and the new
> untagged_addr_remote_unlocked() (used by the per-VMA-lock
> access_remote_vm() fast path) reads it without the mmap lock.
>
> The field is a single aligned word and cannot tear, but annotate the
> reads and writes with READ_ONCE()/WRITE_ONCE() to make the lockless
> access explicit and keep the compiler from reloading or tearing it.
>
> No functional change.
>
> Assisted-by: Claude:claude-opus-4-8
> Signed-off-by: Rik van Riel <riel@xxxxxxxxxxx>
> ---
> arch/x86/include/asm/mmu_context.h | 6 +++---
> arch/x86/include/asm/uaccess_64.h | 2 +-
> arch/x86/kernel/process_64.c | 2 +-
> 3 files changed, 5 insertions(+), 5 deletions(-)
>

Acked-by: Usama Arif <usama.arif@xxxxxxxxx>