Page MenuHomeFreeBSD

D32591.id97214.diff
No OneTemporary

D32591.id97214.diff

Index: sys/x86/iommu/intel_utils.c
===================================================================
--- sys/x86/iommu/intel_utils.c
+++ sys/x86/iommu/intel_utils.c
@@ -489,6 +489,33 @@
return (error);
}
+/*
+ * Some BIOSes protect memory region they reside in by using DMAR to
+ * prevent devices from doing any DMA transactions to that part of RAM.
+ * AMI refers to this as "DMA Control Guarantee".
+ * We need to disable this right after address translation is enabled.
+ */
+static int
+dmar_disable_protected_regions(struct dmar_unit *unit)
+{
+ uint32_t reg;
+ int error;
+
+ DMAR_ASSERT_LOCKED(unit);
+
+ /* Check if we support the feature. */
+ if (!(unit->hw_cap & (DMAR_CAP_PLMR | DMAR_CAP_PHMR)))
+ return (0);
+
+ reg = dmar_read4(unit, DMAR_PMEN_REG);
+ reg &= ~DMAR_PMEN_EPM;
+ dmar_write4(unit, DMAR_PMEN_REG, reg);
+ DMAR_WAIT_UNTIL(((dmar_read4(unit, DMAR_PMEN_REG) & DMAR_PMEN_PRS)
+ != 0));
+
+ return (error);
+}
+
int
dmar_enable_translation(struct dmar_unit *unit)
{
@@ -499,7 +526,10 @@
dmar_write4(unit, DMAR_GCMD_REG, unit->hw_gcmd);
DMAR_WAIT_UNTIL(((dmar_read4(unit, DMAR_GSTS_REG) & DMAR_GSTS_TES)
!= 0));
- return (error);
+ if (error != 0)
+ return (error);
+
+ return (dmar_disable_protected_regions(unit));
}
int

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 9, 7:39 AM (4 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28554419
Default Alt Text
D32591.id97214.diff (1 KB)

Event Timeline