diff mbox series

[v8,056/103] KVM: x86/mmu: Let vcpu re-try when faulting page type conflict

Message ID c88b7037e410dea368496319a8427f8924a7585f.1659854790.git.isaku.yamahata@intel.com (mailing list archive)
State New, archived
Headers show
Series KVM TDX basic feature support | expand

Commit Message

Isaku Yamahata Aug. 7, 2022, 10:01 p.m. UTC
From: Xiaoyao Li <xiaoyao.li@intel.com>

When it gets a private page fault on a shared page, or vice verse, let
vcpu retry and vcpu will keep faulting until other vcpu maps the gpa to
matched page type.

Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
---
 arch/x86/kvm/mmu/mmu.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 27deaf44ee80..c9c27945ed44 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -4230,6 +4230,10 @@  static int kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
 			return RET_PF_EMULATE;
 	}
 
+	if (kvm_gfn_shared_mask(vcpu->kvm) &&
+	    (kvm_mem_is_private(vcpu->kvm, fault->gfn) != fault->is_private))
+		return RET_PF_RETRY;
+
 	async = false;
 	fault->pfn = __gfn_to_pfn_memslot(slot, fault->gfn, false, &async,
 					  fault->write, &fault->map_writable,