From patchwork Fri Feb 19 15:23:10 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 80655 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1JFQ9tK015868 for ; Fri, 19 Feb 2010 15:26:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754700Ab0BSPZS (ORCPT ); Fri, 19 Feb 2010 10:25:18 -0500 Received: from va3ehsobe004.messaging.microsoft.com ([216.32.180.14]:2781 "EHLO VA3EHSOBE004.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754276Ab0BSPX2 (ORCPT ); Fri, 19 Feb 2010 10:23:28 -0500 Received: from mail113-va3-R.bigfish.com (10.7.14.244) by VA3EHSOBE004.bigfish.com (10.7.40.24) with Microsoft SMTP Server id 8.1.240.5; Fri, 19 Feb 2010 15:23:28 +0000 Received: from mail113-va3 (localhost [127.0.0.1]) by mail113-va3-R.bigfish.com (Postfix) with ESMTP id D5EED710348; Fri, 19 Feb 2010 15:23:27 +0000 (UTC) X-SpamScore: -4 X-BigFish: VPS-4(zz936eMab9bhzz1202hzzz32i6bh87h61h) X-Spam-TCS-SCL: 0:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail113-va3 (localhost.localdomain [127.0.0.1]) by mail113-va3 (MessageSwitch) id 1266593007330344_20409; Fri, 19 Feb 2010 15:23:27 +0000 (UTC) Received: from VA3EHSMHS025.bigfish.com (unknown [10.7.14.236]) by mail113-va3.bigfish.com (Postfix) with ESMTP id 48216ED8051; Fri, 19 Feb 2010 15:23:27 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by VA3EHSMHS025.bigfish.com (10.7.99.35) with Microsoft SMTP Server (TLS) id 14.0.482.39; Fri, 19 Feb 2010 15:23:24 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id o1JFQ2Be020648; Fri, 19 Feb 2010 09:26:06 -0600 X-WSS-ID: 0KY3HEU-02-7NK-02 X-M-MSG: Received: from sausexbh2.amd.com (SAUSEXBH2.amd.com [163.181.22.102]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 28F18C8A17; Fri, 19 Feb 2010 09:23:17 -0600 (CST) Received: from sausexmb1.amd.com ([163.181.3.156]) by sausexbh2.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 19 Feb 2010 09:23:21 -0600 Received: from seurexmb1.amd.com ([165.204.9.130]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 19 Feb 2010 09:23:21 -0600 Received: from lemmy.osrc.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 19 Feb 2010 16:23:12 +0100 Received: by lemmy.osrc.amd.com (Postfix, from userid 41430) id ACFDDC9BBD; Fri, 19 Feb 2010 16:23:12 +0100 (CET) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH 11/11] KVM: SVM: Don't call instruction emulator for invd and wbinvd Date: Fri, 19 Feb 2010 16:23:10 +0100 Message-ID: <1266592990-8911-12-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1266592990-8911-1-git-send-email-joerg.roedel@amd.com> References: <1266592990-8911-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 19 Feb 2010 15:23:12.0933 (UTC) FILETIME=[736E8D50:01CAB177] MIME-Version: 1.0 X-Reverse-DNS: ausb3extmailp02.amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 19 Feb 2010 15:26:11 +0000 (UTC) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 9beda8e..0180cb1 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -1029,6 +1029,10 @@ done_prefixes: /* Unrecognised? */ if (c->d == 0) { + /* Don't fail for invd and wbinvd*/ + if (c->twobyte && (c->b == 0x08 || c->b == 0x09)) + return 0; + DPRINTF("Cannot emulate %02x\n", c->b); return -1; } diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 8119355..5fd00e8 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2117,6 +2117,16 @@ static int cpuid_interception(struct vcpu_svm *svm) return 1; } +static int invd_interception(struct vcpu_svm *svm) +{ + svm->next_rip = kvm_rip_read(&svm->vcpu) + 2; + skip_emulated_instruction(&svm->vcpu); + + /* Nop */ + + return 1; +} + static int iret_interception(struct vcpu_svm *svm) { ++svm->vcpu.stat.nmi_window_exits; @@ -2418,7 +2428,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = { /* [SVM_EXIT_CR0_SEL_WRITE] = emulate_on_interception, */ [SVM_EXIT_CPUID] = cpuid_interception, [SVM_EXIT_IRET] = iret_interception, - [SVM_EXIT_INVD] = emulate_on_interception, + [SVM_EXIT_INVD] = invd_interception, [SVM_EXIT_PAUSE] = pause_interception, [SVM_EXIT_HLT] = halt_interception, [SVM_EXIT_INVLPG] = invlpg_interception, @@ -2434,7 +2444,7 @@ static int (*svm_exit_handlers[])(struct vcpu_svm *svm) = { [SVM_EXIT_STGI] = stgi_interception, [SVM_EXIT_CLGI] = clgi_interception, [SVM_EXIT_SKINIT] = skinit_interception, - [SVM_EXIT_WBINVD] = emulate_on_interception, + [SVM_EXIT_WBINVD] = invd_interception, [SVM_EXIT_MONITOR] = invalid_op_interception, [SVM_EXIT_MWAIT] = invalid_op_interception, [SVM_EXIT_NPF] = pf_interception,