[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <72a75924-c3cb-6b23-62bd-67b739dec166@redhat.com>
Date: Fri, 5 Jun 2020 08:35:33 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: Xiaoyao Li <xiaoyao.li@...el.com>,
Li RongQing <lirongqing@...du.com>,
linux-kernel@...r.kernel.org, kvm@...r.kernel.org, x86@...nel.org,
hpa@...or.com, bp@...en8.de, mingo@...hat.com, tglx@...utronix.de,
jmattson@...gle.com, wanpengli@...cent.com, vkuznets@...hat.com,
sean.j.christopherson@...el.com, wei.huang2@....com
Subject: Re: [PATCH][v6] KVM: X86: support APERF/MPERF registers
On 05/06/20 07:00, Xiaoyao Li wrote:
> you could do
>
> bool guest_cpuid_aperfmperf = false;
> if (best)
> guest_cpuid_aperfmperf = !!(best->ecx & BIT(0));
>
> if (guest_cpuid_aperfmerf != guest_has_aperfmperf(vcpu->kvm))
> return -EINVAL;
>
>
> In fact, I think we can do nothing here. Leave it as what usersapce
> wants just like how KVM treats other CPUID bits.
The reason to do it like Rongqing did is that it's suggested to take the
output of KVM_GET_SUPPORTED_CPUID and pass it down to KVM_SET_CPUID2.
Unfortunately we have KVM_GET_SUPPORTED_CPUID as a /dev/kvm (not VM)
ioctl, otherwise you could have used guest_has_aperfmperf to affect the
output of KVM_GET_SUPPORTED_CPUID.
I think it's okay however to keep it simple as you suggest. In this
case however __do_cpuid_func must not return the X86_FEATURE_APERFMPERF bit.
The guest can instead check for the availability of KVM_CAP_APERFMPERF,
which is already done in Rongqing's patch.
>> @@ -4930,6 +4939,11 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
>> kvm->arch.exception_payload_enabled = cap->args[0];
>> r = 0;
>> break;
>> + case KVM_CAP_APERFMPERF:
>> + kvm->arch.aperfmperf_mode =
>> + boot_cpu_has(X86_FEATURE_APERFMPERF) ? cap->args[0] : 0;
>
> Shouldn't check whether cap->args[0] is a valid value?
Yes, only valid values should be allowed.
Also, it should fail with -EINVAL if the host does not have
X86_FEATURE_APERFMPERF.
Thanks,
Paolo
Powered by blists - more mailing lists