[PATCH 2/3] qemu-kvm: align cpu-features with kvm_supported_cpuid

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The cpuid features exposed to the guest are currently not aligned with the bits
returned by the supported_cpuid ioctl. This patch fixes it.

Signed-off-by: Joerg Roedel <joerg.roedel@xxxxxxx>
---
 qemu-kvm-x86.c |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c
index 729d600..95774c1 100644
--- a/qemu-kvm-x86.c
+++ b/qemu-kvm-x86.c
@@ -578,6 +578,13 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
                 if (i == 0xd && copy.regs[R_EAX] == 0)
                     break;
             }
+        } else if (i == 1) {
+            do_cpuid_ent(&cpuid_ent[cpuid_nent], i, 0, &copy);
+            kvm_trim_features(&cpuid_ent[cpuid_nent].edx,
+                              kvm_arch_get_supported_cpuid(cenv, 1, R_EDX));
+            kvm_trim_features(&cpuid_ent[cpuid_nent].ecx,
+                              kvm_arch_get_supported_cpuid(cenv, 1, R_ECX));
+            cpuid_nent++;
         } else
             do_cpuid_ent(&cpuid_ent[cpuid_nent++], i, 0, &copy);
     }
@@ -586,20 +593,19 @@ int kvm_arch_qemu_init_env(CPUState *cenv)
     qemu_kvm_cpuid_on_env(&copy);
     limit = copy.regs[R_EAX];
 
-    for (i = 0x80000000; i <= limit; ++i)
-	do_cpuid_ent(&cpuid_ent[cpuid_nent++], i, 0, &copy);
+    for (i = 0x80000000; i <= limit; ++i) {
+	do_cpuid_ent(&cpuid_ent[cpuid_nent], i, 0, &copy);
+        if (i == 0x80000001) {
+            kvm_trim_features(&cpuid_ent[cpuid_nent].edx,
+                              kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX));
+            kvm_trim_features(&cpuid_ent[cpuid_nent].ecx,
+                              kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_ECX));
+        }
+        ++cpuid_nent;
+    }
 
     kvm_setup_cpuid2(cenv->kvm_cpu_state.vcpu_ctx, cpuid_nent, cpuid_ent);
 
-    kvm_trim_features(&cenv->cpuid_features,
-                      kvm_arch_get_supported_cpuid(cenv, 1, R_EDX));
-    kvm_trim_features(&cenv->cpuid_ext_features,
-                      kvm_arch_get_supported_cpuid(cenv, 1, R_ECX));
-    kvm_trim_features(&cenv->cpuid_ext2_features,
-                      kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_EDX));
-    kvm_trim_features(&cenv->cpuid_ext3_features,
-                      kvm_arch_get_supported_cpuid(cenv, 0x80000001, R_ECX));
-
     return 0;
 }
 
-- 
1.6.3.1


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux