diff mbox series

[v2,5/6] x86/hyperv: extract more information from Hyper-V

Message ID 20191218144233.15372-6-liuwe@microsoft.com (mailing list archive)
State New, archived
Headers show
Series Implement Hyper-V reference TSC based clock source | expand

Commit Message

Wei Liu Dec. 18, 2019, 2:42 p.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>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/guest/hyperv/hyperv.c | 17 +++++++++++++++++
 xen/include/asm-x86/guest/hyperv.h | 12 ++++++++++++
 2 files changed, 29 insertions(+)
diff mbox series

Patch

diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index b82ae3833f..2e70b4aa82 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 __read_mostly ms_hyperv;
 
 static const struct hypervisor_ops ops = {
     .name = "Hyper-V",
@@ -40,6 +43,20 @@  const struct hypervisor_ops *__init hyperv_probe(void)
     if ( eax != 0x31237648 )    /* Hv#1 */
         return NULL;
 
+    /* Extract more information from Hyper-V */
+    cpuid(HYPERV_CPUID_FEATURES, &eax, &ebx, &ecx, &edx);
+    ms_hyperv.features = eax;
+    ms_hyperv.misc_features = edx;
+
+    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);
+
+    cpuid(HYPERV_CPUID_IMPLEMENT_LIMITS, &eax, &ebx, &ecx, &edx);
+    ms_hyperv.max_vp_index = eax;
+    ms_hyperv.max_lp_index = ebx;
+
     return &ops;
 }
 
diff --git a/xen/include/asm-x86/guest/hyperv.h b/xen/include/asm-x86/guest/hyperv.h
index 3f88b94c77..cc21b9abfc 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;
+
 const struct hypervisor_ops *hyperv_probe(void);
 
 #else