iommu/amd: WARN if KVM attempts to set vCPU affinity without posted intrrupts

WARN if KVM attempts to set vCPU affinity when posted interrupts aren't
enabled, as KVM shouldn't try to enable posting when they're unsupported,
and the IOMMU driver darn well should only advertise posting support when
AMD_IOMMU_GUEST_IR_VAPIC() is true.

Note, KVM consumes is_guest_mode only on success.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20250404193923.1413163-7-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by Sean Christopherson and committed by Paolo Bonzini aae251a3 07172206

+3 -10
+3 -10
drivers/iommu/amd/iommu.c
··· 3869 struct irq_2_irte *irte_info = &ir_data->irq_2_irte; 3870 struct iommu_dev_data *dev_data; 3871 3872 if (ir_data->iommu == NULL) 3873 return -EINVAL; 3874 ··· 3886 3887 ir_data->cfg = irqd_cfg(data); 3888 pi_data->ir_data = ir_data; 3889 - 3890 - /* Note: 3891 - * SVM tries to set up for VAPIC mode, but we are in 3892 - * legacy mode. So, we force legacy mode instead. 3893 - */ 3894 - if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) { 3895 - pr_debug("%s: Fall back to using intr legacy remap\n", 3896 - __func__); 3897 - pi_data->is_guest_mode = false; 3898 - } 3899 3900 pi_data->prev_ga_tag = ir_data->cached_ga_tag; 3901 if (pi_data->is_guest_mode) {
··· 3869 struct irq_2_irte *irte_info = &ir_data->irq_2_irte; 3870 struct iommu_dev_data *dev_data; 3871 3872 + if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))) 3873 + return -EINVAL; 3874 + 3875 if (ir_data->iommu == NULL) 3876 return -EINVAL; 3877 ··· 3883 3884 ir_data->cfg = irqd_cfg(data); 3885 pi_data->ir_data = ir_data; 3886 3887 pi_data->prev_ga_tag = ir_data->cached_ga_tag; 3888 if (pi_data->is_guest_mode) {