Skip to contentSkip to conversation

Allow changing of Hypervisor CPUIDs.

PATCH Applied Don Slutz 3 participants 21 messages Sep 22, 2012 – Sep 24, 2012 KVM

v5 of 7 Applied Latest is v7 →

lore
Share & tools
lore

Don Slutz

author
#0 lore raw

v5 cover Allow changing of Hypervisor CPUIDs.

Also known as Paravirtualization CPUIDs.

This is primarily done so that the guest will think it is running under vmware when hypervisor-vendor=vmware is specified as a property of a cpu.

This depends on:

http://lists.gnu.org/archive/html/qemu-devel/2012-09/msg01400.html

As far as I know it is #4. It depends on (1) and (2) and (3).

This change is based on:

Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

Changes from v4 to v5:
Undo kvm_clock2 change.
Add cpuid_hv_level_set; cpuid_hv_level == 0 is now valid.
Add cpuid_hv_vendor_set; the null string is now valid.
Handle kvm and cpuid_hv_level == 0. hypervisor-vendor=kvm,hypervisor-level=0 and hypervisor-level=0,hypervisor-vendor=kvm
now do the same thing.

Changes from v3 to v4:
Added CPUID_HV_LEVEL_HYPERV, CPUID_HV_LEVEL_KVM. Added CPUID_HV_VENDOR_HYPERV.
Added hyperv as known hypservisor-vendor. Allow hypervisor-level to be 0.

Changes from v2 to v3:
Clean post to qemu-devel.

Changes from v1 to v2:

1) Added 1/4 from http://lists.gnu.org/archive/html/qemu-devel/2012-08/msg05153.html

Because Fred is changing jobs and so will not be pushing to get this in. It needed to be rebased, And I needed it to complete the testing of this change.

2) Added 2/4 because of the re-work I needed a way to clear all KVM bits,

3) The rework of v1. Make it fit into the object model re-work of cpu.c for x86.

4) Added 3/4 -- The split out of the code that is not needed for accel=kvm.

Changes from v2 to v3:

Marcelo Tosatti:
Its one big patch, better split in logically correlated patches (with better changelog). This would help reviewers.

So split 3 and 4 into 3 to 17. More info in change log. No code change.

Don Slutz (17):
target-i386: Allow tsc-frequency to be larger then 2.147G
target-i386: Add missing kvm bits.
target-i386: Add Hypervisor level.
target-i386: Add cpu object access routines for Hypervisor level.
target-i386: Add cpu object access routines for Hypervisor level.
target-i386: Use Hypervisor level in -machine pc,accel=kvm.
target-i386: Use Hypervisor level in -machine pc,accel=tcg.
target-i386: Add Hypervisor vendor.
target-i386: Add cpu object access routines for Hypervisor vendor.
target-i386: Use Hypervisor vendor in -machine pc,accel=kvm.
target-i386: Use Hypervisor vendor in -machine pc,accel=tcg.
target-i386: Add some known names to Hypervisor vendor.
target-i386: Add optional Hypervisor leaf extra.
target-i386: Add cpu object access routines for Hypervisor leaf
extra.
target-i386: Add setting of Hypervisor leaf extra for known vmare4.
target-i386: Use Hypervisor leaf extra in -machine pc,accel=kvm.
target-i386: Use Hypervisor leaf extra in -machine pc,accel=tcg.

 target-i386/cpu.c |  285 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 target-i386/cpu.h |   34 +++++++
 target-i386/kvm.c |   33 +++++-
 3 files changed, 341 insertions(+), 11 deletions(-)
author
#1 lore raw

PATCH v5 1/17 target-i386: Allow tsc-frequency to be larger then 2.147G

The check using INT_MAX (2147483647) is wrong in this case.

---
 target-i386/cpu.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-i386/cpu.c +1 -1
