Skip to content

Commit 9abe2ac

Browse files
marcanjoergroedel
authored andcommitted
iommu/io-pgtable-arm: Fix table descriptor paddr formatting
Table descriptors were being installed without properly formatting the address using paddr_to_iopte, which does not match up with the iopte_deref in __arm_lpae_map. This is incorrect for the LPAE pte format, as it does not handle the high bits properly. This was found on Apple T6000 DARTs, which require a new pte format (different shift); adding support for that to paddr_to_iopte/iopte_to_paddr caused it to break badly, as even <48-bit addresses would end up incorrect in that case. Fixes: 6c89928 ("iommu/io-pgtable-arm: Support 52-bit physical address") Acked-by: Robin Murphy <[email protected]> Signed-off-by: Hector Martin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 556f99a commit 9abe2ac

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

drivers/iommu/io-pgtable-arm.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,12 @@ static int arm_lpae_init_pte(struct arm_lpae_io_pgtable *data,
315315
static arm_lpae_iopte arm_lpae_install_table(arm_lpae_iopte *table,
316316
arm_lpae_iopte *ptep,
317317
arm_lpae_iopte curr,
318-
struct io_pgtable_cfg *cfg)
318+
struct arm_lpae_io_pgtable *data)
319319
{
320320
arm_lpae_iopte old, new;
321+
struct io_pgtable_cfg *cfg = &data->iop.cfg;
321322

322-
new = __pa(table) | ARM_LPAE_PTE_TYPE_TABLE;
323+
new = paddr_to_iopte(__pa(table), data) | ARM_LPAE_PTE_TYPE_TABLE;
323324
if (cfg->quirks & IO_PGTABLE_QUIRK_ARM_NS)
324325
new |= ARM_LPAE_PTE_NSTABLE;
325326

@@ -380,7 +381,7 @@ static int __arm_lpae_map(struct arm_lpae_io_pgtable *data, unsigned long iova,
380381
if (!cptep)
381382
return -ENOMEM;
382383

383-
pte = arm_lpae_install_table(cptep, ptep, 0, cfg);
384+
pte = arm_lpae_install_table(cptep, ptep, 0, data);
384385
if (pte)
385386
__arm_lpae_free_pages(cptep, tblsz, cfg);
386387
} else if (!cfg->coherent_walk && !(pte & ARM_LPAE_PTE_SW_SYNC)) {
@@ -592,7 +593,7 @@ static size_t arm_lpae_split_blk_unmap(struct arm_lpae_io_pgtable *data,
592593
__arm_lpae_init_pte(data, blk_paddr, pte, lvl, 1, &tablep[i]);
593594
}
594595

595-
pte = arm_lpae_install_table(tablep, ptep, blk_pte, cfg);
596+
pte = arm_lpae_install_table(tablep, ptep, blk_pte, data);
596597
if (pte != blk_pte) {
597598
__arm_lpae_free_pages(tablep, tablesz, cfg);
598599
/*

0 commit comments

Comments
 (0)