Skip to contentSkip to conversation

Initial support for Microsoft Hyper-V.

RFC PATCH Superseded Vadim Rozenfeld 5 participants 9 messages Oct 17, 2011

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Initial support for Microsoft Hyper-V.

With the following series of patches we are starting to implement some basic Microsoft Hyper-V Enlightenment functionality. This series is mostly about adding support for relaxed timing, spinlock, and virtual apic.

For more Hyper-V related information please see:
"Hypervisor Functional Specification v2.0: For Windows Server 2008 R2" at
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18673

Changelog:
v0->v1
- move hyper-v parameters under cpu category,
- move hyper-v stuff to target-i386 directory,
- make CONFIG_HYPERV enabled by default for i386-softmmu and x86_64-softmmu configurations,
- rearrange the patches from v0,
- set HV_X64_MSR_HYPERCALL, HV_X64_MSR_GUEST_OS_ID, and HV_X64_MSR_APIC_ASSIST_PAGE to 0 on system reset.

Vadim Rozenfeld (2):
hyper-v: introduce Hyper-V support infrastructure.
hyper-v: initialize Hyper-V CPUID leafs.

 Makefile.target                    |    2 +
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 target-i386/cpuid.c                |   14 +++++++
 target-i386/hyperv.c               |   69 ++++++++++++++++++++++++++++++++++++
 target-i386/hyperv.h               |   30 +++++++++++++++
 target-i386/kvm.c                  |   64 ++++++++++++++++++++++++++++++++-
 7 files changed, 179 insertions(+), 2 deletions(-)
 create mode 100644 target-i386/hyperv.c
 create mode 100644 target-i386/hyperv.h
Signature · 1 line
1.7.4.4
#1 lore raw

RFC PATCH 1/2 hyper-v: introduce Hyper-V support infrastructure.

with the following series of patches we are starting to implement some basic Microsoft Hyper-V Enlightenment functionality, like relaxed timing, spinlock, and virtual apic support.

For more Hyper-V related information please see:
"Hypervisor Functional Specification v2.0: For Windows Server 2008 R2" at
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18673

---
 Makefile.target                    |    2 +
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 target-i386/cpuid.c                |   14 +++++++
 target-i386/hyperv.c               |   69 ++++++++++++++++++++++++++++++++++++
 target-i386/hyperv.h               |   30 +++++++++++++++
 6 files changed, 117 insertions(+), 0 deletions(-)
 create mode 100644 target-i386/hyperv.c
 create mode 100644 target-i386/hyperv.h
Makefile.target +2 -0
index 40cc592..2c8e1b8 100644
@@ -202,6 +202,8 @@ obj-$(CONFIG_NO_KVM) += kvm-stub.o
 obj-y += memory.o
 LIBS+=-lz
 
+obj-$(CONFIG_HYPERV) += hyperv.o
+
 QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
 QEMU_CFLAGS += $(VNC_SASL_CFLAGS)
 QEMU_CFLAGS += $(VNC_JPEG_CFLAGS)
default-configs/i386-softmmu.mak +1 -0
index 55589fa..ee69a0a 100644
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
 CONFIG_SOUND=y
 CONFIG_HPET=y
 CONFIG_APPLESMC=y
+CONFIG_HYPERV=y
default-configs/x86_64-softmmu.mak +1 -0
index 8895028..35b1c00 100644
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
 CONFIG_SOUND=y
 CONFIG_HPET=y
 CONFIG_APPLESMC=y
+CONFIG_HYPERV=y
target-i386/cpuid.c +14 -0
index 1e8bcff..50b2d0e 100644
@@ -27,6 +27,8 @@
 #include "qemu-option.h"
 #include "qemu-config.h"
 