index af50a8f..0313cf5 100644
@@ -1146,7 +1146,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
 {
     X86CPU *cpu = X86_CPU(obj);
     const int64_t min = 0;
-    const int64_t max = INT_MAX;
+    const int64_t max = INT64_MAX;
     int64_t value;
 
     visit_type_freq(v, &value, name, errp);
Signature · 1 line
1.7.1
author
#3 lore raw

PATCH v5 2/17 target-i386: Add missing kvm bits.

In reply to Don Slutz

Fix duplicate name (kvmclock => kvm_clock2) also.

---
 target-i386/cpu.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
target-i386/cpu.c +8 -4
index 0313cf5..25ca986 100644
@@ -87,10 +87,14 @@ static const char *ext3_feature_name[] = {
 };
 
 static const char *kvm_feature_name[] = {
-    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock", "kvm_asyncpf", NULL, "kvm_pv_eoi", NULL,
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+    "kvmclock", "kvm_nopiodelay", "kvm_mmu", "kvmclock",
+    "kvm_asyncpf", "kvm_steal_time", "kvm_pv_eoi", NULL,
+    NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL,
+    "kvm_clock_stable", NULL, NULL, NULL,
+    NULL, NULL, NULL, NULL,
 };
 
 static const char *svm_feature_name[] = {
Signature · 1 line
1.7.1
author
#4 lore raw

PATCH v5 3/17 target-i386: Add Hypervisor level.

In reply to Don Slutz

Also known as Paravirtualization level or maximim cpuid function present in this leaf. This is just the EAX value for 0x40000000.

QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).

This is based on:

Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

QEMU has the value HYPERV_CPUID_MIN defined.

---
 target-i386/cpu.h |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
target-i386/cpu.h +3 -0
index 5265c5a..1899f69 100644
@@ -777,11 +777,14 @@ typedef struct CPUX86State {
     uint32_t cpuid_ext3_features;
     uint32_t cpuid_apic_id;
     bool cpuid_vendor_override;
+    bool cpuid_hv_level_set;
     /* Store the results of Centaur's CPUID instructions */
     uint32_t cpuid_xlevel2;
     uint32_t cpuid_ext4_features;
     /* Flags from CPUID[EAX=7,ECX=0].EBX */
     uint32_t cpuid_7_0_ebx;
+    /* Hypervisor CPUIDs */
+    uint32_t cpuid_hv_level;
 
     /* MTRRs */
     uint64_t mtrr_fixed[11];
Signature · 1 line
1.7.1
author
#5 lore raw

PATCH v5 4/17 target-i386: Add cpu object access routines for Hypervisor level.

In reply to Don Slutz

These are modeled after x86_cpuid_get_xlevel and x86_cpuid_set_xlevel.

---
 target-i386/cpu.c |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
target-i386/cpu.c +29 -0
index 25ca986..7b31de9 100644
@@ -1166,6 +1166,32 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
     cpu->env.tsc_khz = value / 1000;
 }
 
+static void x86_cpuid_get_hv_level(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+
+    visit_type_uint32(v, &cpu->env.cpuid_hv_level, name, errp);
+}
+
+static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+    uint32_t value;
+
+    visit_type_uint32(v, &value, name, errp);
+    if (error_is_set(errp)) {
+        return;
+    }
+
+    if ((value != 0) && (value < 0x40000000)) {
+        value += 0x40000000;
+    }
+    cpu->env.cpuid_hv_level = value;
+    cpu->env.cpuid_hv_level_set = true;
+}
+
 #if !defined(CONFIG_USER_ONLY)
 static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
                                  const char *name, Error **errp)
@@ -2061,6 +2087,9 @@ static void x86_cpu_initfn(Object *obj)
     object_property_add(obj, "enforce", "bool",
                         x86_cpuid_get_enforce,
                         x86_cpuid_set_enforce, NULL, NULL, NULL);
+    object_property_add(obj, "hypervisor-level", "int",
+                        x86_cpuid_get_hv_level,
+                        x86_cpuid_set_hv_level, NULL, NULL, NULL);
 #if !defined(CONFIG_USER_ONLY)
     object_property_add(obj, "hv_spinlocks", "int",
                         x86_get_hv_spinlocks,
Signature · 1 line
1.7.1
author
#6 lore raw

PATCH v5 5/17 target-i386: Add cpu object access routines for Hypervisor level.

In reply to Don Slutz

These are modeled after x86_cpuid_get_xlevel and x86_cpuid_set_xlevel.

---
 target-i386/cpu.c |    8 ++++++++
 target-i386/cpu.h |    2 ++
 2 files changed, 10 insertions(+), 0 deletions(-)
target-i386/cpu.c +8 -0
index 7b31de9..e5deca2 100644
@@ -1193,6 +1193,11 @@ static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque,
 }
 
 #if !defined(CONFIG_USER_ONLY)
+static void x86_set_hyperv(Object *obj, Error **errp)
+{
+    object_property_set_int(obj, CPUID_HV_LEVEL_HYPERV, "hypervisor-level", errp);
+}
+
 static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
                                  const char *name, Error **errp)
 {
@@ -1215,6 +1220,7 @@ static void x86_set_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
         return;
     }
     hyperv_set_spinlock_retries(value);
+    x86_set_hyperv(obj, errp);
 }
 
 static void x86_get_hv_relaxed(Object *obj, Visitor *v, void *opaque,
@@ -1235,6 +1241,7 @@ static void x86_set_hv_relaxed(Object *obj, Visitor *v, void *opaque,
         return;
     }
     hyperv_enable_relaxed_timing(value);
+    x86_set_hyperv(obj, errp);
 }
 
 static void x86_get_hv_vapic(Object *obj, Visitor *v, void *opaque,
@@ -1255,6 +1262,7 @@ static void x86_set_hv_vapic(Object *obj, Visitor *v, void *opaque,
         return;
     }
     hyperv_enable_vapic_recommended(value);
+    x86_set_hyperv(obj, errp);
 }
 #endif
 
target-i386/cpu.h +2 -0
index 1899f69..3152a4e 100644
@@ -488,6 +488,8 @@
 
 #define CPUID_VENDOR_VIA   "CentaurHauls"
 
+#define CPUID_HV_LEVEL_HYPERV  0x40000005
+
 #define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX     (1 << 0) /* enumeration supported */
 
Signature · 1 line
1.7.1
author
#7 lore raw

PATCH v5 6/17 target-i386: Use Hypervisor level in -machine pc,accel=kvm.

In reply to Don Slutz

Also known as Paravirtualization level.

This change is based on:

Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).

---
 target-i386/kvm.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
target-i386/kvm.c +2 -2
index 895d848..8462c75 100644
@@ -389,12 +389,12 @@ int kvm_arch_init_vcpu(CPUX86State *env)
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
     c->function = KVM_CPUID_SIGNATURE;
