lkml.org 
[lkml]   [2021]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4 3/6] KVM: VMX: Detect Tertiary VM-Execution control when setup VMCS config
From
Date
On 9/11/2021 5:35 AM, Sean Christopherson wrote:
> On Mon, Aug 09, 2021, Zeng Guang wrote:
>> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
>> index 927a552393b9..ee8c5664dc95 100644
>> --- a/arch/x86/kvm/vmx/vmx.c
>> +++ b/arch/x86/kvm/vmx/vmx.c
>> @@ -2391,6 +2391,23 @@ static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt,
>> return 0;
>> }
>>
>> +static __init int adjust_vmx_controls_64(u64 ctl_min, u64 ctl_opt,
>> + u32 msr, u64 *result)
>> +{
>> + u64 vmx_msr;
>> + u64 ctl = ctl_min | ctl_opt;
>> +
>> + rdmsrl(msr, vmx_msr);
>> + ctl &= vmx_msr; /* bit == 1 means it can be set */
>> +
>> + /* Ensure minimum (required) set of control bits are supported. */
>> + if (ctl_min & ~ctl)
>> + return -EIO;
>> +
>> + *result = ctl;
>> + return 0;
>> +}
> More succinctly, since we don't need to force-set bits in the final value:
>
> u64 allowed1;
>
> rdmsrl(msr, allowed1);
>
> /* Ensure minimum (required) set of control bits are supported. */
> if (ctl_min & ~allowed1)
> return -EIO;
>
> *result = (ctl_min | ctl_opt) & allowed1;
> return 0;
Yes, it becomes more concise. I will change it . Thanks.
>> static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
>> struct vmx_capability *vmx_cap)
>> {

\
 
 \ /
  Last update: 2021-09-17 18:18    [W:0.062 / U:0.588 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site