From: Alejandro Jimenez Date: Tue, 17 Jun 2025 15:04:25 +0000 (+0000) Subject: amd_iommu: Fix the calculation for Device Table size X-Git-Tag: v7.2.19~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=452a0cb27bf8a2c3aa98e28c24fbce12c1034fb0;p=thirdparty%2Fqemu.git amd_iommu: Fix the calculation for Device Table size Correctly calculate the Device Table size using the format encoded in the Device Table Base Address Register (MMIO Offset 0000h). Cc: qemu-stable@nongnu.org Fixes: d29a09ca6842 ("hw/i386: Introduce AMD IOMMU") Signed-off-by: Alejandro Jimenez Reviewed-by: Vasant Hegde Message-Id: <20250617150427.20585-7-alejandro.j.jimenez@oracle.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 67d3077ee403472d45794399e97c9f329242fce9) Signed-off-by: Michael Tokarev --- diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index f2da6348f65..0df9c1a2323 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -640,8 +640,8 @@ static inline void amdvi_handle_devtab_write(AMDVIState *s) uint64_t val = amdvi_readq(s, AMDVI_MMIO_DEVICE_TABLE); s->devtab = (val & AMDVI_MMIO_DEVTAB_BASE_MASK); - /* set device table length */ - s->devtab_len = ((val & AMDVI_MMIO_DEVTAB_SIZE_MASK) + 1 * + /* set device table length (i.e. number of entries table can hold) */ + s->devtab_len = (((val & AMDVI_MMIO_DEVTAB_SIZE_MASK) + 1) * (AMDVI_MMIO_DEVTAB_SIZE_UNIT / AMDVI_MMIO_DEVTAB_ENTRY_SIZE)); }