From patchwork Thu Apr 23 14:03:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 19639 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n3NE41sO008286 for ; Thu, 23 Apr 2009 14:04:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752665AbZDWODw (ORCPT ); Thu, 23 Apr 2009 10:03:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753153AbZDWODw (ORCPT ); Thu, 23 Apr 2009 10:03:52 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59890 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751565AbZDWODv (ORCPT ); Thu, 23 Apr 2009 10:03:51 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n3NE3pkV019073 for ; Thu, 23 Apr 2009 10:03:51 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n3NE3oqw024640; Thu, 23 Apr 2009 10:03:50 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n3NE3nk8007395; Thu, 23 Apr 2009 10:03:49 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 587) id CFF6E18D460; Thu, 23 Apr 2009 17:03:48 +0300 (IDT) Date: Thu, 23 Apr 2009 17:03:48 +0300 From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH][SVM] Don't reinject event that caused a task switch. Message-ID: <20090423140348.GP24095@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org If a task switch caused by an event remove it from the event queue. VMX already does that. Signed-off-by: Gleb Natapov --- Gleb. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 44bb4f8..5134e0e 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1800,6 +1800,10 @@ static int task_switch_interception(struct vcpu_svm *svm, int int_type = svm->vmcb->control.exit_int_info & SVM_EXITINTINFO_TYPE_MASK; int int_vec = svm->vmcb->control.exit_int_info & SVM_EVTINJ_VEC_MASK; + uint32_t type = + svm->vmcb->control.exit_int_info & SVM_EXITINTINFO_TYPE_MASK; + uint32_t idt_v = + svm->vmcb->control.exit_int_info & SVM_EXITINTINFO_VALID; tss_selector = (u16)svm->vmcb->control.exit_info_1; @@ -1809,11 +1813,26 @@ static int task_switch_interception(struct vcpu_svm *svm, else if (svm->vmcb->control.exit_info_2 & (1ULL << SVM_EXITINFOSHIFT_TS_REASON_JMP)) reason = TASK_SWITCH_JMP; - else if (svm->vmcb->control.exit_int_info & SVM_EXITINTINFO_VALID) + else if (idt_v) reason = TASK_SWITCH_GATE; else reason = TASK_SWITCH_CALL; + if (reason == TASK_SWITCH_GATE) { + switch (type) { + case SVM_EXITINTINFO_TYPE_NMI: + svm->vcpu.arch.nmi_injected = false; + break; + case SVM_EXITINTINFO_TYPE_EXEPT: + kvm_clear_exception_queue(&svm->vcpu); + break; + case SVM_EXITINTINFO_TYPE_INTR: + kvm_clear_interrupt_queue(&svm->vcpu); + break; + default: + break; + } + } if (reason != TASK_SWITCH_GATE || int_type == SVM_EXITINTINFO_TYPE_SOFT || @@ -2192,7 +2211,7 @@ static int handle_exit(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu) if (is_external_interrupt(svm->vmcb->control.exit_int_info) && exit_code != SVM_EXIT_EXCP_BASE + PF_VECTOR && - exit_code != SVM_EXIT_NPF) + exit_code != SVM_EXIT_NPF && exit_code != SVM_EXIT_TASK_SWITCH) printk(KERN_ERR "%s: unexpected exit_ini_info 0x%x " "exit_code 0x%x\n", __func__, svm->vmcb->control.exit_int_info,