From patchwork Thu May 27 08:06:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Jianfeng X-Patchwork-Id: 102577 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 o4R88eEv029759 for ; Thu, 27 May 2010 08:08:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755377Ab0E0IIh (ORCPT ); Thu, 27 May 2010 04:08:37 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:53489 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754902Ab0E0IIf (ORCPT ); Thu, 27 May 2010 04:08:35 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 67AE61701B3; Thu, 27 May 2010 16:08:33 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o4R86Ppj018608; Thu, 27 May 2010 16:06:25 +0800 Received: from [10.167.141.226] (unknown [10.167.141.226]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 29E2210C0B1; Thu, 27 May 2010 16:12:17 +0800 (CST) Message-ID: <4BFE280A.3090607@cn.fujitsu.com> Date: Thu, 27 May 2010 16:06:34 +0800 From: Gui Jianfeng User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Avi Kivity CC: kvm@vger.kernel.org Subject: [PATCH] kvm mmu: optimizations when tdp is in use 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]); Thu, 27 May 2010 08:08:40 +0000 (UTC) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 0bb9f17..ce4bbd3 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -495,10 +495,13 @@ static int mapping_level(struct kvm_vcpu *vcpu, gfn_t large_gfn) max_level = kvm_x86_ops->get_lpage_level() < host_level ? kvm_x86_ops->get_lpage_level() : host_level; + if (tdp_enabled) + goto done; + for (level = PT_DIRECTORY_LEVEL; level <= max_level; ++level) if (has_wrprotected_page(vcpu->kvm, large_gfn, level)) break; - +done: return level - 1; } @@ -1346,7 +1349,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu, if (role.direct) role.cr4_pae = 0; role.access = access; - if (vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) { + if (!tdp_enabled && vcpu->arch.mmu.root_level <= PT32_ROOT_LEVEL) { quadrant = gaddr >> (PAGE_SHIFT + (PT64_PT_BITS * level)); quadrant &= (1 << ((PT32_PT_BITS - PT64_PT_BITS) * level)) - 1; role.quadrant = quadrant;