KVM: nVMX: Return -EINVAL when signaling failure in pre-VM-Entry helpers
Convert all top-level nested VM-Enter consistency check functions to return 0/-EINVAL instead of failure codes, since now they can only ever return one failure code. This also does not give the false impression that failure information is always consumed and/or relevant, e.g. vmx_set_nested_state() only cares whether or not the checks were successful. nested_check_host_control_regs() can also now be inlined into its caller, nested_vmx_check_host_state, since the two have effectively become the same function. Based on a patch by Sean Christopherson. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
5478ba349f
commit
98d9e858fa
@ -2595,15 +2595,12 @@ static int nested_vmx_check_controls(struct kvm_vcpu *vcpu,
|
|||||||
if (nested_check_vm_execution_controls(vcpu, vmcs12) ||
|
if (nested_check_vm_execution_controls(vcpu, vmcs12) ||
|
||||||
nested_check_vm_exit_controls(vcpu, vmcs12) ||
|
nested_check_vm_exit_controls(vcpu, vmcs12) ||
|
||||||
nested_check_vm_entry_controls(vcpu, vmcs12))
|
nested_check_vm_entry_controls(vcpu, vmcs12))
|
||||||
return VMXERR_ENTRY_INVALID_CONTROL_FIELD;
|
return -EINVAL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static int nested_vmx_check_host_state(struct kvm_vcpu *vcpu,
|
||||||
* Checks related to Host Control Registers and MSRs
|
|
||||||
*/
|
|
||||||
static int nested_check_host_control_regs(struct kvm_vcpu *vcpu,
|
|
||||||
struct vmcs12 *vmcs12)
|
struct vmcs12 *vmcs12)
|
||||||
{
|
{
|
||||||
bool ia32e;
|
bool ia32e;
|
||||||
@ -2639,15 +2636,6 @@ static int nested_check_host_control_regs(struct kvm_vcpu *vcpu,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nested_vmx_check_host_state(struct kvm_vcpu *vcpu,
|
|
||||||
struct vmcs12 *vmcs12)
|
|
||||||
{
|
|
||||||
if (nested_check_host_control_regs(vcpu, vmcs12))
|
|
||||||
return VMXERR_ENTRY_INVALID_HOST_STATE_FIELD;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int nested_vmx_check_vmcs_link_ptr(struct kvm_vcpu *vcpu,
|
static int nested_vmx_check_vmcs_link_ptr(struct kvm_vcpu *vcpu,
|
||||||
struct vmcs12 *vmcs12)
|
struct vmcs12 *vmcs12)
|
||||||
{
|
{
|
||||||
@ -3159,13 +3147,11 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
|
|||||||
launch ? VMXERR_VMLAUNCH_NONCLEAR_VMCS
|
launch ? VMXERR_VMLAUNCH_NONCLEAR_VMCS
|
||||||
: VMXERR_VMRESUME_NONLAUNCHED_VMCS);
|
: VMXERR_VMRESUME_NONLAUNCHED_VMCS);
|
||||||
|
|
||||||
ret = nested_vmx_check_controls(vcpu, vmcs12);
|
if (nested_vmx_check_controls(vcpu, vmcs12))
|
||||||
if (ret)
|
return nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_CONTROL_FIELD);
|
||||||
return nested_vmx_failValid(vcpu, ret);
|
|
||||||
|
|
||||||
ret = nested_vmx_check_host_state(vcpu, vmcs12);
|
if (nested_vmx_check_host_state(vcpu, vmcs12))
|
||||||
if (ret)
|
return nested_vmx_failValid(vcpu, VMXERR_ENTRY_INVALID_HOST_STATE_FIELD);
|
||||||
return nested_vmx_failValid(vcpu, ret);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're finally done with prerequisite checking, and can start with
|
* We're finally done with prerequisite checking, and can start with
|
||||||
|
Loading…
Reference in New Issue
Block a user