Skip to content

Commit 9c902ae

Browse files
sean-jcbonzini
authored andcommitted
KVM: RISC-V: Mark "struct page" pfns accessed before dropping mmu_lock
Mark pages accessed before dropping mmu_lock when faulting in guest memory so that RISC-V can convert to kvm_release_faultin_page() without tripping its lockdep assertion on mmu_lock being held. Marking pages accessed outside of mmu_lock is ok (not great, but safe), but marking pages _dirty_ outside of mmu_lock can make filesystems unhappy (see the link below). Do both under mmu_lock to minimize the chances of doing the wrong thing in the future. Link: https://lore.kernel.org/all/cover.1683044162.git.lstoakes@gmail.com Reviewed-by: Andrew Jones <ajones@ventanamicro.com> Acked-by: Anup Patel <anup@brainfault.org> Signed-off-by: Sean Christopherson <seanjc@google.com> Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-ID: <20241010182427.1434605-59-seanjc@google.com>
1 parent 9b3639b commit 9c902ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/riscv/kvm/mmu.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,11 +682,11 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
682682

683683
out_unlock:
684684
if ((!ret || ret == -EEXIST) && writable)
685-
kvm_set_pfn_dirty(hfn);
685+
kvm_release_pfn_dirty(hfn);
686+
else
687+
kvm_release_pfn_clean(hfn);
686688

687689
spin_unlock(&kvm->mmu_lock);
688-
kvm_set_pfn_accessed(hfn);
689-
kvm_release_pfn_clean(hfn);
690690
return ret;
691691
}
692692

0 commit comments

Comments
 (0)