]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/PoD: Avoid using variable length arrays in p2m_pod_zero_check()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 17 Sep 2018 15:30:53 +0000 (16:30 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 25 Sep 2018 10:59:32 +0000 (11:59 +0100)
Callers of p2m_pod_zero_check() pass a count of up to POD_SWEEP_STRIDE.
Move the definition of POD_SWEEP_STRIDE and give the arrays a fixed
bound.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/mm/p2m-pod.c

index 5ad62d71c717e2680dbafb30da8cd120f40e83d1..4c56cb58c67abef6bb582cd47321a6e05da9c6ab 100644 (file)
@@ -862,15 +862,19 @@ out:
     return ret;
 }
 
+#define POD_SWEEP_LIMIT 1024
+#define POD_SWEEP_STRIDE  16
+
 static void
 p2m_pod_zero_check(struct p2m_domain *p2m, const gfn_t *gfns, unsigned int count)
 {
-    mfn_t mfns[count];
-    p2m_type_t types[count];
-    unsigned long *map[count];
+    mfn_t mfns[POD_SWEEP_STRIDE];
+    p2m_type_t types[POD_SWEEP_STRIDE];
+    unsigned long *map[POD_SWEEP_STRIDE];
     struct domain *d = p2m->domain;
     unsigned int i, j, max_ref = 1;
 
+    BUG_ON(count > POD_SWEEP_STRIDE);
 
     /* Allow an extra refcount for one shadow pt mapping in shadowed domains */
     if ( paging_mode_shadow(d) )
@@ -1012,8 +1016,6 @@ out_unmap:
             unmap_domain_page(map[i]);
 }
 
-#define POD_SWEEP_LIMIT 1024
-#define POD_SWEEP_STRIDE  16
 static void
 p2m_pod_emergency_sweep(struct p2m_domain *p2m)
 {