Skip to contentSkip to conversation

iommu/vt-d: Disable superpages on Haswell

PATCH New Johnathan Chan 1 participant 1 message Sep 29

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/vt-d: Disable superpages on Haswell

The non-graphics DMAR unit of Haswell client processors reports 2MiB and 1GiB second-level superpage support (SLLPS = 0x3), but DMA that goes through a 2MiB superpage entry faults:

DMAR: [DMA Read NO_PASID] Request device [00:1f.2] fault addr 0xd1400000 [fault reason 0x0c] non-zero reserved fields in PTE
ata5.00: exception Emask 0x70 SAct 0x100000 SErr 0x440900 action 0x6 frozen ata5.00: irq_stat 0x28000008, host bus error, interface fatal error ata5.00: failed command: WRITE FPDMA QUEUED
ata5.00: cmd 61/00:a0:00:88:c5/20:00:39:00:00/40 tag 20 ncq dma 4194304 ou

The fault addresses are always 2MiB aligned. The leaf entries hold only R, W and PS with a 2MiB aligned output address, which is valid per the VT-d specification.

Until v6.13 this was hidden. The superpage level of a DMA domain was the smallest common denominator across all active DMAR units, and the graphics DMAR unit on these platforms reports SLLPS = 0, so superpages were never used. An older report shows that the fault appears as soon as the graphics unit is taken out of the picture with intel_iommu=igfx_off.

Since commit 7c204426b818 ("iommu/vt-d: Add domain_alloc_paging support"), the superpage capability of a paging domain comes only from the DMAR unit that serves the device, so on these systems every device behind the non-graphics unit gets superpage mappings. On an ext4-on- dm-crypt root on AHCI, large writes fail with I/O errors and the file system is corrupted. Other reports show the same fault on HD Audio and on a discrete GPU on Haswell machines.

Disable superpages when a Haswell host bridge is present, which restores the behaviour these platforms had before v6.13.

Hardware on which this was seen (all fault reason 0x0c, 2MiB aligned):
- Core i5-4690K, Z97 [8086:0c00], AHCI 00:1f.2
- Core i7-4790K [8086:0c00], 2MiB coherent DMA buffer
- ASRock Z97 Extreme6, HD Audio 00:1b.0 (v6.12 good, v6.13-rc6 bad)
- Core i7-4870HQ (Crystal Well), discrete GPU 01:00.0

Fixes 7c204426b818 ("iommu/vt-d: Add domain_alloc_paging support")
Assisted-by LLM

---
Notes (not for the changelog):

An LLM assistant was used to analyse the logs, find the culprit commit and draft the patch and changelog; I reviewed and tested the result.

Tested on i5-4690K / Z97X-UD3H [8086:0c00], ext4 on LVM on dm-crypt on AHCI:
- Unpatched v7.0-based kernel: the fault hit in 5 of 6 boots during normal use, losing file data.
- v7.0 + this patch: quirk message printed; no DMAR faults or I/O errors after 32GiB of fio 4MiB direct and buffered writes. The tested build differed only in comments. Clean with W=1 and sparse.
- Not tested: the other five IDs (worst case there is the pre-v6.13 behaviour), and fio on an unpatched kernel without sp_off.

Is there an Intel erratum for this? I found none publicly and would like to cite it if one exists.

 drivers/iommu/intel/iommu.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/iommu/intel/iommu.c +21 -0
index 2e3b3ab216f8..b108d1476d4b 100644
@@ -4034,6 +4034,27 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e30, quirk_iommu_rwbf);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e40, quirk_iommu_rwbf);
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e90, quirk_iommu_rwbf);
 
+static void quirk_iommu_no_superpage(struct pci_dev *dev)
+{
+	if (risky_device(dev))
+		return;
+
+	/*
+	 * The non-graphics DMAR unit reports superpage support, but DMA
+	 * through a 2MiB superpage entry faults.
+	 */
+	pci_info(dev, "Disabling IOMMU superpage support\n");
+	intel_iommu_superpage = 0;
+}
+
+/* Haswell DMAR superpage support is broken */
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0a04, quirk_iommu_no_superpage);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0c00, quirk_iommu_no_superpage);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0c04, quirk_iommu_no_superpage);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0c08, quirk_iommu_no_superpage);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0d00, quirk_iommu_no_superpage);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x0d04, quirk_iommu_no_superpage);
+
 #define GGC 0x52
 #define GGC_MEMORY_SIZE_MASK	(0xf << 8)
 #define GGC_MEMORY_SIZE_NONE	(0x0 << 8)

base-commit: 93f51579e7df248780214094418f205253383cc5

Signature · 1 line
2.43.0