+#include "hyperv.h"
+
 /* feature flags taken from "Intel Processor Identification and the CPUID
  * Instruction" and AMD's "CPUID Specification".  In cases of disagreement
  * between feature naming conventions, aliases may be added.
@@ -716,6 +718,14 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
                     goto error;
                 }
                 x86_cpu_def->tsc_khz = tsc_freq / 1000;
+            } else if (!strcmp(featurestr, "hv_spinlocks")) {
+               char* err;
+               numvalue = strtoul(val, &err, 0);
+               if (!*val || *err) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    goto error;
+                }
+                hyperv_set_spinlock_retries(numvalue);
             } else {
                 fprintf(stderr, "unrecognized feature %s\n", featurestr);
                 goto error;
@@ -724,6 +734,10 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
             check_cpuid = 1;
         } else if (!strcmp(featurestr, "enforce")) {
             check_cpuid = enforce_cpuid = 1;
+        } else if (!strcmp(featurestr, "hv_relaxed")) {
+            hyperv_set_relaxed_timing(1);
+        } else if (!strcmp(featurestr, "hv_vapic")) {
+            hyperv_set_vapic_recommended(1);            
         } else {
             fprintf(stderr, "feature string `%s' not in format (+feature|-feature|feature=xyz)\n", featurestr);
             goto error;
target-i386/hyperv.c new file +69 -0

69 lines not on this page · raw message

target-i386/hyperv.h new file +30 -0
new file mode 100644
index 0000000..1ea5e99
@@ -0,0 +1,30 @@
+/*
+ * QEMU Hyper-V support
+ *
+ * Copyright Red Hat, Inc. 2011
+ *
+ * Author: Vadim Rozenfeld     <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_HW_HYPERV_H
+#define QEMU_HW_HYPERV_H 1
+
+#include <asm/hyperv.h>
+
+#define HYPERV_SPINLOCK_NEVER_RETRY             0xFFFFFFFF
+
+void hyperv_set_vapic_recommended(int val);
+void hyperv_set_relaxed_timing(int val);
+void hyperv_set_spinlock_retries(int val);
+
+int hyperv_enabled(void);
+int hyperv_hypercall_available(void);
+int hyperv_get_vapic_recommended(void);
+int hyperv_get_relaxed_timing(void);
+int hyperv_get_spinlock_retries(void);
+
+#endif /* QEMU_HW_HYPERV_H */
Signature · 1 line
1.7.4.4
#4 lore raw

RFC PATCH 2/2 hyper-v: initialize Hyper-V CPUID leafs.

In reply to Vadim Rozenfeld
---
 target-i386/kvm.c |   64 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 62 insertions(+), 2 deletions(-)
target-i386/kvm.c +62 -2
index 3840255..30b3e85 100644
@@ -29,6 +29,7 @@
 #include "hw/pc.h"
 #include "hw/apic.h"
 #include "ioport.h"
+#include "hyperv.h"
 
 //#define DEBUG_KVM
 
@@ -379,11 +380,16 @@ int kvm_arch_init_vcpu(CPUState *env)
     cpuid_i = 0;
 
     /* Paravirtualization CPUIDs */
-    memcpy(signature, "KVMKVMKVM\0\0\0", 12);
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
     c->function = KVM_CPUID_SIGNATURE;
-    c->eax = 0;
+    if (!hyperv_enabled()) {
+        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
+        c->eax = 0;
+    } else {
+        memcpy(signature, "Microsoft Hv", 12);
+        c->eax = HYPERV_CPUID_MIN;
+    }
     c->ebx = signature[0];
     c->ecx = signature[1];
     c->edx = signature[2];
@@ -394,6 +400,45 @@ int kvm_arch_init_vcpu(CPUState *env)
     c->eax = env->cpuid_kvm_features &
         kvm_arch_get_supported_cpuid(s, KVM_CPUID_FEATURES, 0, R_EAX);
 
+    if (hyperv_enabled()) {
+        memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12);
+        c->eax = signature[0];
+
+        c = &cpuid_data.entries[cpuid_i++];
+        memset(c, 0, sizeof(*c));
+        c->function = HYPERV_CPUID_VERSION;
+        c->eax = 0x00001bbc;
+        c->ebx = 0x00060001;
+
+        c = &cpuid_data.entries[cpuid_i++];
+        memset(c, 0, sizeof(*c));
+        c->function = HYPERV_CPUID_FEATURES;
+        if (hyperv_get_relaxed_timing()) {
+            c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
+        }
+        if (hyperv_get_vapic_recommended()) {
+            c->eax |= HV_X64_MSR_HYPERCALL_AVAILABLE;
+            c->eax |= HV_X64_MSR_APIC_ACCESS_AVAILABLE;
+        }
+
+        c = &cpuid_data.entries[cpuid_i++];
+        memset(c, 0, sizeof(*c));
+        c->function = HYPERV_CPUID_ENLIGHTMENT_INFO;
+        if (hyperv_get_relaxed_timing()) {
+            c->eax |= HV_X64_RELAXED_TIMING_RECOMMENDED;
+        }
+        if (hyperv_get_vapic_recommended()) {
+            c->eax |= HV_X64_APIC_ACCESS_RECOMMENDED;
+        }
+        c->ebx = hyperv_get_spinlock_retries();
+
+        c = &cpuid_data.entries[cpuid_i++];
+        memset(c, 0, sizeof(*c));
+        c->function = HYPERV_CPUID_IMPLEMENT_LIMITS;
+        c->eax = 0x40;
+        c->ebx = 0x40;
+    }
+
     has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
 
     cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused);
