Skip to content

Commit d8f4cda

Browse files
sean-jcbonzini
authored andcommitted
KVM: MIPS: Mark "struct page" pfns dirty only in "slow" page fault path
Mark pages/folios dirty only the slow page fault path, i.e. only when mmu_lock is held and the operation is mmu_notifier-protected, as marking a page/folio dirty after it has been written back can make some filesystems unhappy (backing KVM guests will such filesystem files is uncommon, and the race is minuscule, hence the lack of complaints). See the link below for details. Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Sean Christopherson <[email protected]> Tested-by: Dmitry Osipenko <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Message-ID: <[email protected]>
1 parent 14d02b7 commit d8f4cda

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/mips/kvm/mmu.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ static int _kvm_mips_map_page_fast(struct kvm_vcpu *vcpu, unsigned long gpa,
514514
set_pte(ptep, pte_mkdirty(*ptep));
515515
pfn = pte_pfn(*ptep);
516516
mark_page_dirty(kvm, gfn);
517-
kvm_set_pfn_dirty(pfn);
518517
}
519518

520519
if (out_entry)
@@ -628,7 +627,6 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, unsigned long gpa,
628627
if (write_fault) {
629628
prot_bits |= __WRITEABLE;
630629
mark_page_dirty(kvm, gfn);
631-
kvm_set_pfn_dirty(pfn);
632630
}
633631
}
634632
entry = pfn_pte(pfn, __pgprot(prot_bits));
@@ -642,6 +640,9 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, unsigned long gpa,
642640
if (out_buddy)
643641
*out_buddy = *ptep_buddy(ptep);
644642

643+
if (writeable)
644+
kvm_set_pfn_dirty(pfn);
645+
645646
spin_unlock(&kvm->mmu_lock);
646647
kvm_release_pfn_clean(pfn);
647648
kvm_set_pfn_accessed(pfn);

0 commit comments

Comments
 (0)