From patchwork Tue Apr 27 10:38:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 95372 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 o3RAiKZs020876 for ; Tue, 27 Apr 2010 10:44:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755094Ab0D0Kmm (ORCPT ); Tue, 27 Apr 2010 06:42:42 -0400 Received: from tx2ehsobe002.messaging.microsoft.com ([65.55.88.12]:59235 "EHLO TX2EHSOBE003.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754637Ab0D0Kix (ORCPT ); Tue, 27 Apr 2010 06:38:53 -0400 Received: from mail142-tx2-R.bigfish.com (10.9.14.242) by TX2EHSOBE003.bigfish.com (10.9.40.23) with Microsoft SMTP Server id 8.1.340.0; Tue, 27 Apr 2010 10:38:49 +0000 Received: from mail142-tx2 (localhost.localdomain [127.0.0.1]) by mail142-tx2-R.bigfish.com (Postfix) with ESMTP id 3B7667C0367; Tue, 27 Apr 2010 10:38:49 +0000 (UTC) X-SpamScore: 1 X-BigFish: VPS1(zzab9bhzz1202hzz6ff19hz32i2a8h87h62h) X-Spam-TCS-SCL: 1:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail142-tx2 (localhost.localdomain [127.0.0.1]) by mail142-tx2 (MessageSwitch) id 1272364728817358_29764; Tue, 27 Apr 2010 10:38:48 +0000 (UTC) Received: from TX2EHSMHS008.bigfish.com (unknown [10.9.14.242]) by mail142-tx2.bigfish.com (Postfix) with ESMTP id B9C8B168804D; Tue, 27 Apr 2010 10:38:48 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by TX2EHSMHS008.bigfish.com (10.9.99.108) with Microsoft SMTP Server (TLS) id 14.0.482.44; Tue, 27 Apr 2010 10:38:47 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o3RAdAAg012753; Tue, 27 Apr 2010 05:39:13 -0500 X-WSS-ID: 0L1J6WG-02-NOO-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 29EC8C8578; Tue, 27 Apr 2010 05:38:39 -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.234.1; Tue, 27 Apr 2010 05:38:43 -0500 Received: from storexmb1.amd.com (10.1.1.14) by storexhtp01.amd.com (172.24.4.3) with Microsoft SMTP Server id 8.2.234.1; Tue, 27 Apr 2010 03:38:42 -0700 Received: from sausexmb1.amd.com ([163.181.3.156]) by storexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 27 Apr 2010 06:38:42 -0400 Received: from seurexmb1.amd.com ([165.204.9.130]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 27 Apr 2010 05:38:40 -0500 Received: from lemmy.osrc.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 27 Apr 2010 12:38:35 +0200 Received: by lemmy.osrc.amd.com (Postfix, from userid 41430) id 9972EC9C5C; Tue, 27 Apr 2010 12:38:35 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti CC: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH 07/22] KVM: SVM: Implement MMU helper functions for Nested Nested Paging Date: Tue, 27 Apr 2010 12:38:17 +0200 Message-ID: <1272364712-17425-8-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1272364712-17425-1-git-send-email-joerg.roedel@amd.com> References: <1272364712-17425-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 27 Apr 2010 10:38:35.0761 (UTC) FILETIME=[CA522610:01CAE5F5] 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]); Tue, 27 Apr 2010 10:44:30 +0000 (UTC) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 4aae4be..e31f601 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -92,6 +92,9 @@ struct nested_state { u32 intercept_exceptions; u64 intercept; + /* Nested Paging related state */ + u64 nested_cr3; + }; #define MSRPM_OFFSETS 16 @@ -1490,6 +1493,36 @@ static int vmmcall_interception(struct vcpu_svm *svm) return 1; } +static unsigned long nested_svm_get_tdp_cr3(struct kvm_vcpu *vcpu) +{ + struct vcpu_svm *svm = to_svm(vcpu); + + return svm->nested.nested_cr3; +} + +static void nested_svm_set_tdp_cr3(struct kvm_vcpu *vcpu, + unsigned long root) +{ + struct vcpu_svm *svm = to_svm(vcpu); + + svm->vmcb->control.nested_cr3 = root; + force_new_asid(vcpu); +} + +static void nested_svm_inject_npf_exit(struct kvm_vcpu *vcpu, + unsigned long addr, + u32 error_code) +{ + struct vcpu_svm *svm = to_svm(vcpu); + + svm->vmcb->control.exit_code = SVM_EXIT_NPF; + svm->vmcb->control.exit_code_hi = 0; + svm->vmcb->control.exit_info_1 = error_code; + svm->vmcb->control.exit_info_2 = addr; + + nested_svm_vmexit(svm); +} + static int nested_svm_check_permissions(struct vcpu_svm *svm) { if (!(svm->vcpu.arch.efer & EFER_SVME)