Skip to content

Commit aae251a

Browse files
sean-jcbonzini
authored andcommitted
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 <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 0717220 commit aae251a

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

drivers/iommu/amd/iommu.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3869,6 +3869,9 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *data, void *vcpu_info)
38693869
struct irq_2_irte *irte_info = &ir_data->irq_2_irte;
38703870
struct iommu_dev_data *dev_data;
38713871

3872+
if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)))
3873+
return -EINVAL;
3874+
38723875
if (ir_data->iommu == NULL)
38733876
return -EINVAL;
38743877

@@ -3884,16 +3887,6 @@ static int amd_ir_set_vcpu_affinity(struct irq_data *data, void *vcpu_info)
38843887
ir_data->cfg = irqd_cfg(data);
38853888
pi_data->ir_data = ir_data;
38863889

3887-
/* Note:
3888-
* SVM tries to set up for VAPIC mode, but we are in
3889-
* legacy mode. So, we force legacy mode instead.
3890-
*/
3891-
if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)) {
3892-
pr_debug("%s: Fall back to using intr legacy remap\n",
3893-
__func__);
3894-
pi_data->is_guest_mode = false;
3895-
}
3896-
38973890
pi_data->prev_ga_tag = ir_data->cached_ga_tag;
38983891
if (pi_data->is_guest_mode) {
38993892
ir_data->ga_root_ptr = (pi_data->base >> 12);

0 commit comments

Comments
 (0)