@@ -945,6 +990,13 @@ static int kvm_put_msrs(CPUState *env, int level)
             kvm_msr_entry_set(&msrs[n++], MSR_KVM_ASYNC_PF_EN,
                               env->async_pf_en_msr);
         }
+        if (hyperv_hypercall_available()) {
+            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_GUEST_OS_ID, 0);
+            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_HYPERCALL, 0);
+        }
+        if (hyperv_get_vapic_recommended()) {
+            kvm_msr_entry_set(&msrs[n++], HV_X64_MSR_APIC_ASSIST_PAGE, 0);
+        }
     }
     if (env->mcg_cap) {
         int i;
@@ -1179,6 +1231,14 @@ static int kvm_get_msrs(CPUState *env)
         msrs[n++].index = MSR_KVM_ASYNC_PF_EN;
     }
 
+    if (hyperv_hypercall_available()) {
+        msrs[n++].index = HV_X64_MSR_GUEST_OS_ID;
+        msrs[n++].index = HV_X64_MSR_HYPERCALL;
+    }
+    if (hyperv_get_vapic_recommended()) {
+        msrs[n++].index = HV_X64_MSR_APIC_ASSIST_PAGE;
+    }
+
     if (env->mcg_cap) {
         msrs[n++].index = MSR_MCG_STATUS;
         msrs[n++].index = MSR_MCG_CTL;
Signature · 1 line
1.7.4.4
#2 lore raw

Re: [Qemu-devel] [PATCH RFC v1 1/2] hyper-v: introduce Hyper-V support infrastructure.

In reply to Vadim Rozenfeld

Am 17.10.2011 11:17, schrieb Vadim Rozenfeld:

Quoted 23 lines

with the following series of patches we are starting to implement some basic Microsoft Hyper-V Enlightenment functionality, like relaxed timing, spinlock, and virtual apic support.

For more Hyper-V related information please see:
"Hypervisor Functional Specification v2.0: For Windows Server 2008 R2" at
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18673

---
 Makefile.target                    |    2 +
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 target-i386/cpuid.c                |   14 +++++++
 target-i386/hyperv.c               |   69 ++++++++++++++++++++++++++++++++++++
 target-i386/hyperv.h               |   30 +++++++++++++++
 6 files changed, 117 insertions(+), 0 deletions(-)
 create mode 100644 target-i386/hyperv.c
 create mode 100644 target-i386/hyperv.h
Makefile.target +0 -0
index 40cc592..2c8e1b8 100644

Makefile.target obj-$(CONFIG_NO_KVM) += kvm-stub.o · line 206

Quoted 5 lines
Makefile.target +2 -0
@@ -202,6 +202,8 @@ obj-$(CONFIG_NO_KVM) += kvm-stub.o
 obj-y += memory.o
 LIBS+=-lz
 
+obj-$(CONFIG_HYPERV) += hyperv.o
+

The patch doesn't look to me as if it could build successfully without CONFIG_HYPERV. An option with only one working value seems a bit pointless.

Kevin

#3 lore raw

Re: [PATCH RFC v1 1/2] hyper-v: introduce Hyper-V support infrastructure.

In reply to Vadim Rozenfeld
Quoted 23 lines · Vadim Rozenfeld

with the following series of patches we are starting to implement some basic Microsoft Hyper-V Enlightenment functionality, like relaxed timing, spinlock, and virtual apic support.

For more Hyper-V related information please see:
"Hypervisor Functional Specification v2.0: For Windows Server 2008 R2" at
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18673

---
 Makefile.target                    |    2 +
 default-configs/i386-softmmu.mak   |    1 +
 default-configs/x86_64-softmmu.mak |    1 +
 target-i386/cpuid.c                |   14 +++++++
 target-i386/hyperv.c               |   69 ++++++++++++++++++++++++++++++++++++
 target-i386/hyperv.h               |   30 +++++++++++++++
 6 files changed, 117 insertions(+), 0 deletions(-)
 create mode 100644 target-i386/hyperv.c
 create mode 100644 target-i386/hyperv.h
Makefile.target +0 -0
index 40cc592..2c8e1b8 100644

Makefile.target obj-$(CONFIG_NO_KVM) += kvm-stub.o · line 205

Quoted 4 lines
Makefile.target +1 -0
@@ -202,6 +202,8 @@ obj-$(CONFIG_NO_KVM) += kvm-stub.o
 obj-y += memory.o
 LIBS+=-lz
 
+obj-$(CONFIG_HYPERV) += hyperv.o

obj-i386-y

Quoted 18 lines
Makefile.target +1 -0
+
 QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
 QEMU_CFLAGS += $(VNC_SASL_CFLAGS)
 QEMU_CFLAGS += $(VNC_JPEG_CFLAGS)
default-configs/i386-softmmu.mak +1 -0
index 55589fa..ee69a0a 100644
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
 CONFIG_SOUND=y
 CONFIG_HPET=y
 CONFIG_APPLESMC=y
+CONFIG_HYPERV=y
default-configs/x86_64-softmmu.mak +0 -0
index 8895028..35b1c00 100644

default-configs/x86_64-softmmu.mak CONFIG_PIIX_PCI=y · line 24

Quoted 4 lines
default-configs/x86_64-softmmu.mak +1 -0
@@ -21,3 +21,4 @@ CONFIG_PIIX_PCI=y
 CONFIG_SOUND=y
 CONFIG_HPET=y
 CONFIG_APPLESMC=y
+CONFIG_HYPERV=y

Useless config options (that do not work anyway as Kevin noted).

Quoted 70 lines
target-i386/cpuid.c +14 -0
index 1e8bcff..50b2d0e 100644
@@ -27,6 +27,8 @@
 #include "qemu-option.h"
 #include "qemu-config.h"
 
+#include "hyperv.h"
+
 /* feature flags taken from "Intel Processor Identification and the CPUID
  * Instruction" and AMD's "CPUID Specification".  In cases of disagreement
  * between feature naming conventions, aliases may be added.
@@ -716,6 +718,14 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
                     goto error;
                 }
                 x86_cpu_def->tsc_khz = tsc_freq / 1000;
+            } else if (!strcmp(featurestr, "hv_spinlocks")) {
+               char* err;
+               numvalue = strtoul(val, &err, 0);
+               if (!*val || *err) {
+                    fprintf(stderr, "bad numerical value %s\n", val);
+                    goto error;
+                }
+                hyperv_set_spinlock_retries(numvalue);
             } else {
                 fprintf(stderr, "unrecognized feature %s\n", featurestr);
                 goto error;
@@ -724,6 +734,10 @@ static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model)
             check_cpuid = 1;
         } else if (!strcmp(featurestr, "enforce")) {
             check_cpuid = enforce_cpuid = 1;
+        } else if (!strcmp(featurestr, "hv_relaxed")) {
+            hyperv_set_relaxed_timing(1);
+        } else if (!strcmp(featurestr, "hv_vapic")) {
+            hyperv_set_vapic_recommended(1);            
         } else {
             fprintf(stderr, "feature string `%s' not in format (+feature|-feature|feature=xyz)\n", featurestr);
             goto error;
target-i386/hyperv.c new file +25 -0
new file mode 100644
index 0000000..bed859e
@@ -0,0 +1,69 @@
+/*
+ * QEMU Hyper-V support
+ *
+ * Copyright Red Hat, Inc. 2011
+ *
+ * Author: Vadim Rozenfeld     <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#include "hyperv.h"
+
+static int hyperv_vapic;
+static int hyperv_relaxed_timing;
+static int hyperv_spinlock_attempts = HYPERV_SPINLOCK_NEVER_RETRY;
+
+void hyperv_set_vapic_recommended(int val)
+{
+    hyperv_vapic = val;
+}
+
+void hyperv_set_relaxed_timing(int val)
+{

target-i386/hyperv.c line 35

Quoted 10 lines
target-i386/hyperv.c new file +10 -0
+    hyperv_relaxed_timing = val;
+}
+
+void hyperv_set_spinlock_retries(int val)
+{
+    hyperv_spinlock_attempts = val;
+    if (hyperv_spinlock_attempts < 0xFFF) {
+        hyperv_spinlock_attempts = 0xFFF;
+    }
+}

hyperv_enabled_x(bool enable) would be nicer.

Quoted 8 lines
target-i386/hyperv.c new file +8 -0
+
+int hyperv_enabled(void)
+{
+    return hyperv_hypercall_available() || hyperv_get_relaxed_timing();
+}
+
+int hyperv_hypercall_available(void)
+{

target-i386/hyperv.c line 53

Quoted 10 lines
target-i386/hyperv.c new file +10 -0
+    if (hyperv_vapic ||
+        (hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_RETRY)) {
+      return 1;
+    }
+    return 0;
+}
+
+int hyperv_get_vapic_recommended(void)
+{
+#ifdef KVM_CAP_IRQCHIP

This is x86-only code, and x86 supports KVM_CAP_IRQCHIP. So drop this #ifdef.

Quoted 5 lines
target-i386/hyperv.c new file +5 -0
+    return hyperv_vapic;
+#else
+    return 0;
+#endif
+}

target-i386/hyperv.c line 68

Quoted 10 lines
target-i386/hyperv.c new file +10 -0
+
+int hyperv_get_relaxed_timing(void)
+{
+    return hyperv_relaxed_timing;
+}
+
+int hyperv_get_spinlock_retries(void)
+{
+    return hyperv_spinlock_attempts;
+}

bool hyperv_vapic_recommend(void), hyperv_relaxed_timing_enabled etc. "get" implies to me that there is actual a non-boolean value returned which is not.

Quoted 27 lines
target-i386/hyperv.c new file +1 -0
+
target-i386/hyperv.h new file +20 -0
new file mode 100644
index 0000000..1ea5e99
@@ -0,0 +1,30 @@
+/*
+ * QEMU Hyper-V support
+ *
+ * Copyright Red Hat, Inc. 2011
+ *
+ * Author: Vadim Rozenfeld     <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ *
+ */
+
+#ifndef QEMU_HW_HYPERV_H
+#define QEMU_HW_HYPERV_H 1
+
+#include <asm/hyperv.h>
+
+#define HYPERV_SPINLOCK_NEVER_RETRY             0xFFFFFFFF
+
+void hyperv_set_vapic_recommended(int val);

target-i386/hyperv.h line 30

Quoted 10 lines
target-i386/hyperv.h new file +10 -0
+void hyperv_set_relaxed_timing(int val);
+void hyperv_set_spinlock_retries(int val);
+
+int hyperv_enabled(void);
+int hyperv_hypercall_available(void);
+int hyperv_get_vapic_recommended(void);
+int hyperv_get_relaxed_timing(void);
+int hyperv_get_spinlock_retries(void);
+
+#endif /* QEMU_HW_HYPERV_H */

Looks good otherwise.

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
maintainer
#5 lore raw

Re: [PATCH RFC v1 2/2] hyper-v: initialize Hyper-V CPUID leafs.

In reply to Vadim Rozenfeld
Quoted 6 lines · Vadim Rozenfeld
target-i386/kvm.c +0 -1
@@ -379,11 +380,16 @@ int kvm_arch_init_vcpu(CPUState *env)
      cpuid_i = 0;
 
      /* Paravirtualization CPUIDs */
-    memcpy(signature, "KVMKVMKVM\0\0\0", 12);
      c =&cpuid_data.entries[cpuid_i++];

target-i386/kvm.c int kvm_arch_init_vcpu(CPUState *env) · line 392

Quoted 10 lines
target-i386/kvm.c +7 -1
      memset(c, 0, sizeof(*c));
      c->function = KVM_CPUID_SIGNATURE;
-    c->eax = 0;
+    if (!hyperv_enabled()) {
+        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
+        c->eax = 0;
+    } else {
+        memcpy(signature, "Microsoft Hv", 12);
+        c->eax = HYPERV_CPUID_MIN;
+    }

Even not counting that hyper-v support should IMHO not be in KVM-specific code, I still think this shouldn't remove KVM leaves completely but rather move them to 0x40000100. The KVM paravirtualization code then can similarly probe with 0x100 stride up to 0x40001000. This is what was done for Xen, and it allows to enable enlightenments independent of whether the guest is Linux or Windows.

However, let's get a third opinion---Avi, what do you think?

Paolo

#6 lore raw

Re: [PATCH RFC v1 2/2] hyper-v: initialize Hyper-V CPUID leafs.

Quoted 25 lines · Paolo Bonzini
Quoted 6 lines · Vadim Rozenfeld
target-i386/kvm.c +0 -1
@@ -379,11 +380,16 @@ int kvm_arch_init_vcpu(CPUState *env)
      cpuid_i = 0;
 
      /* Paravirtualization CPUIDs */
-    memcpy(signature, "KVMKVMKVM\0\0\0", 12);
      c =&cpuid_data.entries[cpuid_i++];

target-i386/kvm.c int kvm_arch_init_vcpu(CPUState *env) · line 392

Quoted 10 lines
target-i386/kvm.c +7 -1
      memset(c, 0, sizeof(*c));
      c->function = KVM_CPUID_SIGNATURE;
-    c->eax = 0;
+    if (!hyperv_enabled()) {
+        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
+        c->eax = 0;
+    } else {
+        memcpy(signature, "Microsoft Hv", 12);
+        c->eax = HYPERV_CPUID_MIN;
+    }

Even not counting that hyper-v support should IMHO not be in KVM-specific code, I still think this shouldn't remove KVM leaves completely but rather move them to 0x40000100. The KVM paravirtualization code then can similarly probe with 0x100 stride up to 0x40001000. This is what was done for Xen, and it allows to enable enlightenments independent of whether the guest is Linux or Windows.

Quoted 1 line

However, let's get a third opinion---Avi, what do you think?

I agree with you, especially as this already works for Xen.

Note it doesn't completely solve the issue (so we have two interfaces, which is the preferred one?), but it's better than nothing.

Signature · 1 line
error compiling committee.c: too many arguments to function
maintainer
#7 lore raw

Re: [PATCH RFC v1 2/2] hyper-v: initialize Hyper-V CPUID leafs.

Quoted 7 lines · Avi Kivity
Quoted 7 lines

Even not counting that hyper-v support should IMHO not be in KVM-specific code, I still think this shouldn't remove KVM leaves completely but rather move them to 0x40000100. The KVM paravirtualization code then can similarly probe with 0x100 stride up to 0x40001000. This is what was done for Xen, and it allows to enable enlightenments independent of whether the guest is Linux or Windows.

Quoted 6 lines
Quoted 1 line

However, let's get a third opinion---Avi, what do you think?

I agree with you, especially as this already works for Xen.

Note it doesn't completely solve the issue (so we have two interfaces, which is the preferred one?), but it's better than nothing.

Windows doesn't look beyond 0x40000000, so Hyper-V stays there and KVM has to shift. So MS solved that part for us. :)

Paolo

#8 lore raw

Re: [PATCH RFC v1 2/2] hyper-v: initialize Hyper-V CPUID leafs.

Quoted 11 lines · Paolo Bonzini
Quoted 10 lines · Avi Kivity
Quoted 5 lines

Even not counting that hyper-v support should IMHO not be in KVM-specific code, I still think this shouldn't remove KVM leaves completely but rather move them to 0x40000100. The KVM paravirtualization code then can similarly probe with 0x100 stride up to 0x40001000. This is what was done for Xen, and it allows to

enable

Quoted 3 lines

enlightenments independent of whether the guest is Linux or Windows.

However, let's get a third opinion---Avi, what do you think?

Quoted 7 lines
Quoted 4 lines

I agree with you, especially as this already works for Xen.

Note it doesn't completely solve the issue (so we have two interfaces, which is the preferred one?), but it's better than nothing.

Windows doesn't look beyond 0x40000000, so Hyper-V stays there and KVM has to shift. So MS solved that part for us. :)

I mean, suppose Linux finds hyper-v at 000 and kvm at 100. Is it kvm impersonating hyper-v, or a future hyper-v impersonating kvm, or something else (TAINT_CRAP?) impersonating both?

Signature · 1 line
error compiling committee.c: too many arguments to function