linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] KVM: x86/cpuid: Expose the true number of available ASIDs
@ 2021-07-15 10:45 Like Xu
  2021-07-15 11:19 ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Like Xu @ 2021-07-15 10:45 UTC (permalink / raw)
  To: Paolo Bonzini, Joerg Roedel
  Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	x86, linux-kernel, kvm

From: Like Xu <likexu@tencent.com>

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@tencent.com>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86/cpuid: Expose the true number of available ASIDs
  2021-07-15 10:45 [PATCH] KVM: x86/cpuid: Expose the true number of available ASIDs Like Xu
@ 2021-07-15 11:19 ` Paolo Bonzini
  2021-07-15 11:51   ` Like Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2021-07-15 11:19 UTC (permalink / raw)
  To: Like Xu, Joerg Roedel
  Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	x86, linux-kernel, kvm

On 15/07/21 12:45, Like Xu wrote:
> 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.
>
> -		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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: x86/cpuid: Expose the true number of available ASIDs
  2021-07-15 11:19 ` Paolo Bonzini
@ 2021-07-15 11:51   ` Like Xu
  0 siblings, 0 replies; 3+ messages in thread
From: Like Xu @ 2021-07-15 11:51 UTC (permalink / raw)
  To: Paolo Bonzini, Joerg Roedel
  Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
	x86, linux-kernel, kvm

On 15/7/2021 7:19 pm, Paolo Bonzini wrote:
> On 15/07/21 12:45, Like Xu wrote:
>> 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.
>>
>> -        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?

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-15 11:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 10:45 [PATCH] KVM: x86/cpuid: Expose the true number of available ASIDs Like Xu
2021-07-15 11:19 ` Paolo Bonzini
2021-07-15 11:51   ` Like Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).