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

Re: [Xen-devel] [PATCH v3 4/4] x86/hvm: Indicate avaliability of HW support of APIC virtualization to HVM guests



Boris Ostrovsky wrote on 2014-03-14:
> Set bits in hypervisor CPUID leaf indicating that HW provides (and the
> hypervisor enables) HW support for APIC and x2APIC virtualization.
> 
> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
> ---
>  xen/arch/x86/hvm/vmx/vmx.c          |   12 ++++++++++++
>  xen/include/public/arch-x86/cpuid.h |   10 ++++++++++
>  2 files changed, 22 insertions(+)
> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index 8395e86..e498c26 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++
> b/xen/arch/x86/hvm/vmx/vmx.c @@ -57,6 +57,7 @@
>  #include <asm/apic.h>
>  #include <asm/hvm/nestedhvm.h>
>  #include <asm/event.h>
> +#include <public/arch-x86/cpuid.h>
> 
>  enum handler_return { HNDL_done, HNDL_unhandled,
> HNDL_exception_raised };
> 
> @@ -1646,6 +1647,16 @@ static void vmx_handle_eoi(u8 vector)
>      __vmwrite(GUEST_INTR_STATUS, status);  }
> +void vmx_hypervisor_cpuid_leaf(uint32_t idx, uint32_t sub_idx,
> +                               uint32_t *eax, uint32_t *ebx,
> +                               uint32_t *ecx, uint32_t *edx) {
> +    if ( cpu_has_vmx_apic_reg_virt )
> +         *eax |= XEN_HVM_CPUID_APIC_ACCESS_VIRT;
> +    if ( cpu_has_vmx_virtualize_x2apic_mode )
> +        *eax |= XEN_HVM_CPUID_X2APIC_VIRT; }
> +
>  static struct hvm_function_table __initdata vmx_function_table = {
>      .name                 = "VMX",
>      .cpu_up_prepare       = vmx_cpu_up_prepare,
> @@ -1703,6 +1714,7 @@ static struct hvm_function_table __initdata
> vmx_function_table = {
>      .sync_pir_to_irr      = vmx_sync_pir_to_irr,
>      .handle_eoi           = vmx_handle_eoi,
>      .nhvm_hap_walk_L1_p2m = nvmx_hap_walk_L1_p2m,
> +    .hypervisor_cpuid_leaf= vmx_hypervisor_cpuid_leaf,
>  };
>  
>  const struct hvm_function_table * __init start_vmx(void) diff --git
> a/xen/include/public/arch-x86/cpuid.h
> b/xen/include/public/arch-x86/cpuid.h index d9bd627..7118760 100644 ---
> a/xen/include/public/arch-x86/cpuid.h +++
> b/xen/include/public/arch-x86/cpuid.h @@ -65,4 +65,14 @@
>  #define _XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD 0  #define
> XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD  (1u<<0)
> 
> +/*
> + * Leaf 5 (0x40000004)
> + * HVM-specific features
> + */
> +
> +/* EAX Features */
> +#define XEN_HVM_CPUID_APIC_ACCESS_VIRT (1u << 0) /* Virtualized APIC
> registers */
> +#define XEN_HVM_CPUID_X2APIC_VIRT      (1u << 1) /* Virtualized
> x2APIC accesses */

I still wonder why expose the x2APIC? I guess you only want to know whether the 
APICv is used and all platforms that support APICv must also support 
virtualized x2apic. What can guest do if he knows there is only virtuazliaed 
x2apic but no APICv?

> +
> +
>  #endif /* __XEN_PUBLIC_ARCH_X86_CPUID_H__ */


Best regards,
Yang


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.