Re: [PATCH 2/7] KVM: X86: Synchronize the shadow pagetable before link it
From: Lai Jiangshan
Date: Thu Sep 02 2021 - 20:44:58 EST
On 2021/9/3 07:54, Sean Christopherson wrote:
trace_get_page:
diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h
index 50ade6450ace..5b13918a55c2 100644
--- a/arch/x86/kvm/mmu/paging_tmpl.h
+++ b/arch/x86/kvm/mmu/paging_tmpl.h
@@ -704,6 +704,10 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault,
access = gw->pt_access[it.level - 2];
sp = kvm_mmu_get_page(vcpu, table_gfn, fault->addr,
it.level-1, false, access);
+ if (sp->unsync_children) {
+ kvm_make_all_cpus_request(KVM_REQ_MMU_SYNC, vcpu);
+ return RET_PF_RETRY;
Making KVM_REQ_MMU_SYNC be able remotely is good idea.
But if the sp is not linked, the @sp might not be synced even we
tried many times. So we should continue to link it.
But if we continue to link it, KVM_REQ_MMU_SYNC should be extended to
sync all roots (current root and prev_roots). And maybe add a
KVM_REQ_MMU_SYNC_CURRENT for current root syncing.
It is not going to be a simple. I have a new way to sync pages
and also fix the problem, but that include several non-fix patches.
We need to fix this problem in the simplest way. In my patch
mmu_sync_children() has a @root argument. I think we can disallow
releasing the lock when @root is false. Is it OK?
+ }
}
/*
--