-    if (!hyperv_enabled()) {
+    if (!env->cpuid_hv_level_set) {
         memcpy(signature, "KVMKVMKVM\0\0\0", 12);
         c->eax = 0;
     } else {
         memcpy(signature, "Microsoft Hv", 12);
-        c->eax = HYPERV_CPUID_MIN;
+        c->eax = env->cpuid_hv_level;
     }
     c->ebx = signature[0];
     c->ecx = signature[1];
Signature · 1 line
1.7.1
author
#8 lore raw

PATCH v5 7/17 target-i386: Use Hypervisor level in -machine pc,accel=tcg.

In reply to Don Slutz

Also known as Paravirtualization level.

This change is based on:

Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

QEMU knows this as KVM_CPUID_SIGNATURE (0x40000000) in kvm on linux.

This does not provide vendor support in tcg yet.

---
 target-i386/cpu.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)
target-i386/cpu.c +27 -0
index e5deca2..bf6faed 100644
@@ -1650,6 +1650,21 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                 index =  env->cpuid_xlevel;
             }
         }
+    } else if (index & 0x40000000) {
+        if (env->cpuid_hv_level_set) {
+            uint32_t real_level = env->cpuid_hv_level;
+
+            /* Handle Hypervisor CPUIDs */
+            if (real_level < 0x40000000) {
+                real_level = 0x40000000;
+            }
+            if (index > real_level) {
+                index = real_level;
+            }
+        } else {
+            if (index > env->cpuid_level)
+                index = env->cpuid_level;
+        }
     } else {
         if (index > env->cpuid_level)
             index = env->cpuid_level;
@@ -1788,6 +1803,18 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
             *edx = 0;
         }
         break;
+    case 0x40000000:
+        *eax = env->cpuid_hv_level;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
+    case 0x40000001:
+        *eax = env->cpuid_kvm_features;
+        *ebx = 0;
+        *ecx = 0;
+        *edx = 0;
+        break;
     case 0x80000000:
         *eax = env->cpuid_xlevel;
         *ebx = env->cpuid_vendor1;
Signature · 1 line
1.7.1
author
#9 lore raw

PATCH v5 8/17 target-i386: Add Hypervisor vendor.

In reply to Don Slutz

Also known as Paravirtualization vendor.
This is EBX, ECX, EDX data for 0x40000000.

QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).

This is based on:

Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

---
 target-i386/cpu.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
