VT-d: correct off-by-1 in number-of-IOMMUs check
authorJan Beulich <jbeulich@suse.com>
Tue, 23 Mar 2021 16:01:30 +0000 (17:01 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 23 Mar 2021 16:01:30 +0000 (17:01 +0100)
Otherwise, if we really run on a system with this many IOMMUs,
entering/leaving S3 would overrun iommu_state[].

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
xen/drivers/passthrough/vtd/iommu.c

index 9b58d566c8227756bff7294d99de2bfe2088ae3a..44e407d19f027c0041f00499a2562c85cd0414b7 100644 (file)
@@ -1168,10 +1168,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;
     }