Re: [PATCH v1 3/5] KVM: riscv: Write-protect G-stage PTEs atomically

From: Anup Patel

Date: Wed Nov 25 2026 - 00:50:14 EST


On Mon, Sep 21, 2026 at 4:44 PM SeungJu Cheon <suunj1331@xxxxxxxxx> 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@xxxxxxxxx>

LGTM.

Reviewed-by: Anup Patel <anup@xxxxxxxxxxxxxx>

Regards,
Anup