[PATCH] KVM: x86/cpuid: Expose the true number of available ASIDs

From: Like Xu
Date: Thu Jul 15 2021 - 06:45:20 EST


From: Like Xu <likexu@xxxxxxxxxxx>

The original fixed number "8" was first introduced 11 years ago. Time has
passed and now let KVM report the true number of address space identifiers
(ASIDs) that are supported by the processor returned in Fn8000_000A_EBX.

It helps user-space to make better decisions about guest values.

Fixes: c2c63a493924 ("KVM: SVM: Report emulated SVM features to userspace")
Signed-off-by: Like Xu <likexu@xxxxxxxxxxx>
---
arch/x86/kvm/cpuid.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 739be5da3bca..133827704fd3 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -967,8 +967,11 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
break;
}
entry->eax = 1; /* SVM revision 1 */
- entry->ebx = 8; /* Lets support 8 ASIDs in case we add proper
- ASID emulation to nested SVM */
+ /*
+ * Let's support at least 8 ASIDs in case we
+ * add proper ASID emulation to nested SVM.
+ */
+ entry->ebx = max_t(unsigned int, 8, entry->ebx);
entry->ecx = 0; /* Reserved */
cpuid_entry_override(entry, CPUID_8000_000A_EDX);
break;
--
2.32.0