4d9bbd1
commit a0fa82085e175bf8ce6d69a3f83695f81af2a649
4d9bbd1
Author: Gleb Natapov <gleb@redhat.com>
4d9bbd1
Date:   Thu Dec 15 12:44:05 2011 +0200
4d9bbd1
4d9bbd1
    enable architectural PMU cpuid leaf for kvm
4d9bbd1
    
4d9bbd1
    Signed-off-by: Gleb Natapov <gleb@redhat.com>
4d9bbd1
    Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
4d9bbd1
4d9bbd1
diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
4d9bbd1
index 0b3af90..91a104b 100644
4d9bbd1
--- a/target-i386/cpuid.c
4d9bbd1
+++ b/target-i386/cpuid.c
4d9bbd1
@@ -1180,10 +1180,19 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
4d9bbd1
         break;
4d9bbd1
     case 0xA:
4d9bbd1
         /* Architectural Performance Monitoring Leaf */
4d9bbd1
-        *eax = 0;
4d9bbd1
-        *ebx = 0;
4d9bbd1
-        *ecx = 0;
4d9bbd1
-        *edx = 0;
4d9bbd1
+        if (kvm_enabled()) {
4d9bbd1
+            KVMState *s = env->kvm_state;
4d9bbd1
+
4d9bbd1
+            *eax = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EAX);
4d9bbd1
+            *ebx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EBX);
4d9bbd1
+            *ecx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_ECX);
4d9bbd1
+            *edx = kvm_arch_get_supported_cpuid(s, 0xA, count, R_EDX);
4d9bbd1
+        } else {
4d9bbd1
+            *eax = 0;
4d9bbd1
+            *ebx = 0;
4d9bbd1
+            *ecx = 0;
4d9bbd1
+            *edx = 0;
4d9bbd1
+        }
4d9bbd1
         break;
4d9bbd1
     case 0xD:
4d9bbd1
         /* Processor Extended State */