aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@amd.com>2011-06-10 05:35:30 -0400
committerAvi Kivity <avi@redhat.com>2011-07-12 06:16:20 -0400
commit02668b061db1b9f7f18872e594ac68e237db0bed (patch)
tree8af89c7a18a1ce2aef57336c9d257eb00c29c4db /arch/x86
parent58f0964ee445d6703bf2bfd5170e75fb0920ad8f (diff)
KVM: fix XSAVE bit scanning (now properly)
commit 123108f1c1aafd51d6a5c79cc04d7999dd88a930 tried to fix KVMs XSAVE valid feature scanning, but it was wrong. It was not considering the sparse nature of this bitfield, instead reading values from uninitialized members of the entries array. This patch now separates subleaf indicies from KVM's array indicies and fills the entry before querying it's value. This fixes AVX support in KVM guests. Signed-off-by: Andre Przywara <andre.przywara@amd.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kvm/x86.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index ff4623b1b102..84f46074ca74 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2447,16 +2447,17 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
2447 break; 2447 break;
2448 } 2448 }
2449 case 0xd: { 2449 case 0xd: {
2450 int i; 2450 int idx, i;
2451 2451
2452 entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX; 2452 entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
2453 for (i = 1; *nent < maxnent && i < 64; ++i) { 2453 for (idx = 1, i = 1; *nent < maxnent && idx < 64; ++idx) {
2454 if (entry[i].eax == 0 || !supported_xcr0_bit(i)) 2454 do_cpuid_1_ent(&entry[i], function, idx);
2455 if (entry[i].eax == 0 || !supported_xcr0_bit(idx))
2455 continue; 2456 continue;
2456 do_cpuid_1_ent(&entry[i], function, i);
2457 entry[i].flags |= 2457 entry[i].flags |=
2458 KVM_CPUID_FLAG_SIGNIFCANT_INDEX; 2458 KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
2459 ++*nent; 2459 ++*nent;
2460 ++i;
2460 } 2461 }
2461 break; 2462 break;
2462 } 2463 }