Blame enable_architectural_PMU_cpuid_leaf.patch

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