[PATCH v1 2/5] KVM: riscv: Read G-stage PTEs once when walking page tables
Anup Patel
anup at brainfault.org
Tue Nov 24 21:49:50 PST 2026
On Mon, Sep 21, 2026 at 4:44 PM SeungJu Cheon <suunj1331 at gmail.com> 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 at gmail.com>
LGTM.
Reviewed-by: Anup Patel <anup at brainfault.org>
Regards,
Anup
More information about the linux-riscv
mailing list