xen/arm: Fix crash if last memory section is bigger than 1gb
authorFrediano Ziglio <freddy77@gmail.com>
Thu, 2 Oct 2014 15:16:37 +0000 (16:16 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 3 Oct 2014 13:34:32 +0000 (14:34 +0100)
On arm32 the xenheap has a maximum size of 1GB. On systems with more than 8GB
(so 1/8 total RAM is greater than 1GB) there is no point in searching for a
region with 1/8 of the total RAM when only 1GB will be used. Therefore limit
the maximum size to 1GB before searching.

Signed-off-by: Frediano Ziglio <frediano.ziglio@huawei.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
[ ijc -- updated commit message as discussed ]

xen/arch/arm/setup.c

index 446de8a4eec84ac3ecbb563b1811f2cc6aed370f..c43c776a08f45a1b57032ff35a5a4cf93a911f76 100644 (file)
@@ -500,7 +500,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
      *
      *  - must be 32 MiB aligned
      *  - must not include Xen itself or the boot modules
-     *  - must be at most 1/8 the total RAM in the system
+     *  - must be at most 1GB or 1/8 the total RAM in the system if less
      *  - must be at least 128M
      *
      * We try to allocate the largest xenheap possible within these
@@ -509,6 +509,7 @@ static void __init setup_mm(unsigned long dtb_paddr, size_t dtb_size)
     heap_pages = ram_pages;
     xenheap_pages = (heap_pages/8 + 0x1fffUL) & ~0x1fffUL;
     xenheap_pages = max(xenheap_pages, 128UL<<(20-PAGE_SHIFT));
+    xenheap_pages = min(xenheap_pages, 1UL<<(30-PAGE_SHIFT));
 
     do
     {