]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
KVM: x86: Mask off reserved bits in CPUID.80000008H
authorJim Mattson <jmattson@google.com>
Thu, 29 Sep 2022 22:52:00 +0000 (15:52 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 6 Dec 2022 13:45:46 +0000 (14:45 +0100)
BugLink: https://bugs.launchpad.net/bugs/1998843
commit 7030d8530e533844e2f4b0e7476498afcd324634 upstream.

KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM
actually supports. The following ranges of CPUID.80000008H are reserved
and should be masked off:
    ECX[31:18]
    ECX[11:8]

In addition, the PerfTscSize field at ECX[17:16] should also be zero
because KVM does not set the PERFTSC bit at CPUID.80000001H.ECX[27].

Fixes: 24c82e576b78 ("KVM: Sanitize cpuid")
Signed-off-by: Jim Mattson <jmattson@google.com>
Message-Id: <20220929225203.2234702-3-jmattson@google.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/x86/kvm/cpuid.c

index 6ca34db82d86c88b480d999fb5d9127d909675b1..478721a33a1f18dcca93d159164e53600489220a 100644 (file)
@@ -937,6 +937,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
                        g_phys_as = phys_as;
 
                entry->eax = g_phys_as | (virt_as << 8);
+               entry->ecx &= ~(GENMASK(31, 16) | GENMASK(11, 8));
                entry->edx = 0;
                cpuid_entry_override(entry, CPUID_8000_0008_EBX);
                break;