This Linux kernel change "iommu/vt-d: Check capability before disabling protected memory" is included in the Linux 3.16.72 release. This change is authored by Lu Baolu <baolu.lu [at] linux.intel.com> on Wed Mar 20 09:58:33 2019 +0800. The commit for this change in Linux stable tree is b17048c (patch) which is from upstream commit 5bb71fc. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 5bb71fc.
iommu/vt-d: Check capability before disabling protected memory commit 5bb71fc790a88d063507dc5d445ab8b14e845591 upstream. 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]> Suggested-by: Ashok Raj <[email protected]> Fixes: f8bab73515ca5 ("intel-iommu: PMEN support") Signed-off-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]> Signed-off-by: Ben Hutchings <[email protected]>
There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.
drivers/iommu/intel-iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index b60eb1c..c2a44d2 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -1394,6 +1394,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;