From patchwork Wed May 26 08:48:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 102357 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 o4Q8mdri001809 for ; Wed, 26 May 2010 08:48:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934212Ab0EZIsg (ORCPT ); Wed, 26 May 2010 04:48:36 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:65270 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S932536Ab0EZIsd (ORCPT ); Wed, 26 May 2010 04:48:33 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id C7C6817013B; Wed, 26 May 2010 16:48:32 +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 o4Q8kPdE022531; Wed, 26 May 2010 16:46:25 +0800 Received: from [10.167.141.204] (unknown [10.167.141.204]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 892CD10C0A6; Wed, 26 May 2010 16:52:15 +0800 (CST) Message-ID: <4BFCE059.60502@cn.fujitsu.com> Date: Wed, 26 May 2010 16:48:25 +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: [RESEND PATCH 2/3] kvm, tdp: calculate correct base gfn for non-DIR level 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]); Wed, 26 May 2010 08:48:40 +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);