From patchwork Fri Jun 4 00:51:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gui Jianfeng X-Patchwork-Id: 104192 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 o540rwm1009398 for ; Fri, 4 Jun 2010 00:53:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756749Ab0FDAx4 (ORCPT ); Thu, 3 Jun 2010 20:53:56 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:61465 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1756676Ab0FDAxz (ORCPT ); Thu, 3 Jun 2010 20:53:55 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 54316170135; Fri, 4 Jun 2010 08:53:54 +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 o540pd4A001283; Fri, 4 Jun 2010 08:51:39 +0800 Received: from [10.167.141.226] (unknown [10.167.141.226]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 01F3A10C10D; Fri, 4 Jun 2010 08:57:47 +0800 (CST) Message-ID: <4C084E1B.10301@cn.fujitsu.com> Date: Fri, 04 Jun 2010 08:51:39 +0800 From: Gui Jianfeng User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Sheng Yang CC: Avi Kivity , kvm@vger.kernel.org Subject: [PATCH v3] KVM VMX: Make sure single type invvpid is supported before issuing invvpid instruction References: <4C076B72.1030308@cn.fujitsu.com> <201006031657.02854.sheng@linux.intel.com> <4C0779B2.8000001@cn.fujitsu.com> <201006031758.50792.sheng@linux.intel.com> In-Reply-To: <201006031758.50792.sheng@linux.intel.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]); Fri, 04 Jun 2010 00:53:58 +0000 (UTC) diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index 104cf86..b4e2840 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -376,6 +376,8 @@ enum vmcs_field { #define VMX_EPT_EXTENT_CONTEXT_BIT (1ull << 25) #define VMX_EPT_EXTENT_GLOBAL_BIT (1ull << 26) +#define VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT (1ull << 9) /* (41 - 32) */ + #define VMX_EPT_DEFAULT_GAW 3 #define VMX_EPT_MAX_GAW 0x4 #define VMX_EPT_MT_EPTE_SHIFT 3 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 0e561a5..240a407 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -355,6 +355,11 @@ static inline bool cpu_has_vmx_invept_global(void) return vmx_capability.ept & VMX_EPT_EXTENT_GLOBAL_BIT; } +static inline bool cpu_has_vmx_invvpid_single(void) +{ + return vmx_capability.vpid & VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT; +} + static inline bool cpu_has_vmx_ept(void) { return vmcs_config.cpu_based_2nd_exec_ctrl & @@ -499,7 +504,8 @@ static inline void vpid_sync_vcpu_all(struct vcpu_vmx *vmx) if (vmx->vpid == 0) return; - __invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vmx->vpid, 0); + if (cpu_has_vmx_invvpid_single()) + __invvpid(VMX_VPID_EXTENT_SINGLE_CONTEXT, vmx->vpid, 0); } static inline void ept_sync_global(void)