Skip to content

Commit 2b26d6b

Browse files
sean-jcbonzini
authored andcommitted
KVM: PPC: Book3S: Mark "struct page" pfns dirty/accessed after installing PTE
Mark pages/folios dirty/accessed after installing a PTE, and more specifically after acquiring mmu_lock and checking for an mmu_notifier invalidation. 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. This will also allow converting Book3S to kvm_release_faultin_page(), which requires that mmu_lock be held (for the aforementioned reason). 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 dac09f6 commit 2b26d6b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arch/powerpc/kvm/book3s_64_mmu_host.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,10 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte,
121121

122122
vpn = hpt_vpn(orig_pte->eaddr, map->host_vsid, MMU_SEGSIZE_256M);
123123

124-
kvm_set_pfn_accessed(pfn);
125124
if (!orig_pte->may_write || !writable)
126125
rflags |= PP_RXRX;
127-
else {
126+
else
128127
mark_page_dirty(vcpu->kvm, gfn);
129-
kvm_set_pfn_dirty(pfn);
130-
}
131128

132129
if (!orig_pte->may_execute)
133130
rflags |= HPTE_R_N;
@@ -202,8 +199,11 @@ int kvmppc_mmu_map_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *orig_pte,
202199
}
203200

204201
out_unlock:
202+
if (!orig_pte->may_write || !writable)
203+
kvm_release_pfn_clean(pfn);
204+
else
205+
kvm_release_pfn_dirty(pfn);
205206
spin_unlock(&kvm->mmu_lock);
206-
kvm_release_pfn_clean(pfn);
207207
if (cpte)
208208
kvmppc_mmu_hpte_cache_free(cpte);
209209

0 commit comments

Comments
 (0)