[PATCH v3 46/62] KVM: SVM: WARN if (de)activating guest mode in IOMMU fails
From: Sean Christopherson
Date: Wed Jun 11 2025 - 19:04:10 EST
WARN if (de)activating "guest mode" for an IRTE entry fails as modifying
an IRTE should only fail if KVM is buggy, e.g. has stale metadata.
Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
arch/x86/kvm/svm/avic.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
index ab7fb8950cc0..6048cd90e731 100644
--- a/arch/x86/kvm/svm/avic.c
+++ b/arch/x86/kvm/svm/avic.c
@@ -724,10 +724,9 @@ void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu)
avic_handle_ldr_update(vcpu);
}
-static int avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
+static void avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
{
int apic_id = kvm_cpu_get_apicid(vcpu->cpu);
- int ret = 0;
unsigned long flags;
struct vcpu_svm *svm = to_svm(vcpu);
struct kvm_kernel_irqfd *irqfd;
@@ -742,16 +741,15 @@ static int avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
goto out;
list_for_each_entry(irqfd, &svm->ir_list, vcpu_list) {
+ void *data = irqfd->irq_bypass_data;
+
if (activate)
- ret = amd_iommu_activate_guest_mode(irqfd->irq_bypass_data, apic_id);
+ WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apic_id));
else
- ret = amd_iommu_deactivate_guest_mode(irqfd->irq_bypass_data);
- if (ret)
- break;
+ WARN_ON_ONCE(amd_iommu_deactivate_guest_mode(data));
}
out:
spin_unlock_irqrestore(&svm->ir_list_lock, flags);
- return ret;
}
static void svm_ir_list_del(struct kvm_kernel_irqfd *irqfd)
--
2.50.0.rc1.591.g9c95f17f64-goog