Skip to contentSkip to conversation

QEMU: Fix KVM XSAVE feature bit enumeration

PATCH In review Andre Przywara 3 participants 4 messages Jun 10, 2011 – Jun 19, 2011 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 QEMU: Fix KVM XSAVE feature bit enumeration

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.

---
 target-i386/kvm.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
target-i386/kvm.c +3 -1
index faedc6c..4a97f78 100644
@@ -448,6 +448,8 @@ 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;
@@ -460,7 +462,7 @@ int kvm_arch_init_vcpu(CPUState *env)
                     break;
                 }
                 if (i == 0xd && c->eax == 0) {
-                    break;
+                    continue;
                 }
                 c = &cpuid_data.entries[cpuid_i++];
             }
Signature · 1 line
1.6.4
#1 lore raw
Quoted 15 lines · Andre Przywara

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.

---
 target-i386/kvm.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
target-i386/kvm.c +0 -0
index faedc6c..4a97f78 100644

target-i386/kvm.c int kvm_arch_init_vcpu(CPUState *env) · line 452

Quoted 5 lines
target-i386/kvm.c +2 -0
@@ -448,6 +448,8 @@ int kvm_arch_init_vcpu(CPUState *env)
         case 0xb:
         case 0xd:
             for (j = 0; ; j++) {
+                if (i == 0xd && j == 64)
+                    break;

checkpatch.pl?

target-i386/kvm.c int kvm_arch_init_vcpu(CPUState *env) · line 468

Quoted 12 lines
target-i386/kvm.c +1 -1
                 c->function = i;
                 c->flags = KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
                 c->index = j;
@@ -460,7 +462,7 @@ int kvm_arch_init_vcpu(CPUState *env)
                     break;
                 }
                 if (i == 0xd && c->eax == 0) {
-                    break;
+                    continue;
                 }
                 c = &cpuid_data.entries[cpuid_i++];
             }

Jan

Signature · 2 lines
Siemens AG, Corporate Technology, CT T DE IT 1
Corporate Competence Center Embedded Linux
#2 lore raw

PATCH 1/1 KVM: Fix XSAVE feature bit enumeration

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.

---
 target-i386/kvm.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
target-i386/kvm.c +4 -1
index faedc6c..37a972f 100644
@@ -448,6 +448,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;
@@ -460,7 +463,7 @@ int kvm_arch_init_vcpu(CPUState *env)
                     break;
                 }
                 if (i == 0xd && c->eax == 0) {
-                    break;
+                    continue;
                 }
                 c = &cpuid_data.entries[cpuid_i++];
             }
Signature · 1 line
1.6.4
Applied
#3 lore raw

Re: [PATCH] KVM: Fix XSAVE feature bit enumeration

Quoted 4 lines · Andre Przywara

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.

Thanks, applied to uq/master.

Signature · 1 line
error compiling committee.c: too many arguments to function