KVM: nVMX: fix comments of handle_vmon()
PATCH 1/1 KVM: nVMX: fix comments of handle_vmon()
"VMXON pointer" is saved in vmx->nested.vmxon_ptr since commit 3573e22cfeca ("KVM: nVMX: additional checks on vmxon region"). Also, handle_vmptrld() & handle_vmclear() now have logic to check the VMCS pointer against the VMXON pointer.
So just remove the obsolete comments of handle_vmon().
--- arch/x86/kvm/vmx/nested.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
arch/x86/kvm/vmx/nested.c +1 -8
@@ -4862,14 +4862,7 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)return -ENOMEM ; } -/* -* Emulate the VMXON instruction. -* Currently, we just remember that VMX is active, and do not save or even -* inspect the argument to VMXON (the so-called "VMXON pointer") because we -* do not currently need to store anything in that guest-allocated memory -* region. Consequently, VMCLEAR and VMPTRLD also do not verify that the their -* argument is different from the VMXON pointer (which the spec says they do). -*/ +/* Emulate the VMXON instruction. */ static int handle_vmon (struct kvm_vcpu *vcpu) {int ret;
Signature · 1 line
2.17.1
Quoted 23 lines · Yu Zhang
"VMXON pointer" is saved in
vmx->nested.vmxon_ptrsince commit3573e22cfeca("KVM: nVMX: additional checks on vmxon region"). Also,handle_vmptrld()&handle_vmclear()now have logic to check the VMCS pointer against the VMXON pointer.So just remove the obsolete comments of
handle_vmon().Signed-off-by Yu Zhang <[email protected]>--- arch/x86/kvm/vmx/nested.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)arch/x86/kvm/vmx/nested.c +0
-2@@ -4862,14 +4862,7 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)return -ENOMEM ; } -/* -* Emulate the VMXON instruction.
arch/x86/kvm/vmx/nested.c static int enter_vmx_operation(struct kvm_vcpu *vcpu) · line 4868
Quoted 10 lines
arch/x86/kvm/vmx/nested.c +1
-6-* Currently, we just remember that VMX is active, and do not save or even -* inspect the argument to VMXON (the so-called "VMXON pointer") because we -* do not currently need to store anything in that guest-allocated memory -* region. Consequently, VMCLEAR and VMPTRLD also do not verify that the their -* argument is different from the VMXON pointer (which the spec says they do). -*/ +/* Emulate the VMXON instruction. */ static int handle_vmon (struct kvm_vcpu *vcpu) {int ret;
Indeed,
On a slightly related note: we don't seem to reset 'vmx->nested.vmxon_ptr' upon VMXOFF emulation; this is not a problem per se as we never access it when !vmx->nested.vmxon but I'd still suggest we do something like
arch/x86/kvm/vmx/nested.c +1 -0
@@ -290,6 +290,7 @@ static void free_nested(struct kvm_vcpu *vcpu) vmx->nested.vmxon = false; vmx->nested.smm.vmxon = false; + vmx->nested.vmxon_ptr =-1ull ;free_vpid (vmx->nested.vpid02); vmx->nested.posted_intr_nv =-1 ; vmx->nested.current_vmptr =-1ull ;
arch/x86/kvm/vmx/vmx.c +1 -0
@@ -6884,6 +6884,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 ;
to avoid issues in the future.
Signature · 1 line
Vitaly
Quoted 34 lines · Vitaly Kuznetsov
Indeed,
Reviewed-by Vitaly Kuznetsov <[email protected]>On a slightly related note: we don't seem to reset '
vmx->nested.vmxon_ptr' upon VMXOFF emulation; this is not a problem per se as we never access it when !vmx->nested.vmxon but I'd still suggest we do something likearch/x86/kvm/vmx/nested.c +1
-0@@ -290,6 +290,7 @@ static void free_nested(struct kvm_vcpu *vcpu) vmx->nested.vmxon = false; vmx->nested.smm.vmxon = false; + vmx->nested.vmxon_ptr =-1ull ;free_vpid (vmx->nested.vpid02); vmx->nested.posted_intr_nv =-1 ; vmx->nested.current_vmptr =-1ull ;arch/x86/kvm/vmx/vmx.c +1
-0@@ -6884,6 +6884,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 ;
Quoted 2 lines
to avoid issues in the future.
Thanks, Vitaly. And above suggestion sounds reasonable to me. :)
I can add this in V2 later, if no one objects.
B.R.
Yu
Quoted 35 lines · Yu Zhang
Quoted 34 lines · Vitaly Kuznetsov
Indeed,
Reviewed-by Vitaly Kuznetsov <[email protected]>On a slightly related note: we don't seem to reset '
vmx->nested.vmxon_ptr' upon VMXOFF emulation; this is not a problem per se as we never access it when !vmx->nested.vmxon but I'd still suggest we do something likearch/x86/kvm/vmx/nested.c +1
-0@@ -290,6 +290,7 @@ static void free_nested(struct kvm_vcpu *vcpu) vmx->nested.vmxon = false; vmx->nested.smm.vmxon = false; + vmx->nested.vmxon_ptr =-1ull ;free_vpid (vmx->nested.vpid02); vmx->nested.posted_intr_nv =-1 ; vmx->nested.current_vmptr =-1ull ;arch/x86/kvm/vmx/vmx.c +1
-0@@ -6884,6 +6884,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 ;
Quoted 6 lines
Quoted 2 lines
to avoid issues in the future.
Thanks, Vitaly. And above suggestion sounds reasonable to me. :)
I can add this in V2 later, if no one objects.
Sure, this is rather a separate patch. Thanks!
Signature · 1 line
Vitaly
Quoted 2 lines · Vitaly Kuznetsov
Sure, this is rather a separate patch. Thanks!
Oh, right. Just sent out a seperate patch. :)
@Paolo Any comment on this one? Thanks!
B.R.
Yu
Quoted 24 lines · Yu Zhang
"VMXON pointer" is saved in
vmx->nested.vmxon_ptrsince commit3573e22cfeca("KVM: nVMX: additional checks on vmxon region"). Also,handle_vmptrld()&handle_vmclear()now have logic to check the VMCS pointer against the VMXON pointer.So just remove the obsolete comments of
handle_vmon().Signed-off-by Yu Zhang <[email protected]>--- arch/x86/kvm/vmx/nested.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)arch/x86/kvm/vmx/nested.c +0
-2@@ -4862,14 +4862,7 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu)return -ENOMEM ; } -/* -* Emulate the VMXON instruction.
arch/x86/kvm/vmx/nested.c static int enter_vmx_operation(struct kvm_vcpu *vcpu) · line 4868
Quoted 10 lines
arch/x86/kvm/vmx/nested.c +1
-6-* Currently, we just remember that VMX is active, and do not save or even -* inspect the argument to VMXON (the so-called "VMXON pointer") because we -* do not currently need to store anything in that guest-allocated memory -* region. Consequently, VMCLEAR and VMPTRLD also do not verify that the their -* argument is different from the VMXON pointer (which the spec says they do). -*/ +/* Emulate the VMXON instruction. */ static int handle_vmon (struct kvm_vcpu *vcpu) {int ret;
Queued, thanks.
Paolo