iommu/amd: Set exclusion range correctly [Linux 3.16.72]

This Linux kernel change "iommu/amd: Set exclusion range correctly" is included in the Linux 3.16.72 release. This change is authored by Joerg Roedel <jroedel [at] suse.de> on Fri Apr 12 12:50:31 2019 +0200. The commit for this change in Linux stable tree is a11a987 (patch) which is from upstream commit 3c677d2. 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 3c677d2.

iommu/amd: Set exclusion range correctly

commit 3c677d206210f53a4be972211066c0f1cd47fe12 upstream.

The exlcusion range limit register needs to contain the
base-address of the last page that is part of the range, as
bits 0-11 of this register are treated as 0xfff by the
hardware for comparisons.

So correctly set the exclusion range in the hardware to the
last page which is _in_ the range.

Fixes: b2026aa2dce44 ('x86, AMD IOMMU: add functions for programming IOMMU MMIO space')
Signed-off-by: Joerg Roedel <[email protected]>
Signed-off-by: Ben Hutchings <[email protected]>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/iommu/amd_iommu_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c
index 48b726f..006f4f9 100644
--- a/drivers/iommu/amd_iommu_init.c
+++ b/drivers/iommu/amd_iommu_init.c
@@ -293,7 +293,7 @@ static void iommu_write_l2(struct amd_iommu *iommu, u8 address, u32 val)
 static void iommu_set_exclusion_range(struct amd_iommu *iommu)
 {
    u64 start = iommu->exclusion_start & PAGE_MASK;
-   u64 limit = (start + iommu->exclusion_length) & PAGE_MASK;
+   u64 limit = (start + iommu->exclusion_length - 1) & PAGE_MASK;
    u64 entry;

    if (!iommu->exclusion_start)

Leave a Reply

Your email address will not be published. Required fields are marked *