diff mbox series

[6/6] KVM: x86: Mask off reserved bits in CPUID.8000001FH

Message ID 20220929225203.2234702-6-jmattson@google.com (mailing list archive)
State New, archived
Headers show
Series [1/6] KVM: x86: Mask off reserved bits in CPUID.80000001H | expand

Commit Message

Jim Mattson Sept. 29, 2022, 10:52 p.m. UTC
KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM
actually supports. CPUID.8000001FH:EBX[31:16] are reserved bits and
should be masked off.

Fixes: 8765d75329a3 ("KVM: X86: Extend CPUID range to include new leaf")
Signed-off-by: Jim Mattson <jmattson@google.com>
---
 arch/x86/kvm/cpuid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Bonzini Oct. 22, 2022, 8:34 a.m. UTC | #1
On 9/30/22 00:52, Jim Mattson wrote:
> KVM_GET_SUPPORTED_CPUID should only enumerate features that KVM
> actually supports. CPUID.8000001FH:EBX[31:16] are reserved bits and
> should be masked off.
> 
> Fixes: 8765d75329a3 ("KVM: X86: Extend CPUID range to include new leaf")
> Signed-off-by: Jim Mattson <jmattson@google.com>
> ---
>   arch/x86/kvm/cpuid.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
> index 576cbcf489ce..58dabc9e54db 100644
> --- a/arch/x86/kvm/cpuid.c
> +++ b/arch/x86/kvm/cpuid.c
> @@ -1188,7 +1188,7 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
>   			entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
>   		} else {
>   			cpuid_entry_override(entry, CPUID_8000_001F_EAX);
> -
> +			entry->ebx &= ~GENMASK(31, 16);
>   			/*
>   			 * Enumerate '0' for "PA bits reduction", the adjusted
>   			 * MAXPHYADDR is enumerated directly (see 0x80000008).

I think 15:12 (number of VMPLs supported) should also be masked off 
since KVM does not support SEV-SNP.

Paolo
diff mbox series

Patch

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 576cbcf489ce..58dabc9e54db 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -1188,7 +1188,7 @@  static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
 			entry->eax = entry->ebx = entry->ecx = entry->edx = 0;
 		} else {
 			cpuid_entry_override(entry, CPUID_8000_001F_EAX);
-
+			entry->ebx &= ~GENMASK(31, 16);
 			/*
 			 * Enumerate '0' for "PA bits reduction", the adjusted
 			 * MAXPHYADDR is enumerated directly (see 0x80000008).