summaryrefslogtreecommitdiffstats
path: root/arch/riscv/kvm/mmu.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2024-10-10 20:24:00 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2024-10-25 19:00:48 +0200
commit9c902aee686979d9460d8bd0cabcf2fa0195d7d9 (patch)
tree5692c719da6addbea3a086c49fa466a2a30b414c /arch/riscv/kvm/mmu.c
parentKVM: RISC-V: Mark "struct page" pfns dirty iff a stage-2 PTE is installed (diff)
downloadlinux-9c902aee686979d9460d8bd0cabcf2fa0195d7d9.tar.xz
linux-9c902aee686979d9460d8bd0cabcf2fa0195d7d9.zip
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>
Diffstat (limited to '')
-rw-r--r--arch/riscv/kvm/mmu.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
index 06aa5a0d056d..2e9aee518142 100644
--- a/arch/riscv/kvm/mmu.c
+++ b/arch/riscv/kvm/mmu.c
@@ -682,11 +682,11 @@ int kvm_riscv_gstage_map(struct kvm_vcpu *vcpu,
out_unlock:
if ((!ret || ret == -EEXIST) && writable)
- kvm_set_pfn_dirty(hfn);
+ kvm_release_pfn_dirty(hfn);
+ else
+ kvm_release_pfn_clean(hfn);
spin_unlock(&kvm->mmu_lock);
- kvm_set_pfn_accessed(hfn);
- kvm_release_pfn_clean(hfn);
return ret;
}