From patchwork Sun Apr 12 10:37:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 17803 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 n3CAb9as003503 for ; Sun, 12 Apr 2009 10:37:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759982AbZDLKhG (ORCPT ); Sun, 12 Apr 2009 06:37:06 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759922AbZDLKhG (ORCPT ); Sun, 12 Apr 2009 06:37:06 -0400 Received: from mx2.redhat.com ([66.187.237.31]:45004 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759924AbZDLKhE (ORCPT ); Sun, 12 Apr 2009 06:37:04 -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 n3CAb4Jn025111 for ; Sun, 12 Apr 2009 06:37:04 -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 n3CAb5u7032685; Sun, 12 Apr 2009 06:37:05 -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 n3CAb3Nj025535; Sun, 12 Apr 2009 06:37:03 -0400 Received: from trex.usersys.redhat.com (localhost [127.0.0.1]) by dhcp-1-237.tlv.redhat.com (Postfix) with ESMTP id A63FA18D41C; Sun, 12 Apr 2009 13:37:02 +0300 (IDT) From: Gleb Natapov Subject: [PATCH v3 10/10] [AMD] Skip instruction on a task switch only when appropriate. To: avi@redhat.com Cc: kvm@vger.kernel.org Date: Sun, 12 Apr 2009 13:37:02 +0300 Message-ID: <20090412103702.16966.9171.stgit@trex.usersys.redhat.com> In-Reply-To: <20090412103614.16966.89723.stgit@trex.usersys.redhat.com> References: <20090412103614.16966.89723.stgit@trex.usersys.redhat.com> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 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 was initiated because off a task gate in IDT and IDT was accessed because of an external even the instruction should not be skipped. Signed-off-by: Gleb Natapov --- arch/x86/kvm/svm.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) -- 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 3ffb695..053f3c5 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -1826,6 +1826,7 @@ static int task_switch_interception(struct vcpu_svm *svm, int reason; 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; tss_selector = (u16)svm->vmcb->control.exit_info_1; @@ -1841,8 +1842,14 @@ static int task_switch_interception(struct vcpu_svm *svm, reason = TASK_SWITCH_CALL; - if (reason != TASK_SWITCH_GATE || int_type == SVM_EXITINTINFO_TYPE_SOFT) - skip_emulated_instruction(&svm->vcpu); + if (reason != TASK_SWITCH_GATE || + int_type == SVM_EXITINTINFO_TYPE_SOFT || + (int_type == SVM_EXITINTINFO_TYPE_EXEPT && + (int_vec == OF_VECTOR || int_vec == BP_VECTOR))) { + if (emulate_instruction(&svm->vcpu, kvm_run, 0, 0, + EMULTYPE_SKIP) != EMULATE_DONE) + return 0; + } return kvm_task_switch(&svm->vcpu, tss_selector, reason); }