From: Jan Beulich Date: Tue, 20 Apr 2021 10:01:40 +0000 (+0200) Subject: VT-d: correct off-by-1 in number-of-IOMMUs check X-Git-Tag: archive/raspbian/4.14.2+25-gb6a8c4f72d-2+rpi1^2~47^2~33 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0c4caea34a16173a14074327992122e895984cea;p=xen.git VT-d: correct off-by-1 in number-of-IOMMUs check Otherwise, if we really run on a system with this many IOMMUs, entering/leaving S3 would overrun iommu_state[]. Signed-off-by: Jan Beulich Reviewed-by: Kevin Tian master commit: b9b3082002cac68726fb303e0abd2ff0113d4657 master date: 2021-03-23 17:01:30 +0100 --- diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c index 58128be8b5..ca09cd515c 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1163,10 +1163,10 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd) unsigned long sagaw, nr_dom; int agaw; - if ( nr_iommus > MAX_IOMMUS ) + if ( nr_iommus >= MAX_IOMMUS ) { dprintk(XENLOG_ERR VTDPREFIX, - "IOMMU: nr_iommus %d > MAX_IOMMUS\n", nr_iommus); + "IOMMU: nr_iommus %d > MAX_IOMMUS\n", nr_iommus + 1); return -ENOMEM; }