mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org
Cc: "Joerg Roedel" <joro@8bytes.org>,
	"Borislav Petkov" <bp@alien8.de>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Radim Krčmář" <rkrcmar@redhat.com>
Subject: Re: [PATCH v2 1/2] KVM: x86: Add a framework for supporting MSR-based features
Date: Wed, 21 Feb 2018 08:52:46 -0600	[thread overview]
Message-ID: <d77a8a6e-d10b-82d9-6df4-7ed5505ef40f@amd.com> (raw)
In-Reply-To: <f1b934f4-e228-e6e3-496d-d8287018602e@amd.com>

On 2/21/2018 8:47 AM, Tom Lendacky wrote:
> On 2/21/2018 8:32 AM, Paolo Bonzini wrote:
>> On 21/02/2018 15:15, Tom Lendacky wrote:
>>> On 2/21/2018 5:41 AM, Paolo Bonzini wrote:
>>>> On 16/02/2018 00:12, Tom Lendacky wrote:
>>>>> +static u32 msr_based_features[] = {
>>>>> +};
>>>>> +
>>>>> +static unsigned int num_msr_based_features = ARRAY_SIZE(msr_based_features);
>>>>> +
>>>>>  bool kvm_valid_efer(struct kvm_vcpu *vcpu, u64 efer)
>>>>>  {
>>>>>  	if (efer & efer_reserved_bits)
>>>>> @@ -2785,6 +2794,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
>>>>>  	case KVM_CAP_SET_BOOT_CPU_ID:
>>>>>   	case KVM_CAP_SPLIT_IRQCHIP:
>>>>>  	case KVM_CAP_IMMEDIATE_EXIT:
>>>>> +	case KVM_CAP_GET_MSR_FEATURES:
>>>>>  		r = 1;
>>>>>  		break;
>>>>>  	case KVM_CAP_ADJUST_CLOCK:
>>>>> @@ -4410,6 +4420,47 @@ long kvm_arch_vm_ioctl(struct file *filp,
>>>>>  			r = kvm_x86_ops->mem_enc_unreg_region(kvm, &region);
>>>>>  		break;
>>>>>  	}
>>>>> +	case KVM_GET_MSR_INDEX_LIST: {
>>>>> +		struct kvm_msr_list __user *user_msr_list = argp;
>>>>> +		struct kvm_msr_list msr_list;
>>>>> +		unsigned int n;
>>>>> +
>>>>> +		r = -EFAULT;
>>>>> +		if (copy_from_user(&msr_list, user_msr_list, sizeof(msr_list)))
>>>>> +			goto out;
>>>>> +		n = msr_list.nmsrs;
>>>>> +		msr_list.nmsrs = num_msr_based_features;
>>>>> +		if (copy_to_user(user_msr_list, &msr_list, sizeof(msr_list)))
>>>>> +			goto out;
>>>>> +		r = -E2BIG;
>>>>> +		if (n < msr_list.nmsrs)
>>>>> +			goto out;
>>>>> +		r = -EFAULT;
>>>>> +		if (copy_to_user(user_msr_list->indices, &msr_based_features,
>>>>> +				 num_msr_based_features * sizeof(u32)))
>>>>> +			goto out;
>>>>> +		r = 0;
>>>>> +		break;
>>>>
>>>> I think it's better to have some logic in kvm_init_msr_list, to filter
>>>> the MSR list based on whatever MSRs the backend provides.
>>>
>>> Ok, that's what I had originally and then you said to just return the full
>>> list and let KVM_GET_MSR return a 0 or 1 if it was supported. I can switch
>>> it back.
>>
>> Hmm, I cannot find this remark (I would have been very confused, so I
>> tried to look for it).  I commented on removing kvm_valid_msr_feature,
>> but not kvm_init_msr_list.
> 
> I think this is the reply that sent me off on that track:
>   https://marc.info/?l=linux-kernel&m=151862648123153&w=2
> 
> I'll make it consistent with the other MSR-related items and initialize
> the list in kvm_init_msr_list().  I'll change the signature of the
> msr_feature() kvm_x86_ops callback to take an index and optionally return
> a data value so it can be used to check for support when building the
> list and return a value when needed.

Hmm, actually I'll just leave the signature alone and pass in a local
kvm_msr_entry struct variable for the call when initializing the list.

Thanks,
Tom

> 
> Thanks,
> Tom
> 
>>
>>>>
>>>>> +	}
>>>>> +	case KVM_GET_MSR: {
>>>>
>>>> It's not that the API isn't usable, KVM_GET_MSR is fine for what we need
>>>> here (it's not a fast path), but it's a bit confusing to have
>>>> KVM_GET_MSR and KVM_GET_MSRS.
>>>>
>>>> I see two possibilities:
>>>>
>>>> 1) reuse KVM_GET_MSRS as in the previous version.  It's okay to
>>>> cut-and-paste code from msr_io.
>>>
>>> If I go back to trimming the list based on support, then KVM_GET_MSRS can
>>> be used.
>>
>> No problem, renaming is enough---I should have made a better suggestion
>> in the previous review.
>>
>> Paolo
>>

  reply	other threads:[~2018-02-21 14:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 23:11 [PATCH v2 0/2] KVM: " Tom Lendacky
2018-02-15 23:12 ` [PATCH v2 1/2] KVM: x86: Add a framework for supporting " Tom Lendacky
2018-02-21 11:41   ` Paolo Bonzini
2018-02-21 14:15     ` Tom Lendacky
2018-02-21 14:32       ` Paolo Bonzini
2018-02-21 14:47         ` Tom Lendacky
2018-02-21 14:52           ` Tom Lendacky [this message]
2018-02-21 16:36             ` Paolo Bonzini
2018-02-15 23:12 ` [PATCH v2 2/2] KVM: SVM: Add MSR-based feature support for serializing LFENCE Tom Lendacky
2018-02-21 11:42   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d77a8a6e-d10b-82d9-6df4-7ed5505ef40f@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=bp@alien8.de \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®