Patchwork [v7,11/17] target-i386: Use Hypervisor vendor in -machine pc, accel=kvm.

login
register
mail settings
Submitter Don Slutz
Date Oct. 12, 2012, 7:56 p.m.
Message ID <1350071782-23078-12-git-send-email-Don@CloudSwitch.com>
Download mbox | patch
Permalink /patch/191213/
State New
Headers show

Comments

Don Slutz - Oct. 12, 2012, 7:56 p.m.
Part of "target-i386: Add way to expose VMWare CPUID"

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

QEMU knows this is KVM_CPUID_SIGNATURE (0x40000000).

If hypervisor vendor is set then add kvm's
signature at KVM_CPUID_SIGNATURE_NEXT (0x40000100).

Signed-off-by: Don Slutz <Don@CloudSwitch.com>
---
 target-i386/kvm.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

Patch

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 30963e1..513356d 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -390,20 +390,21 @@  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()) {
-        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
-        if (!env->cpuid_hv_level_set) {
-            c->eax = 0;
-        } else {
-            c->eax = env->cpuid_hv_level;
-        }
+    if (!env->cpuid_hv_level_set) {
+        c->eax = 0;
     } else {
-        memcpy(signature, "Microsoft Hv", 12);
         c->eax = env->cpuid_hv_level;
     }
-    c->ebx = signature[0];
-    c->ecx = signature[1];
-    c->edx = signature[2];
+    if (!env->cpuid_hv_vendor_set) {
+        memcpy(signature, "KVMKVMKVM\0\0\0", 12);
+        c->ebx = signature[0];
+        c->ecx = signature[1];
+        c->edx = signature[2];
+    } else {
+        c->ebx = env->cpuid_hv_vendor1;
+        c->ecx = env->cpuid_hv_vendor2;
+        c->edx = env->cpuid_hv_vendor3;
+    }
 
     c = &cpuid_data.entries[cpuid_i++];
     memset(c, 0, sizeof(*c));
@@ -448,7 +449,8 @@  int kvm_arch_init_vcpu(CPUX86State *env)
         c->function = HYPERV_CPUID_IMPLEMENT_LIMITS;
         c->eax = 0x40;
         c->ebx = 0x40;
-
+    }
+    if (env->cpuid_hv_vendor_set) {
         c = &cpuid_data.entries[cpuid_i++];
         memset(c, 0, sizeof(*c));
         c->function = KVM_CPUID_SIGNATURE_NEXT;