Re: [PATCH v1 2/5] KVM: riscv: Read G-stage PTEs once when walking page tables
From: Anup Patel
Date: Wed Nov 25 2026 - 00:50:09 EST
On Mon, Sep 21, 2026 at 4:44 PM SeungJu Cheon <suunj1331@xxxxxxxxx> wrote:
>
> gstage_pte_leaf() dereferences the PTE pointer, causing walkers to read
> the same entry multiple times. This is safe under mmu_lock, but a
> lockless walker could observe different values when deciding whether an
> entry is a leaf and which child table to follow.
>
> Make gstage_pte_leaf() take a PTE value and use a single snapshot for
> presence, leaf and child-table checks. Also remove a redundant leaf
> check in kvm_riscv_gstage_set_pte(), where mmu_lock prevents the entry
> from changing.
>
> Signed-off-by: SeungJu Cheon <suunj1331@xxxxxxxxx>
LGTM.
Reviewed-by: Anup Patel <anup@xxxxxxxxxxxxxx>
Regards,
Anup