From patchwork Sun Apr 5 07:53:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 16392 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 n357rmM0014264 for ; Sun, 5 Apr 2009 07:53:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757108AbZDEHxt (ORCPT ); Sun, 5 Apr 2009 03:53:49 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752059AbZDEHxs (ORCPT ); Sun, 5 Apr 2009 03:53:48 -0400 Received: from mx2.redhat.com ([66.187.237.31]:60799 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757617AbZDEHxs (ORCPT ); Sun, 5 Apr 2009 03:53:48 -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 n357rT4x012288; Sun, 5 Apr 2009 03:53:29 -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 n357rV1d018623; Sun, 5 Apr 2009 03:53:31 -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 n357rStn024260; Sun, 5 Apr 2009 03:53:29 -0400 Received: from trex.usersys.redhat.com (localhost [127.0.0.1]) by dhcp-1-237.tlv.redhat.com (Postfix) with ESMTP id D165518D41C; Sun, 5 Apr 2009 10:53:26 +0300 (IDT) From: Gleb Natapov Subject: [PATCH 3/3] [AMD] Skip instruction on a task switch only when appropriate. To: avi@reshat.com Cc: kvm@vger.kernel.org Date: Sun, 05 Apr 2009 10:53:26 +0300 Message-ID: <20090405075326.17698.24512.stgit@trex.usersys.redhat.com> In-Reply-To: <20090405075315.17698.75426.stgit@trex.usersys.redhat.com> References: <20090405075315.17698.75426.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); }