diff mbox series

[for-next,3/7] x86/hyperv: extract more information from Hyper-V

Message ID 20191025091618.10153-4-liuwe@microsoft.com (mailing list archive)
State Superseded
Headers show
Series Implement Hyper-V reference TSC based clock source | expand

Commit Message

Wei Liu Oct. 25, 2019, 9:16 a.m. UTC
Provide a structure to store that information. The structure will be
accessed from other places later so make it public.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
---
 xen/arch/x86/guest/hyperv/hyperv.c | 14 ++++++++++++++
 xen/include/asm-x86/guest/hyperv.h | 12 ++++++++++++
 2 files changed, 26 insertions(+)

Comments

Jan Beulich Dec. 10, 2019, 4:10 p.m. UTC | #1
On 25.10.2019 11:16, Wei Liu wrote:
> --- a/xen/arch/x86/guest/hyperv/hyperv.c
> +++ b/xen/arch/x86/guest/hyperv/hyperv.c
> @@ -21,6 +21,9 @@
>  #include <xen/init.h>
>  
>  #include <asm/guest.h>
> +#include <asm/guest/hyperv-tlfs.h>
> +
> +struct ms_hyperv_info ms_hyperv;
>  
>  bool __init hyperv_probe(void)
>  {
> @@ -36,6 +39,17 @@ bool __init hyperv_probe(void)
>      if ( eax != 0x31237648 )    /* Hv#1 */
>          return false;
>  
> +    /* Extract more information from Hyper-V */
> +    ms_hyperv.features = cpuid_eax(HYPERV_CPUID_FEATURES);
> +    ms_hyperv.misc_features = cpuid_edx(HYPERV_CPUID_FEATURES);

It's __init code, so it doesn't matter all that much, but perhaps
obtain these two and ...

> +    ms_hyperv.hints = cpuid_eax(HYPERV_CPUID_ENLIGHTMENT_INFO);
> +
> +    if ( ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED )
> +        ms_hyperv.nested_features = cpuid_eax(HYPERV_CPUID_NESTED_FEATURES);
> +
> +    ms_hyperv.max_vp_index = cpuid_eax(HYPERV_CPUID_IMPLEMENT_LIMITS);
> +    ms_hyperv.max_lp_index = cpuid_ebx(HYPERV_CPUID_IMPLEMENT_LIMITS);

... these two with just one CPUID invocation each? Preferably
with this adjustment
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index 7ab4b127f3..041166f344 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -21,6 +21,9 @@ 
 #include <xen/init.h>
 
 #include <asm/guest.h>
+#include <asm/guest/hyperv-tlfs.h>
+
+struct ms_hyperv_info ms_hyperv;
 
 bool __init hyperv_probe(void)
 {
@@ -36,6 +39,17 @@  bool __init hyperv_probe(void)
     if ( eax != 0x31237648 )    /* Hv#1 */
         return false;
 
+    /* Extract more information from Hyper-V */
+    ms_hyperv.features = cpuid_eax(HYPERV_CPUID_FEATURES);
+    ms_hyperv.misc_features = cpuid_edx(HYPERV_CPUID_FEATURES);
+    ms_hyperv.hints = cpuid_eax(HYPERV_CPUID_ENLIGHTMENT_INFO);
+
+    if ( ms_hyperv.hints & HV_X64_ENLIGHTENED_VMCS_RECOMMENDED )
+        ms_hyperv.nested_features = cpuid_eax(HYPERV_CPUID_NESTED_FEATURES);
+
+    ms_hyperv.max_vp_index = cpuid_eax(HYPERV_CPUID_IMPLEMENT_LIMITS);
+    ms_hyperv.max_lp_index = cpuid_ebx(HYPERV_CPUID_IMPLEMENT_LIMITS);
+
     return true;
 }
 
diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest/hyperv.h
index 4b9cc5a836..0f8800040a 100644
--- a/xen/include/asm-x86/guest/hyperv.h
+++ b/xen/include/asm-x86/guest/hyperv.h
@@ -21,8 +21,20 @@ 
 
 #ifdef CONFIG_HYPERV_GUEST
 
+#include <xen/types.h>
+
 #include <asm/guest/hypervisor.h>
 
+struct ms_hyperv_info {
+    uint32_t features;
+    uint32_t misc_features;
+    uint32_t hints;
+    uint32_t nested_features;
+    uint32_t max_vp_index;
+    uint32_t max_lp_index;
+};
+extern struct ms_hyperv_info ms_hyperv;
+
 extern struct hypervisor_ops hyperv_ops;
 
 bool hyperv_probe(void);