diff mbox

[03/10] KVM: SVM: Move nested INTR #vmexit into preemtible code

Message ID 1254925888-13743-4-git-send-email-joerg.roedel@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

Joerg Roedel Oct. 7, 2009, 2:31 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index b6ce1a9..7015680 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1379,8 +1379,14 @@  static inline int nested_svm_intr(struct vcpu_svm *svm)
 
 	svm->vmcb->control.exit_code = SVM_EXIT_INTR;
 
-	if (nested_svm_exit_handled(svm)) {
-		nsvm_printk("VMexit -> INTR\n");
+	if (svm->nested.intercept & 1ULL) {
+		/*
+		 * The #vmexit can't be emulated here directly because this
+		 * code path runs with irqs and preemtion disabled and a
+		 * #vmexit emulation might sleep. Only set the request bit for
+		 * the #vmexit here.
+		 */
+		set_bit(KVM_REQ_VMEXIT, &svm->vcpu.requests);
 		return 1;
 	}
 
@@ -2859,6 +2865,13 @@  static bool svm_gb_page_enable(void)
 	return true;
 }
 
+static void svm_emulate_vmexit(struct kvm_vcpu *vcpu)
+{
+	struct vcpu_svm *svm = to_svm(vcpu);
+
+	nested_svm_vmexit(svm);
+}
+
 static struct kvm_x86_ops svm_x86_ops = {
 	.cpu_has_kvm_support = has_svm,
 	.disabled_by_bios = is_disabled,
@@ -2923,6 +2936,7 @@  static struct kvm_x86_ops svm_x86_ops = {
 
 	.exit_reasons_str = svm_exit_reasons_str,
 	.gb_page_enable = svm_gb_page_enable,
+	.emulate_vmexit = svm_emulate_vmexit,
 };
 
 static int __init svm_init(void)