]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
xen/page_alloc: Keep away MFN 0 from the buddy allocator
authorJulien Grall <julien.grall@arm.com>
Fri, 9 Aug 2019 12:14:40 +0000 (13:14 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 9 Aug 2019 18:12:55 +0000 (11:12 -0700)
Combining of buddies happens only such that the resulting larger buddy
is still order-aligned. To cross a zone boundary while merging, the
implication is that both the buddy [0, 2^n-1] and the buddy
[2^n, 2^(n+1)-1] are free.

Ideally we want to fix the allocator, but for now we can just prevent
adding the MFN 0 in the allocator to avoid merging across zone
boundaries.

On x86, the MFN 0 is already kept away from the buddy allocator. So the
bug can only happen on Arm platform where the first memory bank is
starting at 0.

As this is a specific to the allocator, the MFN 0 is removed in the common code
to cater all the architectures (current and future).

[Stefano: improve commit message]

Reported-by: Jeff Kubascik <jeff.kubascik@dornerworks.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Tested-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
xen/common/page_alloc.c

index b29c070c3da4044c87e968cb366f44693774990a..438e45ae75d8cc137c73502c9bcac14d85f9c99e 100644 (file)
@@ -1770,6 +1770,18 @@ static void init_heap_pages(
     unsigned long i;
     bool idle_scrub = false;
 
+    /*
+     * Keep MFN 0 away from the buddy allocator to avoid crossing zone
+     * boundary when merging two buddies.
+     */
+    if ( !mfn_x(page_to_mfn(pg)) )
+    {
+        if ( nr_pages-- <= 1 )
+            return;
+        pg++;
+    }
+
+
     /*
      * Some pages may not go through the boot allocator (e.g reserved
      * memory at boot but released just after --- kernel, initramfs,