[RFC PATCH v3 20/27] KVM: SVM: Implement kvm_x86_ops->protected_apic_has_interrupt() for Secure AVIC
From: Naveen N Rao (AMD)
Date: Wed Jul 08 2026 - 02:38:49 EST
Since KVM tracks pending interrupts for a Secure AVIC guest in its copy
of the APIC_IRR, wire up protected_apic_has_interrupt() to just use
protected_apic_has_injectable_intr().
Signed-off-by: Naveen N Rao (AMD) <naveen@xxxxxxxxxx>
---
arch/x86/kvm/svm/svm.h | 2 ++
arch/x86/kvm/svm/sev.c | 5 +++++
arch/x86/kvm/svm/svm.c | 1 +
3 files changed, 8 insertions(+)
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index af3c84a61c07..f5e270086b51 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -1018,6 +1018,7 @@ struct vmcb_save_area *sev_decrypt_vmsa(struct kvm_vcpu *vcpu);
void sev_free_decrypted_vmsa(struct kvm_vcpu *vcpu, struct vmcb_save_area *vmsa);
bool snp_is_secure_avic_enabled(struct kvm *kvm);
bool snp_protected_apic_has_injectable_intr(struct kvm_vcpu *vcpu);
+bool snp_protected_apic_has_interrupt(struct kvm_vcpu *vcpu);
#else
static inline struct page *snp_safe_alloc_page_node(int node, gfp_t gfp)
{
@@ -1057,6 +1058,7 @@ static inline struct vmcb_save_area *sev_decrypt_vmsa(struct kvm_vcpu *vcpu)
static inline void sev_free_decrypted_vmsa(struct kvm_vcpu *vcpu, struct vmcb_save_area *vmsa) {}
static inline bool snp_is_secure_avic_enabled(struct kvm *kvm) { return false; }
static inline bool snp_protected_apic_has_injectable_intr(struct kvm_vcpu *vcpu) { return false; }
+static inline bool snp_protected_apic_has_interrupt(struct kvm_vcpu *vcpu) { return false; }
#endif
/* vmenter.S */
diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 3d36168c3327..a0c5271ec4ca 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -4947,6 +4947,11 @@ bool snp_protected_apic_has_injectable_intr(struct kvm_vcpu *vcpu)
return apic_find_highest_vector(vcpu->arch.apic->regs + APIC_IRR) != -1;
}
+bool snp_protected_apic_has_interrupt(struct kvm_vcpu *vcpu)
+{
+ return snp_protected_apic_has_injectable_intr(vcpu);
+}
+
void sev_vcpu_deliver_sipi_vector(struct kvm_vcpu *vcpu, u8 vector)
{
struct vcpu_svm *svm = to_svm(vcpu);
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 441520c1312d..3f731483f6a2 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -5399,6 +5399,7 @@ struct kvm_x86_ops svm_x86_ops __initdata = {
.required_apicv_inhibits = AVIC_REQUIRED_APICV_INHIBITS,
.protected_apic_has_injectable_intr = snp_protected_apic_has_injectable_intr,
+ .protected_apic_has_interrupt = snp_protected_apic_has_interrupt,
.get_exit_info = svm_get_exit_info,
.get_entry_info = svm_get_entry_info,
--
2.54.0