target-i386/cpu.h +4 -0
index 3152a4e..11730b2 100644
@@ -780,6 +780,7 @@ typedef struct CPUX86State {
     uint32_t cpuid_apic_id;
     bool cpuid_vendor_override;
     bool cpuid_hv_level_set;
+    bool cpuid_hv_vendor_set;
     /* Store the results of Centaur's CPUID instructions */
     uint32_t cpuid_xlevel2;
     uint32_t cpuid_ext4_features;
@@ -787,6 +788,9 @@ typedef struct CPUX86State {
     uint32_t cpuid_7_0_ebx;
     /* Hypervisor CPUIDs */
     uint32_t cpuid_hv_level;
+    uint32_t cpuid_hv_vendor1;
+    uint32_t cpuid_hv_vendor2;
+    uint32_t cpuid_hv_vendor3;
 
     /* MTRRs */
     uint64_t mtrr_fixed[11];
Signature · 1 line
1.7.1
author
#10 lore raw

PATCH v5 9/17 target-i386: Add cpu object access routines for Hypervisor vendor.

In reply to Don Slutz

These are modeled after x86_cpuid_set_vendor and x86_cpuid_get_vendor.
Since kvm's vendor is shorter, the test for correct size is removed and zero padding is added.

Set Microsoft's Vendor now that we can. Value defined in:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx
And matches want is in target-i386/kvm.c

---
 target-i386/cpu.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 target-i386/cpu.h |    2 ++
 2 files changed, 47 insertions(+), 0 deletions(-)
target-i386/cpu.c +45 -0
index bf6faed..ab65594 100644
@@ -1192,10 +1192,52 @@ static void x86_cpuid_set_hv_level(Object *obj, Visitor *v, void *opaque,
     cpu->env.cpuid_hv_level_set = true;
 }
 
+static char *x86_cpuid_get_hv_vendor(Object *obj, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+    CPUX86State *env = &cpu->env;
+    char *value;
+    int i;
+
+    value = (char *)g_malloc(CPUID_VENDOR_SZ + 1);
+    for (i = 0; i < 4; i++) {
+        value[i + 0] = env->cpuid_hv_vendor1 >> (8 * i);
+        value[i + 4] = env->cpuid_hv_vendor2 >> (8 * i);
+        value[i + 8] = env->cpuid_hv_vendor3 >> (8 * i);
+    }
+    value[CPUID_VENDOR_SZ] = '\0';
+
+    return value;
+}
+
+static void x86_cpuid_set_hv_vendor(Object *obj, const char *value,
+                                     Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+    CPUX86State *env = &cpu->env;
+    int i;
+    char adj_value[CPUID_VENDOR_SZ + 1];
+
+    memset(adj_value, 0, sizeof(adj_value));
+
+    pstrcpy(adj_value, sizeof(adj_value), value);
+
+    env->cpuid_hv_vendor1 = 0;
+    env->cpuid_hv_vendor2 = 0;
+    env->cpuid_hv_vendor3 = 0;
+    for (i = 0; i < 4; i++) {
+        env->cpuid_hv_vendor1 |= ((uint8_t)adj_value[i + 0]) << (8 * i);
+        env->cpuid_hv_vendor2 |= ((uint8_t)adj_value[i + 4]) << (8 * i);
+        env->cpuid_hv_vendor3 |= ((uint8_t)adj_value[i + 8]) << (8 * i);
+    }
+    env->cpuid_hv_vendor_set = true;
+}
+
 #if !defined(CONFIG_USER_ONLY)
 static void x86_set_hyperv(Object *obj, Error **errp)
 {
     object_property_set_int(obj, CPUID_HV_LEVEL_HYPERV, "hypervisor-level", errp);
+    object_property_set_str(obj, CPUID_HV_VENDOR_HYPERV, "hypervisor-vendor", errp);
 }
 
 static void x86_get_hv_spinlocks(Object *obj, Visitor *v, void *opaque,
@@ -2125,6 +2167,9 @@ static void x86_cpu_initfn(Object *obj)
     object_property_add(obj, "hypervisor-level", "int",
                         x86_cpuid_get_hv_level,
                         x86_cpuid_set_hv_level, NULL, NULL, NULL);
+    object_property_add_str(obj, "hypervisor-vendor",
+                            x86_cpuid_get_hv_vendor,
+                            x86_cpuid_set_hv_vendor, NULL);
 #if !defined(CONFIG_USER_ONLY)
     object_property_add(obj, "hv_spinlocks", "int",
                         x86_get_hv_spinlocks,
target-i386/cpu.h +2 -0
index 11730b2..eb6aa4a 100644
@@ -488,6 +488,8 @@
 
 #define CPUID_VENDOR_VIA   "CentaurHauls"
 
+#define CPUID_HV_VENDOR_HYPERV "Microsoft Hv"
+
 #define CPUID_HV_LEVEL_HYPERV  0x40000005
 
 #define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
Signature · 1 line
1.7.1
author
#11 lore raw

PATCH v5 10/17 target-i386: Use Hypervisor vendor in -machine pc,accel=kvm.

In reply to Don Slutz

Also known as Paravirtualization vendor.

This change is based on:

Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

---
 target-i386/kvm.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)
target-i386/kvm.c +7 -5
index 8462c75..f8a5177 100644
@@ -389,16 +389,18 @@ int kvm_arch_init_vcpu(CPUX86State *env)
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
     c->function = KVM_CPUID_SIGNATURE;
-    if (!env->cpuid_hv_level_set) {
+    if (!env->cpuid_hv_level_set && !env->cpuid_hv_vendor_set) {
         memcpy(signature, "KVMKVMKVM\0\0\0", 12);
         c->eax = 0;
+        c->ebx = signature[0];
+        c->ecx = signature[1];
+        c->edx = signature[2];
     } else {
-        memcpy(signature, "Microsoft Hv", 12);
         c->eax = env->cpuid_hv_level;
+        c->ebx = env->cpuid_hv_vendor1;
+        c->ecx = env->cpuid_hv_vendor2;
+        c->edx = env->cpuid_hv_vendor3;
     }
-    c->ebx = signature[0];
-    c->ecx = signature[1];
-    c->edx = signature[2];
 
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
Signature · 1 line
1.7.1
author
#12 lore raw

PATCH v5 11/17 target-i386: Use Hypervisor vendor in -machine pc,accel=tcg.

In reply to Don Slutz

Also known as Paravirtualization vendor.

This change is based on:

Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html
This is where the 0 is the same as 0x40000001 is defined.

VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

---
 target-i386/cpu.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
target-i386/cpu.c +4 -4
index ab65594..bfe7b27 100644
@@ -1693,7 +1693,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
             }
         }
     } else if (index & 0x40000000) {
-        if (env->cpuid_hv_level_set) {
+        if (env->cpuid_hv_level_set || env->cpuid_hv_vendor_set) {
             uint32_t real_level = env->cpuid_hv_level;
 
             /* Handle Hypervisor CPUIDs */
@@ -1847,9 +1847,9 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         break;
     case 0x40000000:
         *eax = env->cpuid_hv_level;
-        *ebx = 0;
-        *ecx = 0;
-        *edx = 0;
+        *ebx = env->cpuid_hv_vendor1;
+        *ecx = env->cpuid_hv_vendor2;
+        *edx = env->cpuid_hv_vendor3;
         break;
     case 0x40000001:
         *eax = env->cpuid_kvm_features;
Signature · 1 line
1.7.1
author
#13 lore raw

PATCH v5 12/17 target-i386: Add some known names to Hypervisor vendor.

In reply to Don Slutz
---
 target-i386/cpu.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 target-i386/cpu.h |   19 +++++++++++++++++
 2 files changed, 74 insertions(+), 2 deletions(-)
target-i386/cpu.c +55 -2
index bfe7b27..478b671 100644
@@ -1207,6 +1207,24 @@ static char *x86_cpuid_get_hv_vendor(Object *obj, Error **errp)
     }
     value[CPUID_VENDOR_SZ] = '\0';
 
+    /* Convert known names */
+    if (!strcmp(value, CPUID_HV_VENDOR_HYPERV) &&
+               env->cpuid_hv_level == CPUID_HV_LEVEL_HYPERV) {
+        pstrcpy(value, sizeof(value), "hyperv");
+    } else if (!strcmp(value, CPUID_HV_VENDOR_VMWARE)) {
+        if (env->cpuid_hv_level == CPUID_HV_LEVEL_VMWARE_4) {
+            pstrcpy(value, sizeof(value), "vmware4");
+        } else if (env->cpuid_hv_level == CPUID_HV_LEVEL_VMWARE_3) {
+            pstrcpy(value, sizeof(value), "vmware3");
+        }
+    } else if (!strcmp(value, CPUID_HV_VENDOR_XEN) &&
+               env->cpuid_hv_level == CPUID_HV_LEVEL_XEN) {
+        pstrcpy(value, sizeof(value), "xen");
+    } else if (!strcmp(value, CPUID_HV_VENDOR_KVM) &&
+               (env->cpuid_hv_level == 0 ||
+                env->cpuid_hv_level == CPUID_HV_LEVEL_KVM)) {
+        pstrcpy(value, sizeof(value), "kvm");
+    }
     return value;
 }
 
@@ -1220,7 +1238,35 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const char *value,
 
     memset(adj_value, 0, sizeof(adj_value));
 
-    pstrcpy(adj_value, sizeof(adj_value), value);
+    /* Convert known names */
+    if (!strcmp(value, "hyperv")) {
+        if (!env->cpuid_hv_level_set) {
+            env->cpuid_hv_level = CPUID_HV_LEVEL_HYPERV;
+        }
+        pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_HYPERV);
+    } else if (!strcmp(value, "vmware") || !strcmp(value, "vmware4")) {
+        if (!env->cpuid_hv_level_set) {
+            env->cpuid_hv_level = CPUID_HV_LEVEL_VMWARE_4;
+        }
+        pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_VMWARE);
+    } else if (!strcmp(value, "vmware3")) {
+        if (!env->cpuid_hv_level_set) {
+            env->cpuid_hv_level = CPUID_HV_LEVEL_VMWARE_3;
+        }
+        pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_VMWARE);
+    } else if (!strcmp(value, "xen")) {
+        if (!env->cpuid_hv_level_set) {
+            env->cpuid_hv_level = CPUID_HV_LEVEL_XEN;
+        }
+        pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_XEN);
+    } else if (!strcmp(value, "kvm")) {
+        if (!env->cpuid_hv_level_set) {
+            env->cpuid_hv_level = CPUID_HV_LEVEL_KVM;
+        }
+        pstrcpy(adj_value, sizeof(adj_value), CPUID_HV_VENDOR_KVM);
+    } else {
+        pstrcpy(adj_value, sizeof(adj_value), value);
+    }
 
     env->cpuid_hv_vendor1 = 0;
     env->cpuid_hv_vendor2 = 0;
