diff mbox series

[iommufd,8/9] irq/s390: Add arch_is_secure_msi() for s390

Message ID 8-v1-9e466539c244+47b5-secure_msi_jgg@nvidia.com (mailing list archive)
State New, archived
Headers show
Series Remove IOMMU_CAP_INTR_REMAP | expand

Commit Message

Jason Gunthorpe Dec. 8, 2022, 8:26 p.m. UTC
s390 doesn't use irq_domains, so it has no place to set
IRQ_DOMAIN_FLAG_SECURE_MSI. Instead of continuing to abuse the iommu
subsystem to convey this information add a simple define which s390 can
make statically true. The define will cause irq_device_has_secure_msi() to
return true.

I do not know if S390 meets the definition of "Secure MSI" if someone can
explain how it works I will update the comment in the arch/msi.h to
explain it. Please consider updating S390 to use the modern IRQ
infrastructure.

Remove IOMMU_CAP_INTR_REMAP from the s390 iommu driver.

Cc: Matthew Rosato <mjrosato@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 arch/s390/include/asm/msi.h | 12 ++++++++++++
 drivers/iommu/s390-iommu.c  |  2 --
 include/linux/msi.h         |  6 +++++-
 kernel/irq/msi.c            |  2 +-
 4 files changed, 18 insertions(+), 4 deletions(-)
 create mode 100644 arch/s390/include/asm/msi.h
diff mbox series

Patch

diff --git a/arch/s390/include/asm/msi.h b/arch/s390/include/asm/msi.h
new file mode 100644
index 00000000000000..e3522bde3e9c90
--- /dev/null
+++ b/arch/s390/include/asm/msi.h
@@ -0,0 +1,12 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_S390_MSI_H
+#define _ASM_S390_MSI_H
+#include <asm-generic/msi.h>
+
+/*
+ * Work around S390 not using irq_domain at all so we can't set
+ * IRQ_DOMAIN_FLAG_SECURE_MSI
+ */
+#define arch_is_secure_msi() true
+
+#endif
diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c
index 3c071782f6f16d..c80f4728c0f307 100644
--- a/drivers/iommu/s390-iommu.c
+++ b/drivers/iommu/s390-iommu.c
@@ -44,8 +44,6 @@  static bool s390_iommu_capable(struct device *dev, enum iommu_cap cap)
 	switch (cap) {
 	case IOMMU_CAP_CACHE_COHERENCY:
 		return true;
-	case IOMMU_CAP_INTR_REMAP:
-		return true;
 	default:
 		return false;
 	}
diff --git a/include/linux/msi.h b/include/linux/msi.h
index 75c2c4e71fc34c..8efbf34a86f247 100644
--- a/include/linux/msi.h
+++ b/include/linux/msi.h
@@ -48,6 +48,10 @@  typedef struct arch_msi_msg_data {
 } __attribute__ ((packed)) arch_msi_msg_data_t;
 #endif
 
+#ifndef arch_is_secure_msi
+#define arch_is_secure_msi() false
+#endif
+
 /**
  * msi_msg - Representation of a MSI message
  * @address_lo:		Low 32 bits of msi message address
@@ -660,7 +664,7 @@  static inline bool msi_device_has_secure_msi(struct device *dev)
 	 * inherently secure by our definition. As nobody seems to needs this be
 	 * conservative and return false anyhow.
 	 */
-	return false;
+	return arch_is_secure_msi();
 }
 #endif /* CONFIG_GENERIC_MSI_IRQ */
 
diff --git a/kernel/irq/msi.c b/kernel/irq/msi.c
index 18264bddf63b89..aba4f12df190b7 100644
--- a/kernel/irq/msi.c
+++ b/kernel/irq/msi.c
@@ -1644,6 +1644,6 @@  bool msi_device_has_secure_msi(struct device *dev)
 	for (; domain; domain = domain->parent)
 		if (domain->flags & IRQ_DOMAIN_FLAG_SECURE_MSI)
 			return true;
-	return false;
+	return arch_is_secure_msi();
 }
 EXPORT_SYMBOL_GPL(msi_device_has_secure_msi);