[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <95260776-a734-e95b-40cc-3959eaf38223@intel.com>
Date: Tue, 25 Apr 2023 14:47:08 +0800
From: Zeng Guang <guang.zeng@...el.com>
To: Binbin Wu <binbin.wu@...ux.intel.com>,
Paolo Bonzini <pbonzini@...hat.com>,
"Christopherson,, Sean" <seanjc@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
H Peter Anvin <hpa@...or.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>
Cc: "x86@...nel.org" <x86@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"Gao, Chao" <chao.gao@...el.com>
Subject: Re: [PATCH 6/6] KVM: x86: Set KVM LASS based on hardware capability
On 4/25/2023 10:57 AM, Binbin Wu wrote:
>
> On 4/20/2023 9:37 PM, Zeng Guang wrote:
>> Host kernel may clear LASS capability in boot_cpu_data.x86_capability
> Is there some option to do it?
Kernel supporting LASS will turn off the LASS capability with specific
option, e.g.
"vsyscall=emulate".
>> besides explicitly using clearcpuid parameter. That will cause guest
>> not being able to manage LASS independently. So set KVM LASS directly
>> based on hardware capability to eliminate the dependency.
>>
>> Add new helper functions to facilitate getting result of CPUID sub-leaf.
>>
>> Signed-off-by: Zeng Guang <guang.zeng@...el.com>
>> ---
>> arch/x86/include/asm/cpuid.h | 36 ++++++++++++++++++++++++++++++++++++
>> arch/x86/kvm/cpuid.c | 4 ++++
>> 2 files changed, 40 insertions(+)
>>
>> diff --git a/arch/x86/include/asm/cpuid.h b/arch/x86/include/asm/cpuid.h
>> index 9bee3e7bf973..a25dd00b7c0a 100644
>> --- a/arch/x86/include/asm/cpuid.h
>> +++ b/arch/x86/include/asm/cpuid.h
>> @@ -127,6 +127,42 @@ static inline unsigned int cpuid_edx(unsigned int op)
>> return edx;
>> }
>>
>> +static inline unsigned int cpuid_count_eax(unsigned int op, int count)
>> +{
>> + unsigned int eax, ebx, ecx, edx;
>> +
>> + cpuid_count(op, count, &eax, &ebx, &ecx, &edx);
>> +
>> + return eax;
>> +}
>> +
>> +static inline unsigned int cpuid_count_ebx(unsigned int op, int count)
>> +{
>> + unsigned int eax, ebx, ecx, edx;
>> +
>> + cpuid_count(op, count, &eax, &ebx, &ecx, &edx);
>> +
>> + return ebx;
>> +}
>> +
>> +static inline unsigned int cpuid_count_ecx(unsigned int op, int count)
>> +{
>> + unsigned int eax, ebx, ecx, edx;
>> +
>> + cpuid_count(op, count, &eax, &ebx, &ecx, &edx);
>> +
>> + return ecx;
>> +}
>> +
>> +static inline unsigned int cpuid_count_edx(unsigned int op, int count)
>> +{
>> + unsigned int eax, ebx, ecx, edx;
>> +
>> + cpuid_count(op, count, &eax, &ebx, &ecx, &edx);
>> +
>> + return edx;
>> +}
>> +
>> static __always_inline bool cpuid_function_is_indexed(u32 function)
>> {
>> switch (function) {
>> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
>> index 5facb8037140..e99b99ebe1fe 100644
>> --- a/arch/x86/kvm/cpuid.c
>> +++ b/arch/x86/kvm/cpuid.c
>> @@ -667,6 +667,10 @@ void kvm_set_cpu_caps(void)
>> F(AMX_FP16) | F(AVX_IFMA)
>> );
>>
>> + /* Set LASS based on hardware capability */
>> + if (cpuid_count_eax(7, 1) & F(LASS))
>> + kvm_cpu_cap_set(X86_FEATURE_LASS);
>> +
>> kvm_cpu_cap_init_kvm_defined(CPUID_7_1_EDX,
>> F(AVX_VNNI_INT8) | F(AVX_NE_CONVERT) | F(PREFETCHITI)
>> );
Powered by blists - more mailing lists