@@ -1698,7 +1744,14 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
 
             /* Handle Hypervisor CPUIDs */
             if (real_level < 0x40000000) {
-                real_level = 0x40000000;
+                if (env->cpuid_hv_vendor1 == CPUID_HV_VENDOR_KVM_1 &&
+                    env->cpuid_hv_vendor2 == CPUID_HV_VENDOR_KVM_2 &&
+                    env->cpuid_hv_vendor3 == CPUID_HV_VENDOR_KVM_3 &&
+                    real_level == 0) {
+                    real_level = CPUID_HV_LEVEL_KVM;
+                } else {
+                    real_level = 0x40000000;
+                }
             }
             if (index > real_level) {
                 index = real_level;
target-i386/cpu.h +19 -0
index eb6aa4a..ebb3498 100644
@@ -490,8 +490,27 @@
 
 #define CPUID_HV_VENDOR_HYPERV "Microsoft Hv"
 
+#define CPUID_HV_VENDOR_VMWARE_1 0x61774d56 /* "VMwa" */
+#define CPUID_HV_VENDOR_VMWARE_2 0x4d566572 /* "reVM" */
+#define CPUID_HV_VENDOR_VMWARE_3 0x65726177 /* "ware" */
+#define CPUID_HV_VENDOR_VMWARE "VMwareVMware"
+
+#define CPUID_HV_VENDOR_XEN "XenVMMXenVMM"
+
+#define CPUID_HV_VENDOR_KVM_1 0x4b4d564b /* "KVMK" */
+#define CPUID_HV_VENDOR_KVM_2 0x564b4d56 /* "VMKV" */
+#define CPUID_HV_VENDOR_KVM_3 0x0000004d /* "M\0\0\0" */
+#define CPUID_HV_VENDOR_KVM "KVMKVMKVM"
+
 #define CPUID_HV_LEVEL_HYPERV  0x40000005
 
+#define CPUID_HV_LEVEL_VMWARE_3 0x40000002
+#define CPUID_HV_LEVEL_VMWARE_4 0x40000010
+
+#define CPUID_HV_LEVEL_XEN  0x40000002
+
+#define CPUID_HV_LEVEL_KVM  0x40000001
+
 #define CPUID_MWAIT_IBE     (1 << 1) /* Interrupts can exit capability */
 #define CPUID_MWAIT_EMX     (1 << 0) /* enumeration supported */
 
Signature · 1 line
1.7.1
author
#14 lore raw

PATCH v5 13/17 target-i386: Add optional Hypervisor leaf extra.

In reply to Don Slutz
---
 target-i386/cpu.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
target-i386/cpu.h +4 -0
index ebb3498..254ddef 100644
@@ -812,6 +812,10 @@ typedef struct CPUX86State {
     uint32_t cpuid_hv_vendor1;
     uint32_t cpuid_hv_vendor2;
     uint32_t cpuid_hv_vendor3;
+    /* VMware extra data */
+    uint32_t cpuid_hv_extra;
+    uint32_t cpuid_hv_extra_a;
+    uint32_t cpuid_hv_extra_b;
 
     /* MTRRs */
     uint64_t mtrr_fixed[11];
Signature · 1 line
1.7.1
author
#15 lore raw

PATCH v5 14/17 target-i386: Add cpu object access routines for Hypervisor leaf extra.

In reply to Don Slutz
---
 target-i386/cpu.c |   66 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)
target-i386/cpu.c +66 -0
index 478b671..2423090 100644
@@ -1279,6 +1279,63 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const char *value,
     env->cpuid_hv_vendor_set = true;
 }
 
