If NMIPass is enabled in a device's DTE, the IOMMU lets NMI interrupt
messages pass through unmapped. Therefore, the contents of the MSI
message, not an IRTE, determine how and where the NMI is delivered.

Since the IOMMU driver owns the MSI message of the NMI irq, compose
it using the non-interrupt-remapping format. Also, let descendant
irqchips write the MSI as appropriate for the device.

Cc: Andi Kleen <a...@linux.intel.com>
Cc: "Ravi V. Shankar" <ravi.v.shan...@intel.com>
Cc: Joerg Roedel <j...@8bytes.org>
Cc: Suravee Suthikulpanit <suravee.suthikulpa...@amd.com>
Cc: Stephane Eranian <eran...@google.com>
Cc: iommu@lists.linux-foundation.org
Cc: linuxppc-...@lists.ozlabs.org
Cc: x...@kernel.org
Signed-off-by: Ricardo Neri <ricardo.neri-calde...@linux.intel.com>
---
Changes since v5:
 * Introduced this patch

Changes since v4:
 * N/A

Changes since v3:
 * N/A

Changes since v2:
 * N/A

Changes since v1:
 * N/A
---
 drivers/iommu/amd/iommu.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 4d7421b6858d..6e07949b3e2a 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -3111,7 +3111,16 @@ static void irq_remapping_prepare_irte(struct 
amd_ir_data *data,
        case X86_IRQ_ALLOC_TYPE_HPET:
        case X86_IRQ_ALLOC_TYPE_PCI_MSI:
        case X86_IRQ_ALLOC_TYPE_PCI_MSIX:
-               fill_msi_msg(&data->msi_entry, irte_info->index);
+               if (irq_cfg->delivery_mode == APIC_DELIVERY_MODE_NMI)
+                       /*
+                        * The IOMMU lets NMIs pass through unmapped. Thus, the
+                        * MSI message, not the IRTE, determines the irq
+                        * configuration. Since we own the MSI message,
+                        * compose it. Descendant irqchips will write it.
+                        */
+                       __irq_msi_compose_msg(irq_cfg, &data->msi_entry, true);
+               else
+                       fill_msi_msg(&data->msi_entry, irte_info->index);
                break;
 
        default:
@@ -3509,6 +3518,18 @@ static int amd_ir_set_affinity(struct irq_data *data,
         */
        send_cleanup_vector(cfg);
 
+       /*
+        * When the delivery mode of an irq is NMI, the IOMMU lets the NMI
+        * interrupt messages pass through unmapped. Hence, changes in the
+        * destination are to be reflected in the NMI message itself, not the
+        * IRTE. Thus, descendant irqchips must set the affinity and compose
+        * write the MSI message.
+        *
+        * Also, NMIs do not have an associated vector. No need for cleanup.
+        */
+       if (cfg->delivery_mode == APIC_DELIVERY_MODE_NMI)
+               return IRQ_SET_MASK_OK;
+
        return IRQ_SET_MASK_OK_DONE;
 }
 
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

Reply via email to