public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 2/3] TXT: Intel IOMMU PMR Disable
@ 2008-10-07 23:22 Joseph Cihula
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Cihula @ 2008-10-07 23:22 UTC (permalink / raw)
  To: linux-kernel
  Cc: shane.wang, gang.wei, arjan, asit.k.mallick, jun.nakajima, chrisw,
	jbeulich, mingo, tytso, linux-kernel, joseph.cihula

(re-posted with apologies for formatting and email addresses)

Disable Intel VT-d (IOMMU) Protected Memory Regions (PMRs) when DMA 
remapping is enabled.

Leaving the PMRs enabled may add more delay to the VT-d DMA request 
processing (as another lookup may be performed) but whether they are 
even used is not deterministic:
    DMA requests that are subject to address remapping, and accessing the
    protected memory regions may or may not be blocked by hardware. For
    such requests, software must not depend on hardware protection of the
    protected memory regions, and instead program the DMA-remapping
    page-tables to block DMA to protected memory regions.
    -- from the description field of the PMEN_REG register in the v1.2 
(May '08) VT-d spec.

Signed-off-by:  Shane Wang <shane.wang@intel.com>
Signed-off-by:  Joseph Cihula <joseph.cihula@intel.com>

---

diff -r 29cfdc52a076 drivers/pci/intel-iommu.c
--- a/drivers/pci/intel-iommu.c	Mon Oct 06 12:50:47 2008 -0700
+++ b/drivers/pci/intel-iommu.c	Mon Oct 06 15:54:59 2008 -0700
@@ -742,6 +742,22 @@ static void iommu_disable_protect_mem_re
 	spin_unlock_irqrestore(&iommu->register_lock, flags);
 }
 
+static void disable_pmr(struct intel_iommu *iommu)
+{
+	u32 data;
+
+	data = readl(iommu->reg + DMAR_PMEN_REG);
+	if (!(data & DMA_PMEN_PRS))
+		return;
+
+	data = data & ~DMA_PMEN_EPM;
+	writel(data, iommu->reg + DMAR_PMEN_REG);
+
+	IOMMU_WAIT_OP(iommu, DMAR_PMEN_REG,
+		readl, !(data & DMA_PMEN_PRS), data);
+	return;
+}
+
 static int iommu_enable_translation(struct intel_iommu *iommu)
 {
 	u32 sts;
@@ -755,6 +771,7 @@ static int iommu_enable_translation(stru
 		readl, (sts & DMA_GSTS_TES), sts);
 
 	iommu->gcmd |= DMA_GCMD_TE;
+	disable_pmr(iommu);
 	spin_unlock_irqrestore(&iommu->register_lock, flags);
 	return 0;
 }
diff -r 29cfdc52a076 drivers/pci/intel-iommu.h
--- a/drivers/pci/intel-iommu.h	Mon Oct 06 12:50:47 2008 -0700
+++ b/drivers/pci/intel-iommu.h	Mon Oct 06 15:54:59 2008 -0700
@@ -158,6 +158,10 @@ static inline void dmar_writeq(void __io
 #define DMA_GSTS_FLS (((u32)1) << 29)
 #define DMA_GSTS_AFLS (((u32)1) << 28)
 #define DMA_GSTS_WBFS (((u32)1) << 27)
+
+/* PMEN_REG */
+#define DMA_PMEN_EPM (((u32)1) << 31)
+#define DMA_PMEN_PRS (((u32)1) << 0)
 
 /* CCMD_REG */
 #define DMA_CCMD_ICC (((u64)1) << 63)



^ permalink raw reply	[flat|nested] 2+ messages in thread
* [RFC][PATCH 2/3] TXT: Intel IOMMU PMR Disable
@ 2008-10-07 20:34 Cihula, Joseph
  0 siblings, 0 replies; 2+ messages in thread
From: Cihula, Joseph @ 2008-10-07 20:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Wang, Shane, Wei, Gang, Van De Ven, Arjan, Mallick, Asit K,
	Nakajima, Jun, Chris Wright, Jan Beulich, mingo, tytso

Disable Intel VT-d (IOMMU) Protected Memory Regions (PMRs) when DMA
remapping is enabled.

Leaving the PMRs enabled may add more delay to the VT-d DMA request
processing (as another lookup may be performed) but whether they are
even used is not deterministic:
	DMA requests that are subject to address remapping, and
accessing the
	protected memory regions may or may not be blocked by hardware.
For
	such requests, software must not depend on hardware protection
of the
	protected memory regions, and instead program the DMA-remapping
	page-tables to block DMA to protected memory regions.
	-- from the description field of the PMEN_REG register in the
v1.2 (May '08) VT-d spec.

Signed-off-by:  Shane Wang <shane.wang@intel.com>
Signed-off-by:  Joseph Cihula <joseph.cihula@intel.com>

diff -r 29cfdc52a076 drivers/pci/intel-iommu.c
--- a/drivers/pci/intel-iommu.c Mon Oct 06 12:50:47 2008 -0700
+++ b/drivers/pci/intel-iommu.c Mon Oct 06 15:54:59 2008 -0700
@@ -742,6 +742,22 @@ static void iommu_disable_protect_mem_re
        spin_unlock_irqrestore(&iommu->register_lock, flags);
 }

+static void disable_pmr(struct intel_iommu *iommu)
+{
+       u32 data;
+
+       data = readl(iommu->reg + DMAR_PMEN_REG);
+       if (!(data & DMA_PMEN_PRS))
+               return;
+
+       data = data & ~DMA_PMEN_EPM;
+       writel(data, iommu->reg + DMAR_PMEN_REG);
+
+       IOMMU_WAIT_OP(iommu, DMAR_PMEN_REG,
+               readl, !(data & DMA_PMEN_PRS), data);
+       return;
+}
+
 static int iommu_enable_translation(struct intel_iommu *iommu)
 {
        u32 sts;
@@ -755,6 +771,7 @@ static int iommu_enable_translation(stru
                readl, (sts & DMA_GSTS_TES), sts);

        iommu->gcmd |= DMA_GCMD_TE;
+       disable_pmr(iommu);
        spin_unlock_irqrestore(&iommu->register_lock, flags);
        return 0;
 }
diff -r 29cfdc52a076 drivers/pci/intel-iommu.h
--- a/drivers/pci/intel-iommu.h Mon Oct 06 12:50:47 2008 -0700
+++ b/drivers/pci/intel-iommu.h Mon Oct 06 15:54:59 2008 -0700
@@ -158,6 +158,10 @@ static inline void dmar_writeq(void __io
 #define DMA_GSTS_FLS (((u32)1) << 29)
 #define DMA_GSTS_AFLS (((u32)1) << 28)
 #define DMA_GSTS_WBFS (((u32)1) << 27)
+
+/* PMEN_REG */
+#define DMA_PMEN_EPM (((u32)1) << 31)
+#define DMA_PMEN_PRS (((u32)1) << 0)

 /* CCMD_REG */
 #define DMA_CCMD_ICC (((u64)1) << 63)

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

end of thread, other threads:[~2008-10-07 23:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-07 23:22 [RFC][PATCH 2/3] TXT: Intel IOMMU PMR Disable Joseph Cihula
  -- strict thread matches above, loose matches on Subject: below --
2008-10-07 20:34 Cihula, Joseph

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