iommu/vt-d: Check capability before disabling protected memory
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).
--- drivers/iommu/intel-iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/intel-iommu.c +3 -0
@@ -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
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.
--- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +1 -1
@@ -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
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]>Suggested-by Ashok Raj <[email protected]>Fixes f8bab73515ca5 ("intel-iommu: PMEN support")Signed-off-by Lu Baolu <[email protected]>--- drivers/iommu/intel-iommu.c | 3 +++ 1 file changed, 3 insertions(+)
Applied both, thanks.