Skip to contentSkip to conversation

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

PATCH In review Like Xu 2 participants 3 messages Jul 15, 2021

Subsystems (3)
lore
Share & tools
lore

Like Xu

author
#0 lore raw

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

From: Like Xu <[email protected]>

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")
---
 arch/x86/kvm/cpuid.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/x86/kvm/cpuid.c +5 -2
index 739be5da3bca..133827704fd3 100644
@@ -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;
Signature · 1 line
2.32.0
maintainer
#1 lore raw

arch/x86/kvm/cpuid.c static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) · line 971

Quoted 8 lines · Like Xu

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.

arch/x86/kvm/cpuid.c +0 -2
-		entry->ebx = 8; /* Lets support 8 ASIDs in case we add proper
-				   ASID emulation to nested SVM */

Why, since we don't have ASID emulation yet anyway?

Paolo

author
#2 lore raw
Quoted 5 lines · Paolo Bonzini
Quoted 4 lines · Like Xu

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.

Quoted 8 lines
Quoted 4 lines

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

-        entry->ebx = 8; /* Lets support 8 ASIDs in case we add proper -                   ASID emulation to nested SVM */

Why, since we don't have ASID emulation yet anyway?

Paolo

I suppose you're right on the current state.

But do we have an explanation as to why it is hard-coded as 8 and not zero or a real supported number?