From patchwork Tue Apr 27 10:38:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 95350 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 o3RAfN4P020087 for ; Tue, 27 Apr 2010 10:41:34 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754878Ab0D0Kkc (ORCPT ); Tue, 27 Apr 2010 06:40:32 -0400 Received: from va3ehsobe003.messaging.microsoft.com ([216.32.180.13]:53050 "EHLO VA3EHSOBE003.bigfish.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754744Ab0D0KjS (ORCPT ); Tue, 27 Apr 2010 06:39:18 -0400 Received: from mail11-va3-R.bigfish.com (10.7.14.238) by VA3EHSOBE003.bigfish.com (10.7.40.23) with Microsoft SMTP Server id 8.1.240.5; Tue, 27 Apr 2010 10:39:18 +0000 Received: from mail11-va3 (localhost.localdomain [127.0.0.1]) by mail11-va3-R.bigfish.com (Postfix) with ESMTP id D81301940247; Tue, 27 Apr 2010 10:39:17 +0000 (UTC) X-SpamScore: 9 X-BigFish: VPS9(zzab9bh78fbpzz1202hzz6ff19hz32i2a8h87h43h65h) X-Spam-TCS-SCL: 4:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail11-va3 (localhost.localdomain [127.0.0.1]) by mail11-va3 (MessageSwitch) id 1272364754154828_28218; Tue, 27 Apr 2010 10:39:14 +0000 (UTC) Received: from VA3EHSMHS029.bigfish.com (unknown [10.7.14.237]) by mail11-va3.bigfish.com (Postfix) with ESMTP id E73DE8E00AE; Tue, 27 Apr 2010 10:38:52 +0000 (UTC) Received: from ausb3extmailp01.amd.com (163.181.251.8) by VA3EHSMHS029.bigfish.com (10.7.99.39) with Microsoft SMTP Server (TLS) id 14.0.482.44; Tue, 27 Apr 2010 10:38:50 +0000 Received: from ausb3twp01.amd.com ([163.181.250.37]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o3RAVYKL015010; Tue, 27 Apr 2010 05:31:37 -0500 X-WSS-ID: 0L1J6WJ-01-32O-02 X-M-MSG: Received: from sausexhtp01.amd.com (sausexhtp01.amd.com [163.181.3.165]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by ausb3twp01.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 24B7C102856B; Tue, 27 Apr 2010 05:38:43 -0500 (CDT) Received: from storexhtp01.amd.com (172.24.4.3) by sausexhtp01.amd.com (163.181.3.165) with Microsoft SMTP Server (TLS) id 8.2.234.1; Tue, 27 Apr 2010 03:38:46 -0700 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:45 -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:45 -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:43 -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 729B8C9B2D; 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 02/22] KVM: MMU: Make tdp_enabled a mmu-context parameter Date: Tue, 27 Apr 2010 12:38:12 +0200 Message-ID: <1272364712-17425-3-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.0558 (UTC) FILETIME=[CA332C60:01CAE5F5] 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]); Tue, 27 Apr 2010 10:41:34 +0000 (UTC) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 3f0007b..44eda9b 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -246,6 +246,7 @@ struct kvm_mmu { int root_level; int shadow_root_level; union kvm_mmu_page_role base_role; + bool direct_map; u64 *pae_root; u64 rsvd_bits_mask[2][4]; diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index ddfa865..618d25f 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1794,7 +1794,7 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, spte |= shadow_user_mask; if (level > PT_PAGE_TABLE_LEVEL) spte |= PT_PAGE_SIZE_MASK; - if (tdp_enabled) + if (vcpu->arch.mmu.direct_map) spte |= kvm_x86_ops->get_mt_mask(vcpu, gfn, kvm_is_mmio_pfn(pfn)); @@ -2059,7 +2059,7 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) hpa_t root = vcpu->arch.mmu.root_hpa; ASSERT(!VALID_PAGE(root)); - if (tdp_enabled) + if (vcpu->arch.mmu.direct_map) direct = 1; if (mmu_check_root(vcpu, root_gfn)) return 1; @@ -2072,7 +2072,7 @@ static int mmu_alloc_roots(struct kvm_vcpu *vcpu) return 0; } direct = !is_paging(vcpu); - if (tdp_enabled) + if (vcpu->arch.mmu.direct_map) direct = 1; for (i = 0; i < 4; ++i) { hpa_t root = vcpu->arch.mmu.pae_root[i]; @@ -2385,6 +2385,7 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu) context->invlpg = nonpaging_invlpg; context->shadow_root_level = kvm_x86_ops->get_tdp_level(); context->root_hpa = INVALID_PAGE; + vcpu->arch.mmu.direct_map = true; if (!is_paging(vcpu)) { context->gva_to_gpa = nonpaging_gva_to_gpa; @@ -2423,6 +2424,7 @@ static int init_kvm_softmmu(struct kvm_vcpu *vcpu) r = paging32_init_context(vcpu); vcpu->arch.mmu.base_role.cr4_pae = !!is_pae(vcpu); + vcpu->arch.mmu.direct_map = false; return r; }