From patchwork Mon Aug 2 14:46:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 116533 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o72F1Rq6009004 for ; Mon, 2 Aug 2010 15:01:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751818Ab0HBPA7 (ORCPT ); Mon, 2 Aug 2010 11:00:59 -0400 Received: from va3ehsobe005.messaging.microsoft.com ([216.32.180.31]:24256 "EHLO VA3EHSOBE005.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750959Ab0HBPA6 (ORCPT ); Mon, 2 Aug 2010 11:00:58 -0400 Received: from mail172-va3-R.bigfish.com (10.7.14.245) by VA3EHSOBE005.bigfish.com (10.7.40.25) with Microsoft SMTP Server id 8.1.340.0; Mon, 2 Aug 2010 15:00:45 +0000 Received: from mail172-va3 (localhost.localdomain [127.0.0.1]) by mail172-va3-R.bigfish.com (Postfix) with ESMTP id 50D991408403; Mon, 2 Aug 2010 14:44:45 +0000 (UTC) X-SpamScore: 1 X-BigFish: VS1(zzzz1202hzzz32i87h2a8h43h61h) X-Spam-TCS-SCL: 0:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail172-va3 (localhost.localdomain [127.0.0.1]) by mail172-va3 (MessageSwitch) id 1280760282937837_32444; Mon, 2 Aug 2010 14:44:42 +0000 (UTC) Received: from VA3EHSMHS036.bigfish.com (unknown [10.7.14.248]) by mail172-va3.bigfish.com (Postfix) with ESMTP id E15961370066; Mon, 2 Aug 2010 14:44:42 +0000 (UTC) Received: from ausb3extmailp01.amd.com (163.181.251.8) by VA3EHSMHS036.bigfish.com (10.7.99.46) with Microsoft SMTP Server (TLS) id 14.0.482.44; Mon, 2 Aug 2010 14:43:56 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o72EiI8m028474; Mon, 2 Aug 2010 09:44:21 -0500 X-WSS-ID: 0L6J4WX-02-4IV-02 X-M-MSG: Received: from sausexhtp02.amd.com (sausexhtp02.amd.com [163.181.3.152]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 2DBB0C84D7; Mon, 2 Aug 2010 09:43:44 -0500 (CDT) Received: from storexhtp01.amd.com (172.24.4.3) by sausexhtp02.amd.com (163.181.3.152) with Microsoft SMTP Server (TLS) id 8.2.254.0; Mon, 2 Aug 2010 09:43:44 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp01.amd.com (172.24.4.3) with Microsoft SMTP Server id 8.2.254.0; Mon, 2 Aug 2010 10:43:44 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id 1751049C1FB; Mon, 2 Aug 2010 15:43:43 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 602F4A04BC; Mon, 2 Aug 2010 16:46:48 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: , , Joerg Roedel Subject: [PATCH 1/2] KVM: SVM: Check for nested vmrun intercept before emulating vmrun Date: Mon, 2 Aug 2010 16:46:44 +0200 Message-ID: <1280760405-22591-2-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1280760405-22591-1-git-send-email-joerg.roedel@amd.com> References: <1280760405-22591-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-Reverse-DNS: unknown 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]); Mon, 02 Aug 2010 15:01:29 +0000 (UTC) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index b44c9cc..083fa88 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -2015,6 +2015,14 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm) return true; } +static bool nested_vmcb_checks(struct vmcb *vmcb) +{ + if ((vmcb->control.intercept & (1ULL << INTERCEPT_VMRUN)) == 0) + return false; + + return true; +} + static bool nested_svm_vmrun(struct vcpu_svm *svm) { struct vmcb *nested_vmcb; @@ -2029,6 +2037,17 @@ static bool nested_svm_vmrun(struct vcpu_svm *svm) if (!nested_vmcb) return false; + if (!nested_vmcb_checks(nested_vmcb)) { + nested_vmcb->control.exit_code = SVM_EXIT_ERR; + nested_vmcb->control.exit_code_hi = 0; + nested_vmcb->control.exit_info_1 = 0; + nested_vmcb->control.exit_info_2 = 0; + + nested_svm_unmap(page); + + return false; + } + trace_kvm_nested_vmrun(svm->vmcb->save.rip - 3, vmcb_gpa, nested_vmcb->save.rip, nested_vmcb->control.int_ctl,