+static void x86_cpuid_get_hv_extra(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+
+    visit_type_uint32(v, &cpu->env.cpuid_hv_extra, name, errp);
+}
+
+static void x86_cpuid_set_hv_extra(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+    uint32_t value;
+
+    visit_type_uint32(v, &value, name, errp);
+    if (error_is_set(errp)) {
+        return;
+    }
+
+    if ((value != 0) && (value < 0x40000000)) {
+        value += 0x40000000;
+    }
+    cpu->env.cpuid_hv_extra = value;
+}
+
+static void x86_cpuid_get_hv_extra_a(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+
+    visit_type_uint32(v, &cpu->env.cpuid_hv_extra_a, name, errp);
+}
+
+static void x86_cpuid_set_hv_extra_a(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+
+    visit_type_uint32(v, &cpu->env.cpuid_hv_extra_a, name, errp);
+}
+
+static void x86_cpuid_get_hv_extra_b(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+
+    visit_type_uint32(v, &cpu->env.cpuid_hv_extra_b, name, errp);
+}
+
+static void x86_cpuid_set_hv_extra_b(Object *obj, Visitor *v, void *opaque,
+                                const char *name, Error **errp)
+{
+    X86CPU *cpu = X86_CPU(obj);
+
+    visit_type_uint32(v, &cpu->env.cpuid_hv_extra_b, name, errp);
+}
+
 #if !defined(CONFIG_USER_ONLY)
 static void x86_set_hyperv(Object *obj, Error **errp)
 {
@@ -2223,6 +2280,15 @@ static void x86_cpu_initfn(Object *obj)
     object_property_add_str(obj, "hypervisor-vendor",
                             x86_cpuid_get_hv_vendor,
                             x86_cpuid_set_hv_vendor, NULL);
+    object_property_add(obj, "hypervisor-extra", "int",
+                        x86_cpuid_get_hv_extra,
+                        x86_cpuid_set_hv_extra, NULL, NULL, NULL);
+    object_property_add(obj, "hypervisor-extra-a", "int",
+                        x86_cpuid_get_hv_extra_a,
+                        x86_cpuid_set_hv_extra_a, NULL, NULL, NULL);
+    object_property_add(obj, "hypervisor-extra-b", "int",
+                        x86_cpuid_get_hv_extra_b,
+                        x86_cpuid_set_hv_extra_b, NULL, NULL, NULL);
 #if !defined(CONFIG_USER_ONLY)
     object_property_add(obj, "hv_spinlocks", "int",
                         x86_get_hv_spinlocks,
Signature · 1 line
1.7.1
author
#16 lore raw

PATCH v5 15/17 target-i386: Add setting of Hypervisor leaf extra for known vmare4.

In reply to Don Slutz

This was taken from:
http://article.gmane.org/gmane.comp.emulators.kvm.devel/22643

---
 target-i386/cpu.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
target-i386/cpu.c +32 -0
index 2423090..e8a21b5 100644
@@ -1135,6 +1135,36 @@ static void x86_cpuid_set_model_id(Object *obj, const char *model_id,
     }
 }
 
+static void x86_cpuid_set_vmware_extra(Object *obj)
+{
+    X86CPU *cpu = X86_CPU(obj);
+
+    if ((cpu->env.tsc_khz != 0) &&
+        (cpu->env.cpuid_hv_level == CPUID_HV_LEVEL_VMWARE_4) &&
+        (cpu->env.cpuid_hv_vendor1 == CPUID_HV_VENDOR_VMWARE_1) &&
+        (cpu->env.cpuid_hv_vendor2 == CPUID_HV_VENDOR_VMWARE_2) &&
+        (cpu->env.cpuid_hv_vendor3 == CPUID_HV_VENDOR_VMWARE_3)) {
+        const uint32_t apic_khz = 1000000L;
+
+        /*
+         * From article.gmane.org/gmane.comp.emulators.kvm.devel/22643
+         *
+         *    Leaf 0x40000010, Timing Information.
+         *
+         *    VMware has defined the first generic leaf to provide timing
+         *    information.  This leaf returns the current TSC frequency and
+         *    current Bus frequency in kHz.
+         *
+         *    # EAX: (Virtual) TSC frequency in kHz.
+         *    # EBX: (Virtual) Bus (local apic timer) frequency in kHz.
+         *    # ECX, EDX: RESERVED (Per above, reserved fields are set to zero).
+         */
+        cpu->env.cpuid_hv_extra = 0x40000010;
+        cpu->env.cpuid_hv_extra_a = (uint32_t)cpu->env.tsc_khz;
+        cpu->env.cpuid_hv_extra_b = apic_khz;
+    }
+}
+
 static void x86_cpuid_get_tsc_freq(Object *obj, Visitor *v, void *opaque,
                                    const char *name, Error **errp)
 {
@@ -1164,6 +1194,7 @@ static void x86_cpuid_set_tsc_freq(Object *obj, Visitor *v, void *opaque,
     }
 
     cpu->env.tsc_khz = value / 1000;
+    x86_cpuid_set_vmware_extra(obj);
 }
 
 static void x86_cpuid_get_hv_level(Object *obj, Visitor *v, void *opaque,
@@ -1277,6 +1308,7 @@ static void x86_cpuid_set_hv_vendor(Object *obj, const char *value,
         env->cpuid_hv_vendor3 |= ((uint8_t)adj_value[i + 8]) << (8 * i);
     }
     env->cpuid_hv_vendor_set = true;
+    x86_cpuid_set_vmware_extra(obj);
 }
 
 static void x86_cpuid_get_hv_extra(Object *obj, Visitor *v, void *opaque,
Signature · 1 line
1.7.1
author
#17 lore raw

PATCH v5 16/17 target-i386: Use Hypervisor leaf extra in -machine pc,accel=kvm.

In reply to Don Slutz
---
 target-i386/kvm.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
target-i386/kvm.c +19 -0
index f8a5177..ff82034 100644
@@ -454,6 +454,25 @@ int kvm_arch_init_vcpu(CPUX86State *env)
         c->ebx = signature[0];
         c->ecx = signature[1];
         c->edx = signature[2];
+    } else if (env->cpuid_hv_extra != 0) {
+        for (i = KVM_CPUID_FEATURES + 1; i <= env->cpuid_hv_level; i++) {
+            c = &cpuid_data.entries[cpuid_i++];
+            memset(c, 0, sizeof(*c));
+            c->function = i;
+            if (i == env->cpuid_hv_extra) {
+                c->eax = env->cpuid_hv_extra_a;
+                c->ebx = env->cpuid_hv_extra_b;
+            }
+        }
+
+        c = &cpuid_data.entries[cpuid_i++];
+        memset(c, 0, sizeof(*c));
+        c->function = KVM_CPUID_SIGNATURE_NEXT;
+        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
+        c->eax = 0;
+        c->ebx = signature[0];
+        c->ecx = signature[1];
+        c->edx = signature[2];
     }
 
     has_msr_async_pf_en = c->eax & (1 << KVM_FEATURE_ASYNC_PF);
Signature · 1 line
1.7.1
author
#18 lore raw

PATCH v5 17/17 target-i386: Use Hypervisor leaf extra in -machine pc,accel=tcg.

In reply to Don Slutz
---
 target-i386/cpu.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
target-i386/cpu.c +11 -0
index e8a21b5..12bd5d4 100644
@@ -1999,6 +1999,17 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
         *ecx = 0;
         *edx = 0;
         break;
+    case 0x40000002 ... 0x400000FF:
+        if (index == env->cpuid_hv_extra) {
+            *eax = env->cpuid_hv_extra_a;
+            *ebx = env->cpuid_hv_extra_b;
+        } else {
+            *eax = 0;
+            *ebx = 0;
+        }
+        *ecx = 0;
+        *edx = 0;
+        break;
     case 0x80000000:
         *eax = env->cpuid_xlevel;
         *ebx = env->cpuid_vendor1;
Signature · 1 line
1.7.1
#19 lore raw
In reply to Don Slutz
Quoted 5 lines · Don Slutz

Also known as Paravirtualization CPUIDs.

This is primarily done so that the guest will think it is running under vmware when hypervisor-vendor=vmware is specified as a property of a cpu.

Please use checkpatch.pl to check for missing braces etc.

Quoted 88 lines

This depends on:

http://lists.gnu.org/archive/html/qemu-devel/2012-09/msg01400.html

As far as I know it is #4. It depends on (1) and (2) and (3).

This change is based on:

Microsoft Hypervisor CPUID Leaves:
http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

Changes from v4 to v5:
Undo kvm_clock2 change.
Add cpuid_hv_level_set; cpuid_hv_level == 0 is now valid.
Add cpuid_hv_vendor_set; the null string is now valid.
Handle kvm and cpuid_hv_level == 0. hypervisor-vendor=kvm,hypervisor-level=0 and hypervisor-level=0,hypervisor-vendor=kvm
now do the same thing.

Changes from v3 to v4:
Added CPUID_HV_LEVEL_HYPERV, CPUID_HV_LEVEL_KVM. Added CPUID_HV_VENDOR_HYPERV.
Added hyperv as known hypservisor-vendor. Allow hypervisor-level to be 0.

Changes from v2 to v3:
Clean post to qemu-devel.

Changes from v1 to v2:

1) Added 1/4 from http://lists.gnu.org/archive/html/qemu-devel/2012-08/msg05153.html

