Patchwork [14/15] KVM: Fix XSAVE feature bit enumeration

login
register
mail settings
Submitter Marcelo Tosatti
Date June 21, 2011, 5:08 p.m.
Message ID <31e8c69697becf5e0b54a6a0cef1d27109d469e9.1308676084.git.mtosatti@redhat.com>
Download mbox | patch
Permalink /patch/101320/
State New
Headers show

Comments

Marcelo Tosatti - June 21, 2011, 5:08 p.m.
From: Andre Przywara <andre.przywara@amd.com>

When iterating through the XSAVE feature enumeration CPUID leaf (0xD)
we should not stop at the first zero EAX, but instead keep scanning
since there are gaps in the enumeration (ECX=1 for instance).
This fixes the proper usage of AVX in KVM guests.

Signed-off-by: Andre Przywara <andre.przywara@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
---
 target-i386/kvm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch

diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index 938e0a3..10fb2c4 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -416,6 +416,9 @@  int kvm_arch_init_vcpu(CPUState *env)
         case 0xb:
         case 0xd:
             for (j = 0; ; j++) {
+                if (i == 0xd && j == 64) {
+                    break;
+                }
                 c->function = i;
                 c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
                 c->index = j;
@@ -428,7 +431,7 @@  int kvm_arch_init_vcpu(CPUState *env)
                     break;
                 }
                 if (i == 0xd && c->eax == 0) {
-                    break;
+                    continue;
                 }
                 c = &cpuid_data.entries[cpuid_i++];
             }