From patchwork Wed May 26 08:48:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lai Jiangshan X-Patchwork-Id: 102360 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 o4Q8nLK7001939 for ; Wed, 26 May 2010 08:49:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934050Ab0EZIsb (ORCPT ); Wed, 26 May 2010 04:48:31 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:57227 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S932536Ab0EZIsa (ORCPT ); Wed, 26 May 2010 04:48:30 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id E5D8017013A; Wed, 26 May 2010 16:48:26 +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 o4Q8kJjV022519; Wed, 26 May 2010 16:46:19 +0800 Received: from [10.167.141.204] (unknown [10.167.141.204]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 5864010C0A6; Wed, 26 May 2010 16:52:09 +0800 (CST) Message-ID: <4BFCE053.6040505@cn.fujitsu.com> Date: Wed, 26 May 2010 16:48:19 +0800 From: Lai Jiangshan User-Agent: Thunderbird 2.0.0.6 (Windows/20070728) MIME-Version: 1.0 To: Lai Jiangshan , Avi Kivity CC: Marcelo Tosatti , LKML , kvm@vger.kernel.org Subject: [RESEND PATCH 1/3] kvm: calculate correct gfn for small host pages which emulates large guest pages References: <4BD97AC1.8070704@cn.fujitsu.com> In-Reply-To: <4BD97AC1.8070704@cn.fujitsu.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]); Wed, 26 May 2010 08:49:21 +0000 (UTC) diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 702c016..958e9c6 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -338,10 +338,13 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, direct = 1; if (!is_dirty_gpte(gw->ptes[level - delta])) access &= ~ACC_WRITE_MASK; - table_gfn = gpte_to_gfn(gw->ptes[level - delta]); - /* advance table_gfn when emulating 1gb pages with 4k */ - if (delta == 0) - table_gfn += PT_INDEX(addr, level); + /* + * It is a large guest pages backed by small host pages, + * So we set @direct(@shadow_page->role.direct)=1, and + * set @table_gfn(@shadow_page->gfn)=the base page frame + * for linear translations. + */ + table_gfn = gw->gfn & ~(KVM_PAGES_PER_HPAGE(level) - 1); } else { direct = 0; table_gfn = gw->table_gfn[level - 2];