Re: [PATCH] KVM VMX: Make sure single type invvpid is supported before issuing this instruction

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 03 June 2010 16:44:34 Gui Jianfeng wrote:
> According to SDM, we need check whether single-context INVVPID type is
> supported before issuing invvpid instruction.
> 
> Signed-off-by: Gui Jianfeng <guijianfeng@xxxxxxxxxxxxxx>
> ---
>  arch/x86/include/asm/vmx.h |    2 ++
>  arch/x86/kvm/vmx.c         |    8 +++++++-
>  2 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h
> index 104cf86..6fa40d0 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)

Hi Jianfeng
> 
> +#define VMX_EPT_INVVPID_SINGLE_CONTEXT_BIT      (1ull << (41 - 32))
> +

VPID is not a part of EPT. And you can keep consistent with the names above, like: 
VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT

And comments it later maybe better than indirectly (41 - 32)?

Others looks fine to me.

--
regards
Yang, Sheng

>  #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..e2d12bf 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_EPT_INVVPID_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)
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux