[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5dccc4fb-1b90-326d-fb33-4e68c839a675@intel.com>
Date: Sun, 25 Dec 2022 12:31:21 +0800
From: "Yang, Weijiang" <weijiang.yang@...el.com>
To: Like Xu <like.xu.linux@...il.com>
CC: <kan.liang@...ux.intel.com>, <wei.w.wang@...el.com>,
<seanjc@...gle.com>, <pbonzini@...hat.com>, <jmattson@...gle.com>,
<kvm@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 15/15] KVM: x86/cpuid: Advertise Arch LBR feature in
CPUID
On 12/22/2022 7:03 PM, Like Xu wrote:
> On 25/11/2022 12:06 pm, Yang Weijiang wrote:
>> diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
>> index 85e3df6217af..60b3c591d462 100644
>> --- a/arch/x86/kvm/cpuid.c
>> +++ b/arch/x86/kvm/cpuid.c
>> @@ -134,6 +134,19 @@ static int kvm_check_cpuid(struct kvm_vcpu *vcpu,
>> if (vaddr_bits != 48 && vaddr_bits != 57 && vaddr_bits != 0)
>> return -EINVAL;
>> }
>> + if (kvm_cpu_cap_has(X86_FEATURE_ARCH_LBR)) {
>> + best = cpuid_entry2_find(entries, nent, 0x1c, 0);
>> + if (best) {
>> + unsigned int eax, ebx, ecx, edx;
>> +
>> + /* Reject user-space CPUID if depth is different from
>> host's.*/
>
> Try to verify this in the KVM selftest, as this behavior is different
> from the host.
Will do it.
>
>> + cpuid_count(0x1c, 0, &eax, &ebx, &ecx, &edx); > +
>> + if ((eax & 0xff) &&
>> + (best->eax & 0xff) != BIT(fls(eax & 0xff) - 1))
>> + return -EINVAL;
>> + }
>> + }
Powered by blists - more mailing lists