KVM: nVMX: KVM_SET_NESTED_STATE - Tear down old EVMCS state before setting new state
PATCH 2/3 KVM: nVMX: KVM_SET_NESTED_STATE - Tear down old EVMCS state before setting new state
Move call to nested_enable_evmcs until after free_nested() is complete.
--- arch/x86/kvm/vmx/nested.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kvm/vmx/nested.c +3 -3
@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;
@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)
Signature · 1 line
2.21.0.593.g511ec345e18-goog
Quoted 24 lines · Aaron Lewis
Move call to
nested_enable_evmcsuntil afterfree_nested()is complete.Signed-off-by Aaron Lewis <[email protected]>Reviewed-by Marc Orr <[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
-3@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;
arch/x86/kvm/vmx/nested.c static int vmx_set_nested_state(struct kvm_vcpu *vcpu, · line 5422
Quoted 9 lines
arch/x86/kvm/vmx/nested.c +3
-0@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)
nested_enable_evmcs() doesn't do much, actually, in case it was previously enabled it doesn't do anything and in case it wasn't ordering with free_nested() (where you're aiming at nested_release_evmcs() I would guess) shouldn't matter. So could you please elaborate (better in the commit message) why do we need this re-ordered? My guess is that you'd like to perform checks for e.g. 'vmx.vmxon_pa == -1ull' before we actually start doing any changes but let's clarify that.
Thanks!
Signature · 1 line
Vitaly
From: Vitaly Kuznetsov <[email protected]>
Date: Fri, May 3, 2019 at 3:25 AM
To: Aaron Lewis
Cc: Peter Shier, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>
Quoted 44 lines
Quoted 24 lines · Aaron Lewis
Move call to
nested_enable_evmcsuntil afterfree_nested()is complete.Signed-off-by Aaron Lewis <[email protected]>Reviewed-by Marc Orr <[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
-3@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;arch/x86/kvm/vmx/nested.c static int vmx_set_nested_state(struct kvm_vcpu *vcpu, · line 5422
Quoted 9 lines
arch/x86/kvm/vmx/nested.c +3
-0@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)
nested_enable_evmcs()doesn't do much, actually, in case it was previously enabled it doesn't do anything and in case it wasn't ordering withfree_nested()(where you're aiming atnested_release_evmcs()I would guess) shouldn't matter. So could you please elaborate (better in the commit message) why do we need this re-ordered? My guess is that you'd like to perform checks for e.g. 'vmx.vmxon_pa == -1ull' before we actually start doing any changes but let's clarify that.
Quoted 4 lines
Thanks!
--
Vitaly
There are two reasons for doing this:
1. We don't want to set new state if we are going to leave nesting and exit the function (ie: vmx.vmxon_pa = -1), like you pointed out.
2. To be more future proof, we don't want to set new state before tearing down state. This could cause conflicts down the road.
I can add this to the commit message if there are no objections to these points.
Quoted 55 lines · Aaron Lewis
From: Vitaly Kuznetsov <[email protected]>
Date: Fri, May 3, 2019 at 3:25 AM
To: Aaron Lewis
Cc: Peter Shier, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>Quoted 44 lines
Quoted 24 lines · Aaron Lewis
Move call to
nested_enable_evmcsuntil afterfree_nested()is complete.Signed-off-by Aaron Lewis <[email protected]>Reviewed-by Marc Orr <[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
-3@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;arch/x86/kvm/vmx/nested.c static int vmx_set_nested_state(struct kvm_vcpu *vcpu, · line 5422
Quoted 9 lines
arch/x86/kvm/vmx/nested.c +3
-0@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)
nested_enable_evmcs()doesn't do much, actually, in case it was previously enabled it doesn't do anything and in case it wasn't ordering withfree_nested()(where you're aiming atnested_release_evmcs()I would guess) shouldn't matter. So could you please elaborate (better in the commit message) why do we need this re-ordered? My guess is that you'd like to perform checks for e.g. 'vmx.vmxon_pa == -1ull' before we actually start doing any changes but let's clarify that.Quoted 4 lines
Thanks!
--
Vitaly
Quoted 8 lines
There are two reasons for doing this:
1. We don't want to set new state if we are going to leave nesting and exit the function (ie: vmx.vmxon_pa = -1), like you pointed out.
2. To be more future proof, we don't want to set new state before tearing down state. This could cause conflicts down the road.I can add this to the commit message if there are no objections to these points.
Sounds good to me, please do. Thanks!
Signature · 1 line
Vitaly
From: Vitaly Kuznetsov <[email protected]>
Date: Wed, May 8, 2019 at 12:55 PM
To: Aaron Lewis
Cc: Peter Shier, Paolo Bonzini, <[email protected]>, Jim Mattson, Marc Orr, <[email protected]>
Quoted 63 lines
Quoted 61 lines · Aaron Lewis
From: Vitaly Kuznetsov <[email protected]>
Date: Fri, May 3, 2019 at 3:25 AM
To: Aaron Lewis
Cc: Peter Shier, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>Quoted 44 lines
Quoted 24 lines · Aaron Lewis
Move call to
nested_enable_evmcsuntil afterfree_nested()is complete.Signed-off-by Aaron Lewis <[email protected]>Reviewed-by Marc Orr <[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
-3@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;arch/x86/kvm/vmx/nested.c static int vmx_set_nested_state(struct kvm_vcpu *vcpu, · line 5422
Quoted 9 lines
arch/x86/kvm/vmx/nested.c +3
-0@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)
nested_enable_evmcs()doesn't do much, actually, in case it was previously enabled it doesn't do anything and in case it wasn't ordering withfree_nested()(where you're aiming atnested_release_evmcs()I would guess) shouldn't matter. So could you please elaborate (better in the commit message) why do we need this re-ordered? My guess is that you'd like to perform checks for e.g. 'vmx.vmxon_pa == -1ull' before we actually start doing any changes but let's clarify that.Quoted 4 lines
Thanks!
--
VitalyThere are two reasons for doing this:
1. We don't want to set new state if we are going to leave nesting and exit the function (ie: vmx.vmxon_pa = -1), like you pointed out.
2. To be more future proof, we don't want to set new state before tearing down state. This could cause conflicts down the road.
Quoted 7 lines
Quoted 2 lines
I can add this to the commit message if there are no objections to these points.
Sounds good to me, please do. Thanks!
--
Vitaly
Here is the updated patch:
Move call to nested_enable_evmcs until after free_nested() is complete. There are two reasons for doing this:
1. We don't want to set new state if we are going to leave nesting and exit the function (ie: vmx.vmxon_pa = -1).
2. To be more future proof, we don't want to set new state before tearing down state. This could cause conflicts down the road.
--- arch/x86/kvm/vmx/nested.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/kvm/vmx/nested.c +3 -3
@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;
@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)
Quoted 110 lines · Aaron Lewis
From: Vitaly Kuznetsov <[email protected]>
Date: Wed, May 8, 2019 at 12:55 PM
To: Aaron Lewis
Cc: Peter Shier, Paolo Bonzini, <[email protected]>, Jim Mattson, Marc Orr, <[email protected]>Quoted 63 lines
Quoted 61 lines · Aaron Lewis
From: Vitaly Kuznetsov <[email protected]>
Date: Fri, May 3, 2019 at 3:25 AM
To: Aaron Lewis
Cc: Peter Shier, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>Quoted 44 lines
Quoted 24 lines · Aaron Lewis
Move call to
nested_enable_evmcsuntil afterfree_nested()is complete.Signed-off-by Aaron Lewis <[email protected]>Reviewed-by Marc Orr <[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
-3@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;arch/x86/kvm/vmx/nested.c static int vmx_set_nested_state(struct kvm_vcpu *vcpu, · line 5422
Quoted 9 lines
arch/x86/kvm/vmx/nested.c +3
-0@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)
nested_enable_evmcs()doesn't do much, actually, in case it was previously enabled it doesn't do anything and in case it wasn't ordering withfree_nested()(where you're aiming atnested_release_evmcs()I would guess) shouldn't matter. So could you please elaborate (better in the commit message) why do we need this re-ordered? My guess is that you'd like to perform checks for e.g. 'vmx.vmxon_pa == -1ull' before we actually start doing any changes but let's clarify that.Quoted 4 lines
Thanks!
--
VitalyThere are two reasons for doing this:
1. We don't want to set new state if we are going to leave nesting and exit the function (ie: vmx.vmxon_pa = -1), like you pointed out.
2. To be more future proof, we don't want to set new state before tearing down state. This could cause conflicts down the road.Quoted 7 lines
Quoted 2 lines
I can add this to the commit message if there are no objections to these points.
Sounds good to me, please do. Thanks!
--
VitalyHere is the updated patch:
Move call to
nested_enable_evmcsuntil afterfree_nested()is complete. There are two reasons for doing this:
1. We don't want to set new state if we are going to leave nesting and exit the function (ie: vmx.vmxon_pa = -1).
2. To be more future proof, we don't want to set new state before tearing down state. This could cause conflicts down the road.Signed-off-by Aaron Lewis <[email protected]>Reviewed-by Marc Orr <[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
-3@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;
arch/x86/kvm/vmx/nested.c static int vmx_set_nested_state(struct kvm_vcpu *vcpu, · line 5422
Quoted 9 lines
arch/x86/kvm/vmx/nested.c +3
-0@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)
Hi Vitaly,
Does this update look good or are any other changes needed?
Thanks,
Aaron
Quoted 123 lines · Aaron Lewis
Quoted 110 lines · Aaron Lewis
From: Vitaly Kuznetsov <[email protected]>
Date: Wed, May 8, 2019 at 12:55 PM
To: Aaron Lewis
Cc: Peter Shier, Paolo Bonzini, <[email protected]>, Jim Mattson, Marc Orr, <[email protected]>Quoted 63 lines
Quoted 61 lines · Aaron Lewis
From: Vitaly Kuznetsov <[email protected]>
Date: Fri, May 3, 2019 at 3:25 AM
To: Aaron Lewis
Cc: Peter Shier, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>, <[email protected]>Quoted 44 lines
Quoted 24 lines · Aaron Lewis
Move call to
nested_enable_evmcsuntil afterfree_nested()is complete.Signed-off-by Aaron Lewis <[email protected]>Reviewed-by Marc Orr <[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
-3@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;arch/x86/kvm/vmx/nested.c static int vmx_set_nested_state(struct kvm_vcpu *vcpu, · line 5422
Quoted 9 lines
arch/x86/kvm/vmx/nested.c +3
-0@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)
nested_enable_evmcs()doesn't do much, actually, in case it was previously enabled it doesn't do anything and in case it wasn't ordering withfree_nested()(where you're aiming atnested_release_evmcs()I would guess) shouldn't matter. So could you please elaborate (better in the commit message) why do we need this re-ordered? My guess is that you'd like to perform checks for e.g. 'vmx.vmxon_pa == -1ull' before we actually start doing any changes but let's clarify that.Quoted 4 lines
Thanks!
--
VitalyThere are two reasons for doing this:
1. We don't want to set new state if we are going to leave nesting and exit the function (ie: vmx.vmxon_pa = -1), like you pointed out.
2. To be more future proof, we don't want to set new state before tearing down state. This could cause conflicts down the road.Quoted 7 lines
Quoted 2 lines
I can add this to the commit message if there are no objections to these points.
Sounds good to me, please do. Thanks!
--
VitalyHere is the updated patch:
Move call to
nested_enable_evmcsuntil afterfree_nested()is complete. There are two reasons for doing this:
1. We don't want to set new state if we are going to leave nesting and exit the function (ie: vmx.vmxon_pa = -1).
2. To be more future proof, we don't want to set new state before tearing down state. This could cause conflicts down the road.Signed-off-by Aaron Lewis <[email protected]>Reviewed-by Marc Orr <[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
-3@@ -5373,9 +5373,6 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->format !=0 )return -EINVAL ; -if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) -nested_enable_evmcs (vcpu,NULL ); -if (!nested_vmx_allowed (vcpu))return kvm_state->vmx.vmxon_pa ==-1ull ?0 : -EINVAL ;arch/x86/kvm/vmx/nested.c static int vmx_set_nested_state(struct kvm_vcpu *vcpu, · line 5422
Quoted 9 lines
arch/x86/kvm/vmx/nested.c +3
-0@@ -5417,6 +5414,9 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu,if (kvm_state->vmx.vmxon_pa ==-1ull )return 0 ; +if (kvm_state->flags &KVM_STATE_NESTED_EVMCS ) +nested_enable_evmcs (vcpu,NULL ); + vmx->nested.vmxon_ptr = kvm_state->vmx.vmxon_pa; ret =enter_vmx_operation (vcpu);if (ret)Hi Vitaly,
Quoted 2 lines
Does this update look good or are any other changes needed?
Hi Aaron,
my apologies for not replying earlier. The changelog looks good to me now, thanks!
Signature · 1 line
Vitaly