]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/i386: do not consult nonexistent host leaves
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 29 Apr 2022 19:16:28 +0000 (21:16 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 12 May 2022 10:07:05 +0000 (12:07 +0200)
commit798d8ec0dacd4cc0034298d94f430c14f23e2919
treef69a9e75c514a88bff6660e016305c55d60309a4
parent236d15222e06750d6b889030ed04c849b1dc279e
target/i386: do not consult nonexistent host leaves

When cache_info_passthrough is requested, QEMU passes the host values
of the cache information CPUID leaves down to the guest.  However,
it blindly assumes that the CPUID leaf exists on the host, and this
cannot be guaranteed: for example, KVM has recently started to
synthesize AMD leaves up to 0x80000021 in order to provide accurate
CPU bug information to guests.

Querying a nonexistent host leaf fills the output arguments of
host_cpuid with data that (albeit deterministic) is nonsensical
as cache information, namely the data in the highest Intel CPUID
leaf.  If said highest leaf is not ECX-dependent, this can even
cause an infinite loop when kvm_arch_init_vcpu prepares the input
to KVM_SET_CPUID2.  The infinite loop is only terminated by an
abort() when the array gets full.

Reported-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/cpu.c