Skip to content

Commit 4f46ea1

Browse files
lian-bojfvogel
authored andcommitted
amd_iommu: remap the device table of IOMMU with the memory encryption mask for kdump
Orabug: 28796835 In kdump kernel, it will copy the device table of IOMMU from the old device table, which is encrypted when SME is enabled in the first kernel. So we have to remap the old device table with the memory encryption mask. Signed-off-by: Lianbo Jiang <[email protected]> Acked-by: Joerg Roedel <[email protected]> Signed-off-by: Dan Duval <[email protected]> Reviewed-by: Henry Willard <[email protected]>
1 parent aac4849 commit 4f46ea1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/iommu/amd_iommu_init.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -902,12 +902,22 @@ static bool copy_device_table(void)
902902
}
903903
}
904904

905-
old_devtb_phys = entry & PAGE_MASK;
905+
/*
906+
* When SME is enabled in the first kernel, the entry includes the
907+
* memory encryption mask(sme_me_mask), we must remove the memory
908+
* encryption mask to obtain the true physical address in kdump kernel.
909+
*/
910+
old_devtb_phys = __sme_clr(entry) & PAGE_MASK;
911+
906912
if (old_devtb_phys >= 0x100000000ULL) {
907913
pr_err("The address of old device table is above 4G, not trustworthy!\n");
908914
return false;
909915
}
910-
old_devtb = memremap(old_devtb_phys, dev_table_size, MEMREMAP_WB);
916+
old_devtb = (sme_active() && is_kdump_kernel())
917+
? (__force void *)ioremap_encrypted(old_devtb_phys,
918+
dev_table_size)
919+
: memremap(old_devtb_phys, dev_table_size, MEMREMAP_WB);
920+
911921
if (!old_devtb)
912922
return false;
913923

0 commit comments

Comments
 (0)