[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <72e39861-7af4-057c-f879-4cc5a363e3e4@intel.com>
Date: Mon, 15 Jul 2019 09:11:31 +0800
From: Tao Xu <tao3.xu@...el.com>
To: Sean Christopherson <sean.j.christopherson@...el.com>
Cc: pbonzini@...hat.com, rkrcmar@...hat.com, corbet@....net,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
fenghua.yu@...el.com, xiaoyao.li@...ux.intel.com,
jingqi.liu@...el.com
Subject: Re: [PATCH v7 1/3] KVM: x86: add support for user wait instructions
On 7/12/2019 11:13 PM, Sean Christopherson wrote:
> On Fri, Jul 12, 2019 at 04:29:05PM +0800, Tao Xu wrote:
>> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
>> index 46af3a5e9209..a4d5da34b306 100644
>> --- a/arch/x86/kvm/vmx/nested.c
>> +++ b/arch/x86/kvm/vmx/nested.c
>> @@ -2048,6 +2048,7 @@ static void prepare_vmcs02_early(struct vcpu_vmx *vmx, struct vmcs12 *vmcs12)
>> SECONDARY_EXEC_ENABLE_INVPCID |
>> SECONDARY_EXEC_RDTSCP |
>> SECONDARY_EXEC_XSAVES |
>> + SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE |
>> SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
>> SECONDARY_EXEC_APIC_REGISTER_VIRT |
>> SECONDARY_EXEC_ENABLE_VMFUNC);
>> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
>> index d98eac371c0a..f411c9ae5589 100644
>> --- a/arch/x86/kvm/vmx/vmx.c
>> +++ b/arch/x86/kvm/vmx/vmx.c
>> @@ -2247,6 +2247,7 @@ static __init int setup_vmcs_config(struct vmcs_config *vmcs_conf,
>> SECONDARY_EXEC_RDRAND_EXITING |
>> SECONDARY_EXEC_ENABLE_PML |
>> SECONDARY_EXEC_TSC_SCALING |
>> + SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE |
>> SECONDARY_EXEC_PT_USE_GPA |
>> SECONDARY_EXEC_PT_CONCEAL_VMX |
>> SECONDARY_EXEC_ENABLE_VMFUNC |
>> @@ -3984,6 +3985,25 @@ static void vmx_compute_secondary_exec_control(struct vcpu_vmx *vmx)
>> }
>> }
>>
>> + if (vmcs_config.cpu_based_2nd_exec_ctrl &
>> + SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE) {
>
> This should be aligned with the beginning of the conditional.
> Alternatively, add a vmx_waitpkg_supported() helper, which is fairly
> ubiquitous even when there is only a single call site.
>
OK, Thank you for your suggestion.
>> + /* Exposing WAITPKG only when WAITPKG is exposed */
> No need for this comment. It's also oddly worded, e.g. the second
> "exposed" should probably be "enabled"?
>
>> + bool waitpkg_enabled =
>> + guest_cpuid_has(vcpu, X86_FEATURE_WAITPKG);
>> +
>> + if (!waitpkg_enabled)
>> + exec_control &= ~SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE;
>> +
>> + if (nested) {
>> + if (waitpkg_enabled)
>> + vmx->nested.msrs.secondary_ctls_high |=
>> + SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE;
>> + else
>> + vmx->nested.msrs.secondary_ctls_high &=
>> + ~SECONDARY_EXEC_ENABLE_USR_WAIT_PAUSE;
>> + }
>> + }
>> +
>> vmx->secondary_exec_control = exec_control;
>> }
>>
>> --
>> 2.20.1
>>
Powered by blists - more mailing lists