mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/3] iommu/arm-smmu: change IOMMU_EXEC to IOMMU_NOEXEC
       [not found] <1413205579-6124-1-git-send-email-a.motakis@virtualopensystems.com>
@ 2014-10-13 13:06 ` Antonios Motakis
  2014-10-13 13:06 ` [PATCH 2/3] iommu: add capability IOMMU_CAP_NOEXEC Antonios Motakis
  2014-10-13 13:06 ` [PATCH 3/3] iommu/arm-smmu: add IOMMU_CAP_NOEXEC to the ARM SMMU driver Antonios Motakis
  2 siblings, 0 replies; 3+ messages in thread
From: Antonios Motakis @ 2014-10-13 13:06 UTC (permalink / raw)
  To: will.deacon, kvmarm, iommu, jroedel
  Cc: alex.williamson, tech, christoffer.dall, eric.auger,
	kim.phillips, marc.zyngier, Antonios Motakis, Joerg Roedel,
	Alexey Kardashevskiy, Upinder Malhi (umalhi),
	Thierry Reding, moderated list:ARM SMMU DRIVER, open list

Exposing the XN flag of the SMMU driver as IOMMU_NOEXEC instead of
IOMMU_EXEC makes it enforceable, since for IOMMUs that don't support
the XN flag pages will always be executable.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Acked-by: Joerg Roedel <jroedel@suse.de>
---
 drivers/iommu/arm-smmu.c | 9 +++++----
 include/linux/iommu.h    | 2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 60558f7..566c176 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1281,7 +1281,7 @@ static int arm_smmu_alloc_init_pte(struct arm_smmu_device *smmu, pmd_t *pmd,
 				   unsigned long pfn, int prot, int stage)
 {
 	pte_t *pte, *start;
-	pteval_t pteval = ARM_SMMU_PTE_PAGE | ARM_SMMU_PTE_AF | ARM_SMMU_PTE_XN;
+	pteval_t pteval = ARM_SMMU_PTE_PAGE | ARM_SMMU_PTE_AF;
 
 	if (pmd_none(*pmd)) {
 		/* Allocate a new set of tables */
@@ -1315,10 +1315,11 @@ static int arm_smmu_alloc_init_pte(struct arm_smmu_device *smmu, pmd_t *pmd,
 			pteval |= ARM_SMMU_PTE_MEMATTR_NC;
 	}
 
+	if (prot & IOMMU_NOEXEC)
+		pteval |= ARM_SMMU_PTE_XN;
+
 	/* If no access, create a faulting entry to avoid TLB fills */
-	if (prot & IOMMU_EXEC)
-		pteval &= ~ARM_SMMU_PTE_XN;
-	else if (!(prot & (IOMMU_READ | IOMMU_WRITE)))
+	if (!(prot & (IOMMU_READ | IOMMU_WRITE)))
 		pteval &= ~ARM_SMMU_PTE_PAGE;
 
 	pteval |= ARM_SMMU_PTE_SH_IS;
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 379a617..5f6f71c 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -27,7 +27,7 @@
 #define IOMMU_READ	(1 << 0)
 #define IOMMU_WRITE	(1 << 1)
 #define IOMMU_CACHE	(1 << 2) /* DMA cache coherency */
-#define IOMMU_EXEC	(1 << 3)
+#define IOMMU_NOEXEC	(1 << 3)
 
 struct iommu_ops;
 struct iommu_group;
-- 
2.1.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] iommu: add capability IOMMU_CAP_NOEXEC
       [not found] <1413205579-6124-1-git-send-email-a.motakis@virtualopensystems.com>
  2014-10-13 13:06 ` [PATCH 1/3] iommu/arm-smmu: change IOMMU_EXEC to IOMMU_NOEXEC Antonios Motakis
@ 2014-10-13 13:06 ` Antonios Motakis
  2014-10-13 13:06 ` [PATCH 3/3] iommu/arm-smmu: add IOMMU_CAP_NOEXEC to the ARM SMMU driver Antonios Motakis
  2 siblings, 0 replies; 3+ messages in thread
From: Antonios Motakis @ 2014-10-13 13:06 UTC (permalink / raw)
  To: will.deacon, kvmarm, iommu, jroedel
  Cc: alex.williamson, tech, christoffer.dall, eric.auger,
	kim.phillips, marc.zyngier, Antonios Motakis, Greg Kroah-Hartman,
	Thierry Reding, Alexey Kardashevskiy, Upinder Malhi (umalhi),
	open list

Some IOMMUs accept an IOMMU_NOEXEC protection flag in addition to
IOMMU_READ and IOMMU_WRITE. Expose this as an IOMMU capability.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
Acked-by: Joerg Roedel <jroedel@suse.de>
---
 include/linux/iommu.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 5f6f71c..ba026f1 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -61,6 +61,7 @@ enum iommu_cap {
 	IOMMU_CAP_CACHE_COHERENCY,	/* IOMMU can enforce cache coherent DMA
 					   transactions */
 	IOMMU_CAP_INTR_REMAP,		/* IOMMU supports interrupt isolation */
+	IOMMU_CAP_NOEXEC,		/* IOMMU_NOEXEC flag */
 };
 
 /*
-- 
2.1.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] iommu/arm-smmu: add IOMMU_CAP_NOEXEC to the ARM SMMU driver
       [not found] <1413205579-6124-1-git-send-email-a.motakis@virtualopensystems.com>
  2014-10-13 13:06 ` [PATCH 1/3] iommu/arm-smmu: change IOMMU_EXEC to IOMMU_NOEXEC Antonios Motakis
  2014-10-13 13:06 ` [PATCH 2/3] iommu: add capability IOMMU_CAP_NOEXEC Antonios Motakis
@ 2014-10-13 13:06 ` Antonios Motakis
  2 siblings, 0 replies; 3+ messages in thread
From: Antonios Motakis @ 2014-10-13 13:06 UTC (permalink / raw)
  To: will.deacon, kvmarm, iommu, jroedel
  Cc: alex.williamson, tech, christoffer.dall, eric.auger,
	kim.phillips, marc.zyngier, Antonios Motakis, Joerg Roedel,
	moderated list:ARM SMMU DRIVER, open list

The ARM SMMU supports the IOMMU_NOEXEC protection flag. Add the
corresponding IOMMU capability.

Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com>
---
 drivers/iommu/arm-smmu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c
index 566c176..c8fc02f 100644
--- a/drivers/iommu/arm-smmu.c
+++ b/drivers/iommu/arm-smmu.c
@@ -1569,6 +1569,8 @@ static bool arm_smmu_capable(enum iommu_cap cap)
 		return true;
 	case IOMMU_CAP_INTR_REMAP:
 		return true; /* MSIs are just memory writes */
+	case IOMMU_CAP_NOEXEC:
+		return true;
 	default:
 		return false;
 	}
-- 
2.1.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-10-13 13:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1413205579-6124-1-git-send-email-a.motakis@virtualopensystems.com>
2014-10-13 13:06 ` [PATCH 1/3] iommu/arm-smmu: change IOMMU_EXEC to IOMMU_NOEXEC Antonios Motakis
2014-10-13 13:06 ` [PATCH 2/3] iommu: add capability IOMMU_CAP_NOEXEC Antonios Motakis
2014-10-13 13:06 ` [PATCH 3/3] iommu/arm-smmu: add IOMMU_CAP_NOEXEC to the ARM SMMU driver Antonios Motakis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®