[PATCH 1/4][4.15?] VT-d: correct off-by-1 in number-of-IOMMUs check

Jan Beulich posted 4 patches 3 years, 8 months ago
[PATCH 1/4][4.15?] VT-d: correct off-by-1 in number-of-IOMMUs check
Posted by Jan Beulich 3 years, 8 months ago
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>
---
There are more anomalies here, but since we were asked to not make any
cosmetic changes for patches to have a chance to go into 4.15, I've put
off correcting even the most obvious things (scope of MAX_IOMMUS and
nr_iommus) for a later patch.

--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1168,10 +1168,10 @@ int __init iommu_alloc(struct acpi_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;
     }
 


Re: [PATCH 1/4][4.15?] VT-d: correct off-by-1 in number-of-IOMMUs check
Posted by Ian Jackson 3 years, 8 months ago
Jan Beulich writes ("[PATCH 1/4][4.15?] 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[].

Release-Acked-by: Ian Jackson <iwj@xenproject.org>