diff --git a/xen/arch/arm/arm32/mmu/mm.c b/xen/arch/arm/arm32/mmu/mm.c index 063611412b..0824d61323 100644 --- a/xen/arch/arm/arm32/mmu/mm.c +++ b/xen/arch/arm/arm32/mmu/mm.c @@ -199,7 +199,7 @@ void __init setup_mm(void) total_pages = ram_size >> PAGE_SHIFT; - if ( bootinfo.static_heap ) + if ( using_static_heap ) { const struct membanks *reserved_mem = bootinfo_get_reserved_mem(); @@ -246,7 +246,7 @@ void __init setup_mm(void) do { - e = bootinfo.static_heap ? + e = using_static_heap ? fit_xenheap_in_static_heap(pfn_to_paddr(xenheap_pages), MB(32)) : consider_modules(ram_start, ram_end, pfn_to_paddr(xenheap_pages), diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c index 293d7efaed..80fad8b336 100644 --- a/xen/arch/arm/kernel.c +++ b/xen/arch/arm/kernel.c @@ -235,6 +235,13 @@ static __init int kernel_decompress(struct bootmodule *mod, uint32_t offset) for ( ; i < (1 << kernel_order_out); i++ ) free_domheap_page(pages + i); + /* + * When using static heap feature, don't give bootmodules memory back to + * the heap allocator + */ + if ( using_static_heap ) + return 0; + /* * When freeing the kernel, we need to pass the module start address and * size as they were before taking an offset to gzip header into account, diff --git a/xen/arch/arm/mmu/setup.c b/xen/arch/arm/mmu/setup.c index 9664e85ee6..8c87649bc8 100644 --- a/xen/arch/arm/mmu/setup.c +++ b/xen/arch/arm/mmu/setup.c @@ -341,8 +341,12 @@ void free_init_memory(void) if ( rc ) panic("Unable to remove the init section (rc = %d)\n", rc); - init_domheap_pages(pa, pa + len); - printk("Freed %ldkB init memory.\n", (long)(__init_end-__init_begin)>>10); + if ( !using_static_heap ) + { + init_domheap_pages(pa, pa + len); + printk("Freed %ldkB init memory.\n", + (long)(__init_end-__init_begin) >> 10); + } } /** diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 2e27af4560..545702d8a3 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -206,6 +206,13 @@ void __init discard_initial_modules(void) struct bootmodules *mi = &bootinfo.modules; int i; + /* + * When using static heap feature, don't give bootmodules memory back to + * the heap allocator + */ + if ( using_static_heap ) + goto out; + for ( i = 0; i < mi->nr_mods; i++ ) { paddr_t s = mi->module[i].start; @@ -223,6 +230,7 @@ void __init discard_initial_modules(void) mi->nr_mods = 0; + out: remove_early_mappings(); } diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/bootfdt.c index fc93d86e82..47386d4fff 100644 --- a/xen/common/device-tree/bootfdt.c +++ b/xen/common/device-tree/bootfdt.c @@ -410,7 +410,7 @@ static int __init process_chosen_node(const void *fdt, int node, if ( rc ) return rc; - bootinfo.static_heap = true; + using_static_heap = true; } printk("Checking for initrd in /chosen\n"); diff --git a/xen/common/device-tree/bootinfo.c b/xen/common/device-tree/bootinfo.c index 0daf5e941a..76d652c0de 100644 --- a/xen/common/device-tree/bootinfo.c +++ b/xen/common/device-tree/bootinfo.c @@ -407,7 +407,7 @@ void __init populate_boot_allocator(void) const struct membanks *reserved_mem = bootinfo_get_reserved_mem(); paddr_t s, e; - if ( bootinfo.static_heap ) + if ( using_static_heap ) { for ( i = 0 ; i < reserved_mem->nr_banks; i++ ) { diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 92abed6514..1f424333db 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -165,6 +165,9 @@ #define PGT_TYPE_INFO_INITIALIZER 0 #endif +/* Flag saved when Xen is using the static heap feature */ +bool __ro_after_init using_static_heap; + unsigned long __read_mostly max_page; unsigned long __read_mostly total_pages; paddr_t __ro_after_init mem_hotplug; diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h index 343c48b73d..c8bbfd8979 100644 --- a/xen/include/xen/bootfdt.h +++ b/xen/include/xen/bootfdt.h @@ -139,7 +139,6 @@ struct bootinfo { #ifdef CONFIG_STATIC_SHM struct shared_meminfo shmem; #endif - bool static_heap; }; #ifdef CONFIG_ACPI diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index d7dcf0f063..16f733281a 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -72,6 +72,8 @@ struct page_info; +extern bool using_static_heap; + void put_page(struct page_info *page); bool __must_check get_page(struct page_info *page, const struct domain *domain);