Skip to contentSkip to conversation

iommu/vt-d: Check capability before disabling protected memory

PATCH Applied Lu Baolu 2 participants 3 messages Mar 20, 2019 – Mar 22, 2019 IOMMU

lore
Share & tools
lore

Lu Baolu

author
#0 lore raw

PATCH 1/2 iommu/vt-d: Check capability before disabling protected memory

The spec states in 10.4.16 that the Protected Memory Enable Register should be treated as read-only for implementations not supporting protected memory regions (PLMR and PHMR fields reported as Clear in the Capability register).

Cc Jacob Pan <[email protected]>
Cc mark gross <[email protected]>
Fixes f8bab73515ca5 ("intel-iommu: PMEN support")
---
 drivers/iommu/intel-iommu.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/iommu/intel-iommu.c +3 -0
index 87274b54febd..f002d47d2f27 100644
@@ -1538,6 +1538,9 @@ static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu)
 	u32 pmen;
 	unsigned long flags;
 
+	if (!cap_plmr(iommu->cap) && !cap_phmr(iommu->cap))
+		return;
+
 	raw_spin_lock_irqsave(&iommu->register_lock, flags);
 	pmen = readl(iommu->reg + DMAR_PMEN_REG);
 	pmen &= ~DMA_PMEN_EPM;
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/2 iommu/vt-d: Save the right domain ID used by hardware

The driver sets a default domain id (FLPT_DEFAULT_DID) in the first level only pasid entry, but saves a different domain id in @sdev->did. The value saved in @sdev->did will be used to invalidate the translation caches. Hence, the driver might result in invalidating the caches with a wrong domain id.

Cc Ashok Raj <[email protected]>
Cc Jacob Pan <[email protected]>
Fixes 1c4f88b7f1f92 ("iommu/vt-d: Shared virtual address in scalable mode")
---
 drivers/iommu/intel-iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +1 -1
index f002d47d2f27..28cb713d728c 100644
@@ -5335,7 +5335,7 @@ int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sd
 
 	ctx_lo = context[0].lo;
 
-	sdev->did = domain->iommu_did[iommu->seq_id];
+	sdev->did = FLPT_DEFAULT_DID;
 	sdev->sid = PCI_DEVID(info->bus, info->devfn);
 
 	if (!(ctx_lo & CONTEXT_PASIDE)) {
Signature · 1 line
2.17.1
maintainer Applied
#2 lore raw
In reply to Lu Baolu
Quoted 5 lines · Lu Baolu

The spec states in 10.4.16 that the Protected Memory Enable Register should be treated as read-only for implementations not supporting protected memory regions (PLMR and PHMR fields reported as Clear in the Capability register).

Quoted 8 lines
Cc Jacob Pan <[email protected]>
Cc mark gross <[email protected]>
Fixes f8bab73515ca5 ("intel-iommu: PMEN support")
---
 drivers/iommu/intel-iommu.c | 3 +++
 1 file changed, 3 insertions(+)

Applied both, thanks.