Commit 02668b06 authored by Andre Przywara's avatar Andre Przywara Committed by Avi Kivity

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: default avatarAndre Przywara <andre.przywara@amd.com>
Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
parent 58f0964e
...@@ -2447,16 +2447,17 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function, ...@@ -2447,16 +2447,17 @@ static void do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
break; break;
} }
case 0xd: { case 0xd: {
int i; int idx, i;
entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX; entry->flags |= KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
for (i = 1; *nent < maxnent && i < 64; ++i) { for (idx = 1, i = 1; *nent < maxnent && idx < 64; ++idx) {
if (entry[i].eax == 0 || !supported_xcr0_bit(i)) do_cpuid_1_ent(&entry[i], function, idx);
if (entry[i].eax == 0 || !supported_xcr0_bit(idx))
continue; continue;
do_cpuid_1_ent(&entry[i], function, i);
entry[i].flags |= entry[i].flags |=
KVM_CPUID_FLAG_SIGNIFCANT_INDEX; KVM_CPUID_FLAG_SIGNIFCANT_INDEX;
++*nent; ++*nent;
++i;
} }
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment