Skip to content

Commit a9fa7cb

Browse files
committed
KVM: x86: replace is_smm checks with kvm_x86_ops.smi_allowed
Do not hardcode is_smm so that all the architectural conditions for blocking SMIs are listed in a single place. Well, in two places because this introduces some code duplication between Intel and AMD. This ensures that nested SVM obeys GIF in kvm_vcpu_has_events. Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 88c604b commit a9fa7cb

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3783,7 +3783,7 @@ static bool svm_smi_allowed(struct kvm_vcpu *vcpu)
37833783
return false;
37843784
}
37853785

3786-
return true;
3786+
return !is_smm(vcpu);
37873787
}
37883788

37893789
static int svm_pre_enter_smm(struct kvm_vcpu *vcpu, char *smstate)

arch/x86/kvm/vmx/vmx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7680,7 +7680,7 @@ static bool vmx_smi_allowed(struct kvm_vcpu *vcpu)
76807680
/* we need a nested vmexit to enter SMM, postpone if run is pending */
76817681
if (to_vmx(vcpu)->nested.nested_run_pending)
76827682
return false;
7683-
return true;
7683+
return !is_smm(vcpu);
76847684
}
76857685

76867686
static int vmx_pre_enter_smm(struct kvm_vcpu *vcpu, char *smstate)

arch/x86/kvm/x86.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7764,8 +7764,7 @@ static int inject_pending_event(struct kvm_vcpu *vcpu)
77647764
if (kvm_event_needs_reinjection(vcpu))
77657765
return 0;
77667766

7767-
if (vcpu->arch.smi_pending && !is_smm(vcpu) &&
7768-
kvm_x86_ops.smi_allowed(vcpu)) {
7767+
if (vcpu->arch.smi_pending && kvm_x86_ops.smi_allowed(vcpu)) {
77697768
vcpu->arch.smi_pending = false;
77707769
++vcpu->arch.smi_count;
77717770
enter_smm(vcpu);
@@ -10206,7 +10205,8 @@ static inline bool kvm_vcpu_has_events(struct kvm_vcpu *vcpu)
1020610205
return true;
1020710206

1020810207
if (kvm_test_request(KVM_REQ_SMI, vcpu) ||
10209-
(vcpu->arch.smi_pending && !is_smm(vcpu)))
10208+
(vcpu->arch.smi_pending &&
10209+
kvm_x86_ops.smi_allowed(vcpu)))
1021010210
return true;
1021110211

1021210212
if (kvm_arch_interrupt_allowed(vcpu) &&

0 commit comments

Comments
 (0)