Commit 145c28dd authored by Abel Gordon's avatar Abel Gordon Committed by Gleb Natapov
Browse files

KVM: nVMX: Fix VMXON emulation

handle_vmon doesn't check if L1 is already in root mode (VMXON
was previously called). This patch adds this missing check and calls
nested_vmx_failValid if VMX is already ON.
We need this check because L0 will allocate the shadow vmcs when L1
executes VMXON and we want to avoid host leaks (due to shadow vmcs
allocation) if L1 executes VMXON repeatedly.

Signed-off-by: default avatarAbel Gordon <>
Reviewed-by: default avatarOrit Wasserman <>
Signed-off-by: default avatarGleb Natapov <>
parent 20b97fea
......@@ -5512,6 +5512,9 @@ static void nested_free_all_saved_vmcss(struct vcpu_vmx *vmx)
static void nested_vmx_failValid(struct kvm_vcpu *vcpu,
u32 vm_instruction_error);
* Emulate the VMXON instruction.
* Currently, we just remember that VMX is active, and do not save or even
......@@ -5547,6 +5550,11 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
kvm_inject_gp(vcpu, 0);
return 1;
if (vmx->nested.vmxon) {
nested_vmx_failValid(vcpu, VMXERR_VMXON_IN_VMX_ROOT_OPERATION);
return 1;
vmx->nested.vmcs02_num = 0;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment