KVM: nSVM: Move SMI vmexit handling to svm_check_nested_events()

Unlike VMX, SVM allows a hypervisor to take a SMI vmexit without having
any special SMM-monitor enablement sequence.  Therefore, it has to be
handled like interrupts and NMIs.  Check for an unblocked SMI in
svm_check_nested_events() so that pending SMIs are correctly prioritized
over IRQs and NMIs when the latter events will trigger VM-Exit.

Note that there is no need to test explicitly for SMI vmexits, because
guests always runs outside SMM and therefore can never get an SMI while
they are blocked.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini
2020-04-23 08:17:28 -04:00
parent bbdad0b5a7
commit 55714cddbf
3 changed files with 21 additions and 8 deletions

View File

@@ -3778,14 +3778,6 @@ static bool svm_smi_allowed(struct kvm_vcpu *vcpu)
if (!gif_set(svm))
return false;
if (is_guest_mode(&svm->vcpu) &&
svm->nested.intercept & (1ULL << INTERCEPT_SMI)) {
/* TODO: Might need to set exit_info_1 and exit_info_2 here */
svm->vmcb->control.exit_code = SVM_EXIT_SMI;
svm->nested.exit_required = true;
return false;
}
return !is_smm(vcpu);
}