Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7671ce21 authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini
Browse files

KVM: nVMX: move check_vmentry_postreqs() call to nested_vmx_enter_non_root_mode()



In preparation of supporting checkpoint/restore for nested state,
commit ca0bde28 ("kvm: nVMX: Split VMCS checks from nested_vmx_run()")
modified check_vmentry_postreqs() to only perform the guest EFER
consistency checks when nested_run_pending is true.  But, in the
normal nested VMEntry flow, nested_run_pending is only set after
check_vmentry_postreqs(), i.e. the consistency check is being skipped.

Alternatively, nested_run_pending could be set prior to calling
check_vmentry_postreqs() in nested_vmx_run(), but placing the
consistency checks in nested_vmx_enter_non_root_mode() allows us
to split prepare_vmcs02() and interleave the preparation with
the consistency checks without having to change the call sites
of nested_vmx_enter_non_root_mode().  In other words, the rest
of the consistency check code in nested_vmx_run() will be joining
the postreqs checks in future patches.

Fixes: ca0bde28 ("kvm: nVMX: Split VMCS checks from nested_vmx_run()")
Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
Cc: Jim Mattson <jmattson@google.com>
Reviewed-by: default avatarJim Mattson <jmattson@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent d63907dc
Loading
Loading
Loading
Loading
+3 −7
Original line number Original line Diff line number Diff line
@@ -12658,6 +12658,9 @@ static int nested_vmx_enter_non_root_mode(struct kvm_vcpu *vcpu, u32 *exit_qual)
	if (likely(!evaluate_pending_interrupts) && kvm_vcpu_apicv_active(vcpu))
	if (likely(!evaluate_pending_interrupts) && kvm_vcpu_apicv_active(vcpu))
		evaluate_pending_interrupts |= vmx_has_apicv_interrupt(vcpu);
		evaluate_pending_interrupts |= vmx_has_apicv_interrupt(vcpu);


	if (from_vmentry && check_vmentry_postreqs(vcpu, vmcs12, exit_qual))
		return EXIT_REASON_INVALID_STATE;

	enter_guest_mode(vcpu);
	enter_guest_mode(vcpu);


	if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS))
	if (!(vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS))
@@ -12800,13 +12803,6 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
	 */
	 */
	skip_emulated_instruction(vcpu);
	skip_emulated_instruction(vcpu);


	ret = check_vmentry_postreqs(vcpu, vmcs12, &exit_qual);
	if (ret) {
		nested_vmx_entry_failure(vcpu, vmcs12,
					 EXIT_REASON_INVALID_STATE, exit_qual);
		return 1;
	}

	/*
	/*
	 * We're finally done with prerequisite checking, and can start with
	 * We're finally done with prerequisite checking, and can start with
	 * the nested entry.
	 * the nested entry.