kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] kvm: nVMX: Set nested_run_pending in vmx_set_nested_state after checks complete
@ 2019-05-02 18:31 Aaron Lewis
  2019-05-03 16:35 ` Sean Christopherson
  0 siblings, 1 reply; 3+ messages in thread
From: Aaron Lewis @ 2019-05-02 18:31 UTC (permalink / raw)
  To: pbonzini, rkrcmar, jmattson, marcorr, kvm; +Cc: Aaron Lewis, Peter Shier

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 <aaronlewis@google.com>
Reviewed-by: Peter Shier <pshier@google.com>
---
 arch/x86/kvm/vmx/nested.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 6401eb7ef19c..081dea6e211a 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -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;
 }
 
-- 
2.21.0.593.g511ec345e18-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] kvm: nVMX: Set nested_run_pending in vmx_set_nested_state after checks complete
  2019-05-02 18:31 [PATCH 1/3] kvm: nVMX: Set nested_run_pending in vmx_set_nested_state after checks complete Aaron Lewis
@ 2019-05-03 16:35 ` Sean Christopherson
  2019-05-08 12:11   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Sean Christopherson @ 2019-05-03 16:35 UTC (permalink / raw)
  To: Aaron Lewis; +Cc: pbonzini, rkrcmar, jmattson, marcorr, kvm, Peter Shier

On Thu, May 02, 2019 at 11:31:25AM -0700, Aaron Lewis wrote:
> 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 <aaronlewis@google.com>
> Reviewed-by: Peter Shier <pshier@google.com>
> ---
>  arch/x86/kvm/vmx/nested.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 6401eb7ef19c..081dea6e211a 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -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.

> -
>  	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;
>  }
>  
> -- 
> 2.21.0.593.g511ec345e18-goog
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/3] kvm: nVMX: Set nested_run_pending in vmx_set_nested_state after checks complete
  2019-05-03 16:35 ` Sean Christopherson
@ 2019-05-08 12:11   ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2019-05-08 12:11 UTC (permalink / raw)
  To: Sean Christopherson, Aaron Lewis
  Cc: rkrcmar, jmattson, marcorr, kvm, Peter Shier

On 03/05/19 11:35, Sean Christopherson wrote:
> @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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-08 12:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-02 18:31 [PATCH 1/3] kvm: nVMX: Set nested_run_pending in vmx_set_nested_state after checks complete Aaron Lewis
2019-05-03 16:35 ` Sean Christopherson
2019-05-08 12:11   ` Paolo Bonzini

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).