]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
iommu/io-pgtable-arm: avoid speculative walks through TTBR1
authorWill Deacon <will.deacon@arm.com>
Wed, 18 Mar 2015 10:22:18 +0000 (10:22 +0000)
committerWill Deacon <will.deacon@arm.com>
Fri, 27 Mar 2015 13:39:36 +0000 (13:39 +0000)
Although we set TCR.T1SZ to 0, the input address range covered by TTBR1
is actually calculated using T0SZ in this case on the ARM SMMU. This
could theoretically lead to speculative table walks through physical
address zero, leading to all sorts of fun and games if we have MMIO
regions down there.

This patch avoids the issue by setting EPD1 to disable walks through
the unused TTBR1 register.

Signed-off-by: Will Deacon <will.deacon@arm.com>
drivers/iommu/io-pgtable-arm.c

index b610a8dee23820573b6362472b4ab5ec31c4003f..4e460216bd1644e5bb8a26ba9a4c3891d7452393 100644 (file)
 #define ARM_32_LPAE_TCR_EAE            (1 << 31)
 #define ARM_64_LPAE_S2_TCR_RES1                (1 << 31)
 
+#define ARM_LPAE_TCR_EPD1              (1 << 23)
+
 #define ARM_LPAE_TCR_TG0_4K            (0 << 14)
 #define ARM_LPAE_TCR_TG0_64K           (1 << 14)
 #define ARM_LPAE_TCR_TG0_16K           (2 << 14)
@@ -621,6 +623,9 @@ arm_64_lpae_alloc_pgtable_s1(struct io_pgtable_cfg *cfg, void *cookie)
        }
 
        reg |= (64ULL - cfg->ias) << ARM_LPAE_TCR_T0SZ_SHIFT;
+
+       /* Disable speculative walks through TTBR1 */
+       reg |= ARM_LPAE_TCR_EPD1;
        cfg->arm_lpae_s1_cfg.tcr = reg;
 
        /* MAIRs */