From: Jan Beulich Subject: AMD/IOMMU: correct devtab size writing The fix for XSA-524 inadvertently converted a page-granular value to a byte-granular one, thus always setting maximum size (2Mb) without the table always being that size. Fixes: d7378932b1fc ("AMD/IOMMU: allocate (at least) one spare device table entry") Reported-by: Roger Pau Monné Signed-off-by: Jan Beulich Reviewed-by: Roger Pau Monné --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -80,9 +80,8 @@ static void register_iommu_dev_table_in_ entry = 0; iommu_set_addr_lo_to_reg(&entry, addr_lo >> PAGE_SHIFT); - set_field_in_reg_u32(ROUNDUP(iommu->dev_table.entries * - IOMMU_DEV_TABLE_ENTRY_SIZE, - PAGE_SIZE) - 1, + set_field_in_reg_u32(PFN_UP(iommu->dev_table.entries * + IOMMU_DEV_TABLE_ENTRY_SIZE) - 1, entry, IOMMU_DEV_TABLE_SIZE_MASK, IOMMU_DEV_TABLE_SIZE_SHIFT, &entry); writel(entry, iommu->mmio_base + IOMMU_DEV_TABLE_BASE_LOW_OFFSET);