Re: [RFC PATCH 1/2] KVM: x86: Add a framework for supporting MSR-based features

From: Tom Lendacky
Date: Tue Feb 13 2018 - 23:23:53 EST


On 2/13/2018 10:21 AM, Paolo Bonzini wrote:
> On 08/02/2018 23:58, Tom Lendacky wrote:
>> Provide a new KVM capability that allows bits within MSRs to be recognized
>> as features. Two new ioctls are added to the VM ioctl routine to retrieve
>> the list of these MSRs and their values. The MSR features can optionally
>> be exposed based on a CPU and/or a CPU feature.
>
> Yes, pretty much. Just two changes:
>
>> +struct kvm_msr_based_features {
>> + u32 msr; /* MSR to query */
>> + u64 mask; /* MSR mask */
>> + const struct x86_cpu_id *match; /* Match criteria */
>> + u64 value; /* MSR value */
>
> 1) These two should be replaced by a kvm_x86_ops callback, because
> computing the value is sometimes a bit more complicated than just rdmsr
> (for example, MSRs for VMX capabilities depend on the kvm_intel.ko
> module parameters).

Ok, I'll rework this.

>
>
>> + case KVM_CAP_GET_MSR_FEATURES:
>
> This should be KVM_GET_MSR.

Yup, not sure what I was thinking there.

>
>> + r = msr_io(NULL, argp, do_get_msr_features, 1);
>> + break;
>
>
> Bonus points for writing documentation :) and for moving the MSR> handling code to arch/x86/kvm/msr.{c,h}.

Yup, there will be documentation on it - I wanted to make sure the
direction was correct first. Splitting out msr.c/msr.h might be
best as a separate patchset, let me see what's involved.

Thanks,
Tom

>
> Thanks,
>
> Paolo
>