Skip to content

Commit 1656276

Browse files
committed
KVM: SVM: WARN if (de)activating guest mode in IOMMU fails
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. Link: https://lore.kernel.org/r/20250611224604.313496-48-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent fe02139 commit 1656276

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

arch/x86/kvm/svm/avic.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,9 @@ void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu)
725725
avic_handle_ldr_update(vcpu);
726726
}
727727

728-
static int avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
728+
static void avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
729729
{
730730
int apic_id = kvm_cpu_get_apicid(vcpu->cpu);
731-
int ret = 0;
732731
unsigned long flags;
733732
struct vcpu_svm *svm = to_svm(vcpu);
734733
struct kvm_kernel_irqfd *irqfd;
@@ -743,16 +742,15 @@ static int avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
743742
goto out;
744743

745744
list_for_each_entry(irqfd, &svm->ir_list, vcpu_list) {
745+
void *data = irqfd->irq_bypass_data;
746+
746747
if (activate)
747-
ret = amd_iommu_activate_guest_mode(irqfd->irq_bypass_data, apic_id);
748+
WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apic_id));
748749
else
749-
ret = amd_iommu_deactivate_guest_mode(irqfd->irq_bypass_data);
750-
if (ret)
751-
break;
750+
WARN_ON_ONCE(amd_iommu_deactivate_guest_mode(data));
752751
}
753752
out:
754753
spin_unlock_irqrestore(&svm->ir_list_lock, flags);
755-
return ret;
756754
}
757755

758756
static void svm_ir_list_del(struct kvm_kernel_irqfd *irqfd)

0 commit comments

Comments
 (0)