lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 21 Feb 2018 08:15:36 -0600
From:   Tom Lendacky <thomas.lendacky@....com>
To:     Paolo Bonzini <pbonzini@...hat.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Cc:     Joerg Roedel <joro@...tes.org>, Borislav Petkov <bp@...en8.de>,
        Thomas Gleixner <tglx@...utronix.de>,
        Radim Krčmář <rkrcmar@...hat.com>
Subject: Re: [PATCH v2 1/2] KVM: x86: Add a framework for supporting MSR-based
 features

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.

> 
>> +	}
>> +	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.

Thanks,
Tom

> 
> 2) find a name for KVM_GET_MSR that is better and different from
> KVM_GET_MSRS.  KVM_GET_HOST_MSR or KVM_GET_HOST_FEATURE_MSR come to
> mind, but I'm obviously open to other suggestions.
> 
> Thanks!
> 
> Paolo
> 
>> +		struct kvm_msr_entry __user *user_msr = argp;
>> +		struct kvm_msr_entry msr;
>> +
>> +		r = -EFAULT;
>> +		if (copy_from_user(&msr, user_msr, sizeof(msr)))
>> +			goto out;
>> +
>> +		r = 1;
>> +		if (!kvm_x86_ops->msr_feature || kvm_x86_ops->msr_feature(&msr))
>> +			goto out;
>> +
>> +		r = -EFAULT;
>> +		if (copy_to_user(user_msr, &msr, sizeof(msr)))
>> +			goto out;
>> +
>> +		r = 0;
>> +		break;
>> +	}
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