iommu/vt-d: Check capability before disabling protected memory
authorLu Baolu <baolu.lu@linux.intel.com>
Wed, 20 Mar 2019 01:58:33 +0000 (09:58 +0800)
committerJoerg Roedel <jroedel@suse.de>
Fri, 22 Mar 2019 11:02:26 +0000 (12:02 +0100)
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 <jacob.jun.pan@linux.intel.com>
Cc: mark gross <mgross@intel.com>
Suggested-by: Ashok Raj <ashok.raj@intel.com>
Fixes: f8bab73515ca5 ("intel-iommu: PMEN support")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel-iommu.c

index 87274b54febd0eb3cfb1dd3358609fa037c90095..f002d47d2f27a95438def0aa4d2c471e9ced9e4b 100644 (file)
@@ -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;