* [PATCH] KVM: nVMX: Allow restore nested-state to enable eVMCS when vCPU in SMM
@ 2019-06-25 11:26 Liran Alon
2019-06-25 13:11 ` Vitaly Kuznetsov
0 siblings, 1 reply; 3+ messages in thread
From: Liran Alon @ 2019-06-25 11:26 UTC (permalink / raw)
To: pbonzini, rkrcmar, kvm; +Cc: vkuznets, Liran Alon, Joao Martins
As comment in code specifies, SMM temporarily disables VMX so we cannot
be in guest mode, nor can VMLAUNCH/VMRESUME be pending.
However, code currently assumes that these are the only flags that can be
set on kvm_state->flags. This is not true as KVM_STATE_NESTED_EVMCS
can also be set on this field to signal that eVMCS should be enabled.
Therefore, fix code to check for guest-mode and pending VMLAUNCH/VMRESUME
explicitly.
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Liran Alon <liran.alon@oracle.com>
---
arch/x86/kvm/vmx/nested.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 5c470db311f7..27ff04874f67 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -5373,7 +5373,10 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
* nor can VMLAUNCH/VMRESUME be pending. Outside SMM, SMM flags
* must be zero.
*/
- if (is_smm(vcpu) ? kvm_state->flags : kvm_state->hdr.vmx.smm.flags)
+ if (is_smm(vcpu) ?
+ (kvm_state->flags &
+ (KVM_STATE_NESTED_GUEST_MODE | KVM_STATE_NESTED_RUN_PENDING))
+ : kvm_state->hdr.vmx.smm.flags)
return -EINVAL;
if ((kvm_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_GUEST_MODE) &&
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: nVMX: Allow restore nested-state to enable eVMCS when vCPU in SMM
2019-06-25 11:26 [PATCH] KVM: nVMX: Allow restore nested-state to enable eVMCS when vCPU in SMM Liran Alon
@ 2019-06-25 13:11 ` Vitaly Kuznetsov
2019-07-01 23:16 ` Liran Alon
0 siblings, 1 reply; 3+ messages in thread
From: Vitaly Kuznetsov @ 2019-06-25 13:11 UTC (permalink / raw)
To: Liran Alon, kvm; +Cc: pbonzini, rkrcmar, Joao Martins
Liran Alon <liran.alon@oracle.com> writes:
> As comment in code specifies, SMM temporarily disables VMX so we cannot
> be in guest mode, nor can VMLAUNCH/VMRESUME be pending.
>
> However, code currently assumes that these are the only flags that can be
> set on kvm_state->flags. This is not true as KVM_STATE_NESTED_EVMCS
> can also be set on this field to signal that eVMCS should be enabled.
>
> Therefore, fix code to check for guest-mode and pending VMLAUNCH/VMRESUME
> explicitly.
>
> Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
> Signed-off-by: Liran Alon <liran.alon@oracle.com>
> ---
> arch/x86/kvm/vmx/nested.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 5c470db311f7..27ff04874f67 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -5373,7 +5373,10 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
> * nor can VMLAUNCH/VMRESUME be pending. Outside SMM, SMM flags
> * must be zero.
> */
> - if (is_smm(vcpu) ? kvm_state->flags : kvm_state->hdr.vmx.smm.flags)
> + if (is_smm(vcpu) ?
> + (kvm_state->flags &
> + (KVM_STATE_NESTED_GUEST_MODE | KVM_STATE_NESTED_RUN_PENDING))
> + : kvm_state->hdr.vmx.smm.flags)
> return -EINVAL;
>
> if ((kvm_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_GUEST_MODE) &&
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
--
Vitaly
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: nVMX: Allow restore nested-state to enable eVMCS when vCPU in SMM
2019-06-25 13:11 ` Vitaly Kuznetsov
@ 2019-07-01 23:16 ` Liran Alon
0 siblings, 0 replies; 3+ messages in thread
From: Liran Alon @ 2019-07-01 23:16 UTC (permalink / raw)
To: Vitaly Kuznetsov; +Cc: kvm, pbonzini, rkrcmar, Joao Martins
Gentle ping.
> On 25 Jun 2019, at 16:11, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
>
> Liran Alon <liran.alon@oracle.com> writes:
>
>> As comment in code specifies, SMM temporarily disables VMX so we cannot
>> be in guest mode, nor can VMLAUNCH/VMRESUME be pending.
>>
>> However, code currently assumes that these are the only flags that can be
>> set on kvm_state->flags. This is not true as KVM_STATE_NESTED_EVMCS
>> can also be set on this field to signal that eVMCS should be enabled.
>>
>> Therefore, fix code to check for guest-mode and pending VMLAUNCH/VMRESUME
>> explicitly.
>>
>> Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
>> Signed-off-by: Liran Alon <liran.alon@oracle.com>
>> ---
>> arch/x86/kvm/vmx/nested.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
>> index 5c470db311f7..27ff04874f67 100644
>> --- a/arch/x86/kvm/vmx/nested.c
>> +++ b/arch/x86/kvm/vmx/nested.c
>> @@ -5373,7 +5373,10 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,
>> * nor can VMLAUNCH/VMRESUME be pending. Outside SMM, SMM flags
>> * must be zero.
>> */
>> - if (is_smm(vcpu) ? kvm_state->flags : kvm_state->hdr.vmx.smm.flags)
>> + if (is_smm(vcpu) ?
>> + (kvm_state->flags &
>> + (KVM_STATE_NESTED_GUEST_MODE | KVM_STATE_NESTED_RUN_PENDING))
>> + : kvm_state->hdr.vmx.smm.flags)
>> return -EINVAL;
>>
>> if ((kvm_state->hdr.vmx.smm.flags & KVM_STATE_NESTED_SMM_GUEST_MODE) &&
>
> Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>
> --
> Vitaly
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-01 23:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-25 11:26 [PATCH] KVM: nVMX: Allow restore nested-state to enable eVMCS when vCPU in SMM Liran Alon
2019-06-25 13:11 ` Vitaly Kuznetsov
2019-07-01 23:16 ` Liran Alon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).