From patchwork Mon Mar 22 09:06:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Jianfeng X-Patchwork-Id: 87386 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 o2M978kq029542 for ; Mon, 22 Mar 2010 09:07:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753582Ab0CVJHG (ORCPT ); Mon, 22 Mar 2010 05:07:06 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:57178 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753483Ab0CVJHF (ORCPT ); Mon, 22 Mar 2010 05:07:05 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id CFE9917013C; Mon, 22 Mar 2010 17:07:01 +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 o2M95jPt002983; Mon, 22 Mar 2010 17:05:45 +0800 Received: from [127.0.0.1] (unknown [10.167.141.226]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 1B4F4D490B; Mon, 22 Mar 2010 17:09:24 +0800 (CST) Message-ID: <4BA73322.5020001@cn.fujitsu.com> Date: Mon, 22 Mar 2010 17:06:42 +0800 From: Gui Jianfeng User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Avi Kivity CC: sheng@linux.intel.com, mtosatti@redhat.com, kvm@vger.kernel.org Subject: [PATCH] KMV: VMX: consult IA32_VMX_EPT_VPID_CAP to determine EPT paging-structure memory type 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]); Mon, 22 Mar 2010 09:07:08 +0000 (UTC) diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index fb9a080..1b33a60 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -374,6 +374,8 @@ enum vmcs_field { #define VMX_EPT_MT_EPTE_SHIFT 3 #define VMX_EPT_GAW_EPTP_SHIFT 3 #define VMX_EPT_DEFAULT_MT 0x6ull +#define VMX_EPT_MT_WRBACK 0x6ull +#define VMX_EPT_MT_UNCACHABLE 0x0ull #define VMX_EPT_READABLE_MASK 0x1ull #define VMX_EPT_WRITABLE_MASK 0x2ull #define VMX_EPT_EXECUTABLE_MASK 0x4ull diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 06108f3..f971b9b 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1804,9 +1804,15 @@ static u64 construct_eptp(unsigned long root_hpa) { u64 eptp; - /* TODO write the value reading from MSR */ - eptp = VMX_EPT_DEFAULT_MT | - VMX_EPT_DEFAULT_GAW << VMX_EPT_GAW_EPTP_SHIFT; + if (cpu_has_vmx_eptp_writeback()) + eptp = VMX_EPT_MT_WRBACK | + VMX_EPT_DEFAULT_GAW << VMX_EPT_GAW_EPTP_SHIFT; + else if (cpu_has_vmx_eptp_uncacheable()) + eptp = VMX_EPT_MT_UNCACHABLE | + VMX_EPT_DEFAULT_GAW << VMX_EPT_GAW_EPTP_SHIFT; + else + BUG(); + eptp |= (root_hpa & PAGE_MASK); return eptp;