@@ -328,6 +328,8 @@ static int __init process_chosen_node(const void *fdt, int node,
true);
if ( rc )
return rc;
+
+ reserved_heap = true;
}
printk("Checking for initrd in /chosen\n");
@@ -92,6 +92,8 @@ extern struct bootinfo bootinfo;
extern domid_t max_init_domid;
+extern bool reserved_heap;
+
void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len);
size_t estimate_efi_size(int mem_nr_banks);
@@ -73,6 +73,8 @@ integer_param("xenheap_megabytes", opt_xenheap_megabytes);
domid_t __read_mostly max_init_domid;
+bool reserved_heap;
+
static __used void init_done(void)
{
/* Must be done past setting system_state. */
@@ -772,41 +774,61 @@ static void __init setup_mm(void)
paddr_t ram_start = ~0;
paddr_t ram_end = 0;
paddr_t ram_size = 0;
+ paddr_t bank_start = ~0;
+ paddr_t bank_size = 0;
+ paddr_t bank_end = 0;
int bank;
init_pdx();
+ if ( reserved_heap )
+ {
+ for ( bank = 0 ; bank < bootinfo.reserved_mem.nr_banks; bank++ )
+ {
+ if ( bootinfo.reserved_mem.bank[bank].xen_heap )
+ {
+ bank_start = bootinfo.reserved_mem.bank[bank].start;
+ bank_size = bootinfo.reserved_mem.bank[bank].size;
+ bank_end = bank_start + bank_size;
+
+ init_boot_pages(bank_start, bank_end);
+ }
+ }
+ }
+
total_pages = 0;
for ( bank = 0 ; bank < bootinfo.mem.nr_banks; bank++ )
{
- paddr_t bank_start = bootinfo.mem.bank[bank].start;
- paddr_t bank_size = bootinfo.mem.bank[bank].size;
- paddr_t bank_end = bank_start + bank_size;
paddr_t s, e;
+ bank_start = bootinfo.mem.bank[bank].start;
+ bank_size = bootinfo.mem.bank[bank].size;
+ bank_end = bank_start + bank_size;
+
ram_size = ram_size + bank_size;
ram_start = min(ram_start,bank_start);
ram_end = max(ram_end,bank_end);
setup_xenheap_mappings(bank_start>>PAGE_SHIFT, bank_size>>PAGE_SHIFT);
- s = bank_start;
- while ( s < bank_end )
+ if ( !reserved_heap )
{
- paddr_t n = bank_end;
+ s = bank_start;
+ while ( s < bank_end )
+ {
+ paddr_t n = bank_end;
- e = next_module(s, &n);
+ e = next_module(s, &n);
- if ( e == ~(paddr_t)0 )
- {
- e = n = bank_end;
- }
+ if ( e == ~(paddr_t)0 )
+ e = n = bank_end;
- if ( e > bank_end )
- e = bank_end;
+ if ( e > bank_end )
+ e = bank_end;
- fw_unreserved_regions(s, e, init_boot_pages, 0);
- s = n;
+ fw_unreserved_regions(s, e, init_boot_pages, 0);
+ s = n;
+ }
}
}
This commit firstly adds a global variable `reserved_heap`. This newly introduced global variable is set at the device tree parsing time if the reserved Xenheap ranges are defined in the device tree chosen node. In `setup_mm`, If the reserved Xenheap is enabled and used, we make sure that these reserved Xenheap pages are added to the boot allocator. Otherwise there would be a case that if all available memory is used for the reserved Xenheap, the boot allocator will contain zero page at boot time and eventually cause failures. These reserved Xenheap pages in the boot allocator are added to the heap allocator at `end_boot_allocator()`. If the reserved Xenheap is disabled, we stick to the current page allocation strategy at boot time. Also, this commit removes some unneeded brackets in `setup_mm` following the Xen coding style. Signed-off-by: Henry Wang <Henry.Wang@arm.com> --- xen/arch/arm/bootfdt.c | 2 ++ xen/arch/arm/include/asm/setup.h | 2 ++ xen/arch/arm/setup.c | 52 +++++++++++++++++++++++--------- 3 files changed, 41 insertions(+), 15 deletions(-)