Because Fred is changing jobs and so will not be pushing to get this in. It needed to be rebased, And I needed it to complete the testing of this change.

2) Added 2/4 because of the re-work I needed a way to clear all KVM bits,

3) The rework of v1. Make it fit into the object model re-work of cpu.c for x86.

4) Added 3/4 -- The split out of the code that is not needed for accel=kvm.

Changes from v2 to v3:

Marcelo Tosatti:
Its one big patch, better split in logically correlated patches (with better changelog). This would help reviewers.

So split 3 and 4 into 3 to 17. More info in change log. No code change.

Don Slutz (17):
target-i386: Allow tsc-frequency to be larger then 2.147G
target-i386: Add missing kvm bits.
target-i386: Add Hypervisor level.
target-i386: Add cpu object access routines for Hypervisor level.
target-i386: Add cpu object access routines for Hypervisor level.
target-i386: Use Hypervisor level in -machine pc,accel=kvm.
target-i386: Use Hypervisor level in -machine pc,accel=tcg.
target-i386: Add Hypervisor vendor.
target-i386: Add cpu object access routines for Hypervisor vendor.
target-i386: Use Hypervisor vendor in -machine pc,accel=kvm.
target-i386: Use Hypervisor vendor in -machine pc,accel=tcg.
target-i386: Add some known names to Hypervisor vendor.
target-i386: Add optional Hypervisor leaf extra.
target-i386: Add cpu object access routines for Hypervisor leaf
extra.
target-i386: Add setting of Hypervisor leaf extra for known vmare4.
target-i386: Use Hypervisor leaf extra in -machine pc,accel=kvm.
target-i386: Use Hypervisor leaf extra in -machine pc,accel=tcg.

 target-i386/cpu.c |  285 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 target-i386/cpu.h |   34 +++++++
 target-i386/kvm.c |   33 +++++-
 3 files changed, 341 insertions(+), 11 deletions(-)
