]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: SVM: WARN if (de)activating guest mode in IOMMU fails
authorSean Christopherson <seanjc@google.com>
Wed, 11 Jun 2025 22:45:49 +0000 (15:45 -0700)
committerSean Christopherson <seanjc@google.com>
Mon, 23 Jun 2025 16:50:42 +0000 (09:50 -0700)
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>
arch/x86/kvm/svm/avic.c

index f3bfd7cb0bca5bb9b9774a38517bc198d1f0ba2c..31bf202e0026dc61468c08d53af68c4a0db96649 100644 (file)
@@ -725,10 +725,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;
@@ -743,16 +742,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)