[PATCH v3 47/62] KVM: SVM: Process all IRTEs on affinity change even if one update fails

Sean Christopherson
2025-06-11T22:48:17Z

When updating IRTE GA fields, keep processing all other IRTEs if an update
fails, as not updating later entries risks making a bad situation worse.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/avic.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
index 6048cd90e731..24e07f075646 100644
--- a/arch/x86/kvm/svm/avic.c
+++ b/arch/x86/kvm/svm/avic.c
@@ -849,12 +849,10 @@ static inline int avic_update_iommu_vcpu_affinity(struct kvm_vcpu *vcpu, int cpu
if (list_empty(&svm->ir_list))
return 0;

- list_for_each_entry(irqfd, &svm->ir_list, vcpu_list) {
+ list_for_each_entry(irqfd, &svm->ir_list, vcpu_list)
ret = amd_iommu_update_ga(cpu, irqfd->irq_bypass_data);
- if (ret)
- return ret;
- }
- return 0;
+
+ return ret;
}

void avic_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
--
2.50.0.rc1.591.g9c95f17f64-goog