kvm: nVMX: Set nested_run_pending in vmx_set_nested_state after checks complete
PATCH 1/3 kvm: nVMX: Set nested_run_pending in vmx_set_nested_state after checks complete
nested_run_pending=1 implies we have successfully entered guest mode. Move setting from external state in vmx_set_nested_state() until after all other checks are complete.
--- arch/x86/kvm/vmx/nested.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kvm/vmx/nested.c +3 -3
@@ -5460,9 +5460,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (!(kvm_state->flags &KVM_STATE_NESTED_GUEST_MODE ))return 0 ; - vmx->nested.nested_run_pending = - !!(kvm_state->flags &KVM_STATE_NESTED_RUN_PENDING ); -if (nested_cpu_has_shadow_vmcs (vmcs12) && vmcs12->vmcs_link_pointer !=-1ull ) {struct vmcs12 *shadow_vmcs12 =get_shadow_vmcs12 (vcpu);
@@ -5489,6 +5486,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (ret)return -EINVAL ; + vmx->nested.nested_run_pending = + !!(kvm_state->flags &KVM_STATE_NESTED_RUN_PENDING ); +return 0 ; }
Signature · 1 line
2.21.0.593.g511ec345e18-goog
Quoted 15 lines · Aaron Lewis
nested_run_pending=1 implies we have successfully entered guest mode. Move setting from external state in
vmx_set_nested_state()until after all other checks are complete.Signed-off-by Aaron Lewis <[email protected]>Reviewed-by Peter Shier <[email protected]>--- arch/x86/kvm/vmx/nested.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/x86/kvm/vmx/nested.c +0
-0
arch/x86/kvm/vmx/nested.c static int vmx_set_nested_state(struct kvm_vcpu *vcpu, · line 5464
Quoted 5 lines
arch/x86/kvm/vmx/nested.c +0
-2@@ -5460,9 +5460,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (!(kvm_state->flags &KVM_STATE_NESTED_GUEST_MODE ))return 0 ; - vmx->nested.nested_run_pending = - !!(kvm_state->flags &KVM_STATE_NESTED_RUN_PENDING );
@nested_run_pending is consumed by nested_vmx_enter_non_root_mode(), e.g. prepare_vmcs02(). I'm guessing its current location is deliberate.
Quoted 17 lines
arch/x86/kvm/vmx/nested.c +3
-1-if (nested_cpu_has_shadow_vmcs (vmcs12) && vmcs12->vmcs_link_pointer !=-1ull ) {struct vmcs12 *shadow_vmcs12 =get_shadow_vmcs12 (vcpu);@@ -5489,6 +5486,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (ret)return -EINVAL ; + vmx->nested.nested_run_pending = + !!(kvm_state->flags &KVM_STATE_NESTED_RUN_PENDING ); +return 0 ; }Signature · 1 line
2.21.0.593.g511ec345e18-goog
Paolo Bonzini
maintainerQuoted 2 lines · Sean Christopherson
@nested_run_pending is consumed by
nested_vmx_enter_non_root_mode(), e.g.prepare_vmcs02(). I'm guessing its current location is deliberate.
Right. If nested_run_pending is false, for example, GUEST_BNDCFGS must not be taken from the vmcs12.
Paolo