public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: SVM: fix random segfaults with NPT enabled
@ 2008-08-27 12:18 Joerg Rodel
  2008-08-27 13:11 ` Avi Kivity
  0 siblings, 1 reply; 19+ messages in thread
From: Joerg Rodel @ 2008-08-27 12:18 UTC (permalink / raw)
  To: avi; +Cc: kvm, Joerg Roedel, stable, Alexander Graf

From: Joerg Roedel <joerg.roedel@amd.com>

This patch introduces a guest TLB flush on every NPF exit in KVM. This fixes
random segfaults and #UD exceptions in the guest seen under some workloads
(e.g. long running compile workloads or tbench). A kernbench run with and
without that fix showed that it has a slowdown lower than 0.5%

Cc: stable@kernel.org
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 arch/x86/kvm/svm.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 2d5aed4..980f140 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -59,6 +59,7 @@ static int npt = 1;
 module_param(npt, int, S_IRUGO);
 
 static void kvm_reput_irq(struct vcpu_svm *svm);
+static void svm_flush_tlb(struct kvm_vcpu *vcpu);
 
 static inline struct vcpu_svm *to_svm(struct kvm_vcpu *vcpu)
 {
@@ -1004,10 +1005,17 @@ static int pf_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
 		KVMTRACE_3D(PAGE_FAULT, &svm->vcpu, error_code,
 			    (u32)fault_address, (u32)(fault_address >> 32),
 			    handler);
-	else
+	else {
 		KVMTRACE_3D(TDP_FAULT, &svm->vcpu, error_code,
 			    (u32)fault_address, (u32)(fault_address >> 32),
 			    handler);
+		/*
+		 * FIXME: Tis shouldn't be necessary here, but there is a flush
+		 * missing in the MMU code. Until we find this bug, flush the
+		 * complete TLB here on an NPF
+		 */
+		svm_flush_tlb(&svm->vcpu);
+	}
 
 	if (event_injection)
 		kvm_mmu_unprotect_page_virt(&svm->vcpu, fault_address);
-- 
1.5.3.7



^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2008-08-28 15:58 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-27 12:18 [PATCH] KVM: SVM: fix random segfaults with NPT enabled Joerg Rodel
2008-08-27 13:11 ` Avi Kivity
2008-08-27 13:53   ` Joerg Rodel
2008-08-27 15:21     ` Avi Kivity
2008-08-27 15:32       ` Joerg Roedel
2008-08-27 13:53   ` Avi Kivity
2008-08-27 13:57     ` Joerg Rodel
2008-08-27 15:22       ` Avi Kivity
2008-08-27 15:35         ` Joerg Roedel
2008-08-27 15:50           ` Avi Kivity
2008-08-27 16:27             ` Joerg Rodel
2008-08-27 16:49               ` Avi Kivity
2008-08-27 16:59                 ` Avi Kivity
2008-08-28 14:58                   ` Joerg Rodel
2008-08-28 15:15                     ` Avi Kivity
2008-08-28 15:19                       ` Joerg Roedel
2008-08-28 15:47                         ` Avi Kivity
2008-08-28 15:29                       ` Avi Kivity
2008-08-28 15:58                         ` Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox