From patchwork Fri May 7 08:25:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 97618 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 o478Qjjl001653 for ; Fri, 7 May 2010 08:26:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754664Ab0EGIZ7 (ORCPT ); Fri, 7 May 2010 04:25:59 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:57465 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753915Ab0EGIZo (ORCPT ); Fri, 7 May 2010 04:25:44 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 62F4E17013C; Fri, 7 May 2010 16:25:43 +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 o478NokP026372; Fri, 7 May 2010 16:23:50 +0800 Received: from [10.167.141.204] (unknown [10.167.141.204]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 8684DDC315; Fri, 7 May 2010 16:29:02 +0800 (CST) Message-ID: <4BE3CE80.8050408@cn.fujitsu.com> Date: Fri, 07 May 2010 16:25:36 +0800 From: Lai Jiangshan User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Marcelo Tosatti CC: Avi Kivity , LKML , kvm@vger.kernel.org Subject: Re: [PATCH] kvm mmu: reduce 50% memory usage References: <4BD8228D.7090708@cn.fujitsu.com> <20100429180955.GA17909@amt.cnet> <4BD9D35C.5090403@redhat.com> <20100430154427.GA32340@amt.cnet> <4BE269D4.9090108@cn.fujitsu.com> <20100506190402.GA3432@amt.cnet> In-Reply-To: <20100506190402.GA3432@amt.cnet> 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, 07 May 2010 08:26:45 +0000 (UTC) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index a5c6719..6986a6f 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1955,7 +1956,10 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write, } if (*iterator.sptep == shadow_trap_nonpresent_pte) { - pseudo_gfn = (iterator.addr & PT64_DIR_BASE_ADDR_MASK) >> PAGE_SHIFT; + u64 base_addr = iterator.addr; + + base_addr &= PT64_LVL_ADDR_MASK(iterator.level); + pseudo_gfn = base_addr >> PAGE_SHIFT; sp = kvm_mmu_get_page(vcpu, pseudo_gfn, iterator.addr, iterator.level - 1, 1, ACC_ALL, iterator.sptep);