Skip to content

Commit c95a438

Browse files
sean-jcgregkh
authored andcommitted
iommu/vt-d: Put IRTE back into posted MSI mode if vCPU posting is disabled
commit 2454823 upstream. Add a helper to take care of reconfiguring an IRTE to deliver IRQs to the host, i.e. not to a vCPU, and use the helper when an IRTE's vCPU affinity is nullified, i.e. when KVM puts an IRTE back into "host" mode. Because posted MSIs use an ephemeral IRTE, using modify_irte() puts the IRTE into full remapped mode, i.e. unintentionally disables posted MSIs on the IRQ. Fixes: ed1e48e ("iommu/vt-d: Enable posted mode for device MSIs") Cc: stable@vger.kernel.org Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Jacob Pan <jacob.jun.pan@linux.intel.com> Signed-off-by: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/20250315025135.2365846-2-seanjc@google.com Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com> Signed-off-by: Joerg Roedel <jroedel@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e5dd974 commit c95a438

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/iommu/intel/irq_remapping.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,17 @@ static void intel_ir_reconfigure_irte_posted(struct irq_data *irqd)
11731173
static inline void intel_ir_reconfigure_irte_posted(struct irq_data *irqd) {}
11741174
#endif
11751175

1176-
static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force)
1176+
static void __intel_ir_reconfigure_irte(struct irq_data *irqd, bool force_host)
1177+
{
1178+
struct intel_ir_data *ir_data = irqd->chip_data;
1179+
1180+
if (ir_data->irq_2_iommu.posted_msi)
1181+
intel_ir_reconfigure_irte_posted(irqd);
1182+
else if (force_host || ir_data->irq_2_iommu.mode == IRQ_REMAPPING)
1183+
modify_irte(&ir_data->irq_2_iommu, &ir_data->irte_entry);
1184+
}
1185+
1186+
static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force_host)
11771187
{
11781188
struct intel_ir_data *ir_data = irqd->chip_data;
11791189
struct irte *irte = &ir_data->irte_entry;
@@ -1186,10 +1196,7 @@ static void intel_ir_reconfigure_irte(struct irq_data *irqd, bool force)
11861196
irte->vector = cfg->vector;
11871197
irte->dest_id = IRTE_DEST(cfg->dest_apicid);
11881198

1189-
if (ir_data->irq_2_iommu.posted_msi)
1190-
intel_ir_reconfigure_irte_posted(irqd);
1191-
else if (force || ir_data->irq_2_iommu.mode == IRQ_REMAPPING)
1192-
modify_irte(&ir_data->irq_2_iommu, irte);
1199+
__intel_ir_reconfigure_irte(irqd, force_host);
11931200
}
11941201

11951202
/*
@@ -1244,7 +1251,7 @@ static int intel_ir_set_vcpu_affinity(struct irq_data *data, void *info)
12441251

12451252
/* stop posting interrupts, back to the default mode */
12461253
if (!vcpu_pi_info) {
1247-
modify_irte(&ir_data->irq_2_iommu, &ir_data->irte_entry);
1254+
__intel_ir_reconfigure_irte(data, true);
12481255
} else {
12491256
struct irte irte_pi;
12501257

0 commit comments

Comments
 (0)