[PATCH v1 3/5] KVM: riscv: Write-protect G-stage PTEs atomically
Anup Patel
anup at brainfault.org
Tue Nov 24 21:49:56 PST 2026
On Mon, Sep 21, 2026 at 4:44 PM SeungJu Cheon <suunj1331 at gmail.com> wrote:
>
> GSTAGE_OP_WP clears the W bit with a read-modify-write of the entire
> PTE. Lockless aging can concurrently clear the Accessed bit, allowing
> write-protection to overwrite the update with a stale PTE value.
>
> Clear W atomically with test_and_clear_bit() so that concurrent
> Accessed-bit updates are preserved. Its return value also preserves
> the existing behavior of requesting a TLB flush only when W was
> actually cleared.
>
> Signed-off-by: SeungJu Cheon <suunj1331 at gmail.com>
LGTM.
Reviewed-by: Anup Patel <anup at brainfault.org>
Regards,
Anup
More information about the kvm-riscv
mailing list