* Re: [PATCH] KVM: nVMX: Reset vmxon_ptr upon VMXOFF emulation.
2021-09-09 12:48 [PATCH] KVM: nVMX: Reset vmxon_ptr upon VMXOFF emulation Yu Zhang
@ 2021-09-09 5:19 ` Vitaly Kuznetsov
2021-09-09 7:22 ` Yu Zhang
2021-09-09 16:20 ` Sean Christopherson
1 sibling, 1 reply; 5+ messages in thread
From: Vitaly Kuznetsov @ 2021-09-09 5:19 UTC (permalink / raw)
To: Yu Zhang, seanjc, pbonzini; +Cc: kvm, linux-kernel, wanpengli, jmattson, joro
Yu Zhang <yu.c.zhang@linux.intel.com> writes:
> From: Vitaly Kuznetsov <vkuznets@redhat.com>
>
> Currently, 'vmx->nested.vmxon_ptr' is not reset upon VMXOFF
> emulation. This is not a problem per se as we never access
> it when !vmx->nested.vmxon. But this should be done to avoid
> any issue in the future.
>
> Also, initialize the vmxon_ptr when vcpu is created.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Thanks but even Suggested-by: would be enough :-)
> Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
> ---
> arch/x86/kvm/vmx/nested.c | 1 +
> arch/x86/kvm/vmx/vmx.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 90f34f12f883..e4260f67caac 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -289,6 +289,7 @@ static void free_nested(struct kvm_vcpu *vcpu)
> kvm_clear_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu);
>
> vmx->nested.vmxon = false;
> + vmx->nested.vmxon_ptr = -1ull;
> vmx->nested.smm.vmxon = false;
> free_vpid(vmx->nested.vpid02);
> vmx->nested.posted_intr_nv = -1;
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 0c2c0d5ae873..9a3e35c038f2 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6886,6 +6886,7 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu)
>
> vcpu_setup_sgx_lepubkeyhash(vcpu);
>
> + vmx->nested.vmxon_ptr = -1ull;
> vmx->nested.posted_intr_nv = -1;
> vmx->nested.current_vmptr = -1ull;
> vmx->nested.hv_evmcs_vmptr = EVMPTR_INVALID;
--
Vitaly
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: nVMX: Reset vmxon_ptr upon VMXOFF emulation.
2021-09-09 5:19 ` Vitaly Kuznetsov
@ 2021-09-09 7:22 ` Yu Zhang
0 siblings, 0 replies; 5+ messages in thread
From: Yu Zhang @ 2021-09-09 7:22 UTC (permalink / raw)
To: Vitaly Kuznetsov
Cc: seanjc, pbonzini, kvm, linux-kernel, wanpengli, jmattson, joro
On Thu, Sep 09, 2021 at 07:19:53AM +0200, Vitaly Kuznetsov wrote:
>
> Thanks but even Suggested-by: would be enough :-)
>
I just copied your code. And actually I should be the one to say thanks. :)
B.R.
Yu
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] KVM: nVMX: Reset vmxon_ptr upon VMXOFF emulation.
@ 2021-09-09 12:48 Yu Zhang
2021-09-09 5:19 ` Vitaly Kuznetsov
2021-09-09 16:20 ` Sean Christopherson
0 siblings, 2 replies; 5+ messages in thread
From: Yu Zhang @ 2021-09-09 12:48 UTC (permalink / raw)
To: seanjc, pbonzini, vkuznets; +Cc: kvm, linux-kernel, wanpengli, jmattson, joro
From: Vitaly Kuznetsov <vkuznets@redhat.com>
Currently, 'vmx->nested.vmxon_ptr' is not reset upon VMXOFF
emulation. This is not a problem per se as we never access
it when !vmx->nested.vmxon. But this should be done to avoid
any issue in the future.
Also, initialize the vmxon_ptr when vcpu is created.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
---
arch/x86/kvm/vmx/nested.c | 1 +
arch/x86/kvm/vmx/vmx.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 90f34f12f883..e4260f67caac 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -289,6 +289,7 @@ static void free_nested(struct kvm_vcpu *vcpu)
kvm_clear_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu);
vmx->nested.vmxon = false;
+ vmx->nested.vmxon_ptr = -1ull;
vmx->nested.smm.vmxon = false;
free_vpid(vmx->nested.vpid02);
vmx->nested.posted_intr_nv = -1;
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 0c2c0d5ae873..9a3e35c038f2 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -6886,6 +6886,7 @@ static int vmx_create_vcpu(struct kvm_vcpu *vcpu)
vcpu_setup_sgx_lepubkeyhash(vcpu);
+ vmx->nested.vmxon_ptr = -1ull;
vmx->nested.posted_intr_nv = -1;
vmx->nested.current_vmptr = -1ull;
vmx->nested.hv_evmcs_vmptr = EVMPTR_INVALID;
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: nVMX: Reset vmxon_ptr upon VMXOFF emulation.
2021-09-09 12:48 [PATCH] KVM: nVMX: Reset vmxon_ptr upon VMXOFF emulation Yu Zhang
2021-09-09 5:19 ` Vitaly Kuznetsov
@ 2021-09-09 16:20 ` Sean Christopherson
2021-09-09 16:46 ` Yu Zhang
1 sibling, 1 reply; 5+ messages in thread
From: Sean Christopherson @ 2021-09-09 16:20 UTC (permalink / raw)
To: Yu Zhang; +Cc: pbonzini, vkuznets, kvm, linux-kernel, wanpengli, jmattson, joro
On Thu, Sep 09, 2021, Yu Zhang wrote:
> From: Vitaly Kuznetsov <vkuznets@redhat.com>
>
> Currently, 'vmx->nested.vmxon_ptr' is not reset upon VMXOFF
> emulation. This is not a problem per se as we never access
> it when !vmx->nested.vmxon. But this should be done to avoid
> any issue in the future.
>
> Also, initialize the vmxon_ptr when vcpu is created.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
> ---
> arch/x86/kvm/vmx/nested.c | 1 +
> arch/x86/kvm/vmx/vmx.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 90f34f12f883..e4260f67caac 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -289,6 +289,7 @@ static void free_nested(struct kvm_vcpu *vcpu)
> kvm_clear_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu);
>
> vmx->nested.vmxon = false;
> + vmx->nested.vmxon_ptr = -1ull;
Looks like the "-1ull" comes from current_vmptr and friends, but using INVALID_GPA
is more appropriate. It's the same value, but less arbitrary. The other usage of
-1ull for guest physical addresses should really be cleaned up, too.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] KVM: nVMX: Reset vmxon_ptr upon VMXOFF emulation.
2021-09-09 16:20 ` Sean Christopherson
@ 2021-09-09 16:46 ` Yu Zhang
0 siblings, 0 replies; 5+ messages in thread
From: Yu Zhang @ 2021-09-09 16:46 UTC (permalink / raw)
To: Sean Christopherson
Cc: pbonzini, vkuznets, kvm, linux-kernel, wanpengli, jmattson, joro
On Thu, Sep 09, 2021 at 04:20:35PM +0000, Sean Christopherson wrote:
> On Thu, Sep 09, 2021, Yu Zhang wrote:
> > From: Vitaly Kuznetsov <vkuznets@redhat.com>
> >
> > Currently, 'vmx->nested.vmxon_ptr' is not reset upon VMXOFF
> > emulation. This is not a problem per se as we never access
> > it when !vmx->nested.vmxon. But this should be done to avoid
> > any issue in the future.
> >
> > Also, initialize the vmxon_ptr when vcpu is created.
> >
> > Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> > Signed-off-by: Yu Zhang <yu.c.zhang@linux.intel.com>
> > ---
> > arch/x86/kvm/vmx/nested.c | 1 +
> > arch/x86/kvm/vmx/vmx.c | 1 +
> > 2 files changed, 2 insertions(+)
> >
> > diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> > index 90f34f12f883..e4260f67caac 100644
> > --- a/arch/x86/kvm/vmx/nested.c
> > +++ b/arch/x86/kvm/vmx/nested.c
> > @@ -289,6 +289,7 @@ static void free_nested(struct kvm_vcpu *vcpu)
> > kvm_clear_request(KVM_REQ_GET_NESTED_STATE_PAGES, vcpu);
> >
> > vmx->nested.vmxon = false;
> > + vmx->nested.vmxon_ptr = -1ull;
>
> Looks like the "-1ull" comes from current_vmptr and friends, but using INVALID_GPA
> is more appropriate. It's the same value, but less arbitrary. The other usage of
> -1ull for guest physical addresses should really be cleaned up, too.
>
Indeed. I guess many "-1ull"s will be replaced in nested.c.
We need another cleanup patch for this cleanup patch, which comes from my
first cleanup patch to just clean some comments.. :-) Anyway, thanks!
B.R.
Yu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-09-09 16:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-09 12:48 [PATCH] KVM: nVMX: Reset vmxon_ptr upon VMXOFF emulation Yu Zhang
2021-09-09 5:19 ` Vitaly Kuznetsov
2021-09-09 7:22 ` Yu Zhang
2021-09-09 16:20 ` Sean Christopherson
2021-09-09 16:46 ` Yu Zhang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.