Commit f8bab735 authored by mark gross's avatar mark gross Committed by Linus Torvalds

intel-iommu: PMEN support

Add support for protected memory enable bits by clearing them if they are
set at startup time.  Some future boot loaders or firmware could have this
bit set after it loads the kernel, and it needs to be cleared if DMA's are
going to happen effectively.
Signed-off-by: default avatarmark gross <mgross@intel.com>
Acked-by: default avatarMuli Ben-Yehuda <muli@il.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2d3a4e36
...@@ -692,6 +692,23 @@ static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did, ...@@ -692,6 +692,23 @@ static int iommu_flush_iotlb_psi(struct intel_iommu *iommu, u16 did,
DMA_TLB_PSI_FLUSH, non_present_entry_flush); DMA_TLB_PSI_FLUSH, non_present_entry_flush);
} }
static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu)
{
u32 pmen;
unsigned long flags;
spin_lock_irqsave(&iommu->register_lock, flags);
pmen = readl(iommu->reg + DMAR_PMEN_REG);
pmen &= ~DMA_PMEN_EPM;
writel(pmen, iommu->reg + DMAR_PMEN_REG);
/* wait for the protected region status bit to clear */
IOMMU_WAIT_OP(iommu, DMAR_PMEN_REG,
readl, !(pmen & DMA_PMEN_PRS), pmen);
spin_unlock_irqrestore(&iommu->register_lock, flags);
}
static int iommu_enable_translation(struct intel_iommu *iommu) static int iommu_enable_translation(struct intel_iommu *iommu)
{ {
u32 sts; u32 sts;
...@@ -745,7 +762,7 @@ static char *fault_reason_strings[] = ...@@ -745,7 +762,7 @@ static char *fault_reason_strings[] =
"non-zero reserved fields in PTE", "non-zero reserved fields in PTE",
"Unknown" "Unknown"
}; };
#define MAX_FAULT_REASON_IDX ARRAY_SIZE(fault_reason_strings) - 1 #define MAX_FAULT_REASON_IDX (ARRAY_SIZE(fault_reason_strings) - 1)
char *dmar_get_fault_reason(u8 fault_reason) char *dmar_get_fault_reason(u8 fault_reason)
{ {
...@@ -1730,6 +1747,8 @@ int __init init_dmars(void) ...@@ -1730,6 +1747,8 @@ int __init init_dmars(void)
iommu_flush_context_global(iommu, 0); iommu_flush_context_global(iommu, 0);
iommu_flush_iotlb_global(iommu, 0); iommu_flush_iotlb_global(iommu, 0);
iommu_disable_protect_mem_regions(iommu);
ret = iommu_enable_translation(iommu); ret = iommu_enable_translation(iommu);
if (ret) if (ret)
goto error; goto error;
......
...@@ -140,6 +140,10 @@ static inline void dmar_writeq(void __iomem *addr, u64 val) ...@@ -140,6 +140,10 @@ static inline void dmar_writeq(void __iomem *addr, u64 val)
#define DMA_TLB_IH_NONLEAF (((u64)1) << 6) #define DMA_TLB_IH_NONLEAF (((u64)1) << 6)
#define DMA_TLB_MAX_SIZE (0x3f) #define DMA_TLB_MAX_SIZE (0x3f)
/* PMEN_REG */
#define DMA_PMEN_EPM (((u32)1)<<31)
#define DMA_PMEN_PRS (((u32)1)<<0)
/* GCMD_REG */ /* GCMD_REG */
#define DMA_GCMD_TE (((u32)1) << 31) #define DMA_GCMD_TE (((u32)1) << 31)
#define DMA_GCMD_SRTP (((u32)1) << 30) #define DMA_GCMD_SRTP (((u32)1) << 30)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment