aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/arch/x86/kvm/cpuid.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-10-28 13:15:55 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2022-02-10 13:47:16 -0500
commit2746a6b72ab9a92bd188c4ac3e4122ee1c18f754 (patch)
treee6158f71d1ee8f01ea9bb57d6de43329714c4ab4 /arch/x86/kvm/cpuid.c
parentKVM: x86: Remove unused "flags" of kvm_pv_kick_cpu_op() (diff)
downloadwireguard-linux-2746a6b72ab9a92bd188c4ac3e4122ee1c18f754.tar.xz
wireguard-linux-2746a6b72ab9a92bd188c4ac3e4122ee1c18f754.zip
KVM: x86: skip host CPUID call for hypervisor leaves
Hypervisor leaves are always synthesized by __do_cpuid_func; just return zeroes and do not ask the host. Even on nested virtualization, a value from another hypervisor would be bogus, because all hypercalls and MSRs are processed by KVM. Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/cpuid.c')
-rw-r--r--arch/x86/kvm/cpuid.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 494d4d351859..ff756cdc31ce 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -712,9 +712,17 @@ static struct kvm_cpuid_entry2 *do_host_cpuid(struct kvm_cpuid_array *array,
entry = &array->entries[array->nent++];
+ memset(entry, 0, sizeof(*entry));
entry->function = function;
entry->index = index;
- entry->flags = 0;
+ switch (function & 0xC0000000) {
+ case 0x40000000:
+ /* Hypervisor leaves are always synthesized by __do_cpuid_func. */
+ return entry;
+
+ default:
+ break;
+ }
cpuid_count(entry->function, entry->index,
&entry->eax, &entry->ebx, &entry->ecx, &entry->edx);