author
#20 lore raw
Quoted 7 lines · Blue Swirl
Quoted 5 lines · Don Slutz

Also known as Paravirtualization CPUIDs.

This is primarily done so that the guest will think it is running under vmware when hypervisor-vendor=vmware is specified as a property of a cpu.

Please use checkpatch.pl to check for missing braces etc.

I have been. Somehow missed the warnings on the posted patches. v6 in the works.

Quoted 81 lines
Quoted 81 lines

This depends on:

http://lists.gnu.org/archive/html/qemu-devel/2012-09/msg01400.html

As far as I know it is #4. It depends on (1) and (2) and (3).

This change is based on:

Microsoft Hypervisor CPUID Leaves:

   http://msdn.microsoft.com/en-us/library/windows/hardware/ff542428%28v=vs.85%29.aspx

Linux kernel change starts with:
http://fixunix.com/kernel/538707-use-cpuid-communicate-hypervisor.html
Also:

   http://lkml.indiana.edu/hypermail/linux/kernel/1205.0/00100.html

VMware documention on CPUIDs (Mechanisms to determine if software is running in a VMware virtual machine):
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1009458

Changes from v4 to v5:
Undo kvm_clock2 change.
Add cpuid_hv_level_set; cpuid_hv_level == 0 is now valid.
Add cpuid_hv_vendor_set; the null string is now valid.
Handle kvm and cpuid_hv_level == 0. hypervisor-vendor=kvm,hypervisor-level=0 and hypervisor-level=0,hypervisor-vendor=kvm
now do the same thing.

Changes from v3 to v4:
Added CPUID_HV_LEVEL_HYPERV, CPUID_HV_LEVEL_KVM. Added CPUID_HV_VENDOR_HYPERV.
Added hyperv as known hypservisor-vendor. Allow hypervisor-level to be 0.

Changes from v2 to v3:
Clean post to qemu-devel.

Changes from v1 to v2:

1) Added 1/4 from http://lists.gnu.org/archive/html/qemu-devel/2012-08/msg05153.html

Because Fred is changing jobs and so will not be pushing to get this in. It needed to be rebased, And I needed it to complete the testing of this change.

2) Added 2/4 because of the re-work I needed a way to clear all KVM bits,

3) The rework of v1. Make it fit into the object model re-work of cpu.c for x86.

4) Added 3/4 -- The split out of the code that is not needed for accel=kvm.

Changes from v2 to v3:

Marcelo Tosatti:
Its one big patch, better split in logically correlated patches (with better changelog). This would help reviewers.

So split 3 and 4 into 3 to 17. More info in change log. No code change.

Don Slutz (17):
target-i386: Allow tsc-frequency to be larger then 2.147G
target-i386: Add missing kvm bits.
target-i386: Add Hypervisor level.
target-i386: Add cpu object access routines for Hypervisor level.
target-i386: Add cpu object access routines for Hypervisor level.
target-i386: Use Hypervisor level in -machine pc,accel=kvm.
target-i386: Use Hypervisor level in -machine pc,accel=tcg.
target-i386: Add Hypervisor vendor.
target-i386: Add cpu object access routines for Hypervisor vendor.
target-i386: Use Hypervisor vendor in -machine pc,accel=kvm.
target-i386: Use Hypervisor vendor in -machine pc,accel=tcg.
target-i386: Add some known names to Hypervisor vendor.
target-i386: Add optional Hypervisor leaf extra.
target-i386: Add cpu object access routines for Hypervisor leaf
extra.
target-i386: Add setting of Hypervisor leaf extra for known vmare4.
target-i386: Use Hypervisor leaf extra in -machine pc,accel=kvm.
target-i386: Use Hypervisor leaf extra in -machine pc,accel=tcg.

Quoted 6 lines
Quoted 6 lines
  target-i386/cpu.c |  285 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
  target-i386/cpu.h |   34 +++++++
  target-i386/kvm.c |   33 +++++-
  3 files changed, 341 insertions(+), 11 deletions(-)

-Don