On 22/06/21 19:56, Sean Christopherson wrote:
@@ -2008,10 +2001,19 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
goto trace_get_page;
if (sp->unsync) {
- /* The page is good, but __kvm_sync_page might still end
- * up zapping it. If so, break in order to rebuild it.
+ /*
+ * The page is good, but is stale. "Sync" the page to
+ * get the latest guest state, but don't write-protect
+ * the page and don't mark it synchronized! KVM needs
+ * to ensure the mapping is valid, but doesn't need to
+ * fully sync (write-protect) the page until the guest
+ * invalidates the TLB mapping. This allows multiple
+ * SPs for a single gfn to be unsync.
+ *
+ * If the sync fails, the page is zapped. If so, break
+ * If so, break in order to rebuild it.
*/
This should be a separate patch I think. In addition it should point out the
place where write protection does happen, which is mmu_unsync_children:
/*
* The page is good, but is stale. kvm_sync_page does
* get the latest guest state, but (unlike mmu_unsync_children)
* it doesn't write-protect the page or mark it synchronized!
* This way the validity of the mapping is ensured, but the
* overhead of write protection is not incurred until the
* guest invalidates the TLB mapping. This allows multiple
* SPs for a single gfn to be unsync.
*
* If the sync fails, the page is zapped. If so, break
* in order to rebuild it.
*/
Paolo