@@ -199,7 +199,7 @@ void __init setup_mm(void)
total_pages = ram_size >> PAGE_SHIFT;
- if ( bootinfo.static_heap )
+ if ( xen_is_using_staticheap() )
{
const struct membanks *reserved_mem = bootinfo_get_reserved_mem();
@@ -246,7 +246,7 @@ void __init setup_mm(void)
do
{
- e = bootinfo.static_heap ?
+ e = xen_is_using_staticheap() ?
fit_xenheap_in_static_heap(pfn_to_paddr(xenheap_pages), MB(32)) :
consider_modules(ram_start, ram_end,
pfn_to_paddr(xenheap_pages),
@@ -244,10 +244,11 @@ static __init int kernel_decompress(struct bootmodule *mod, uint32_t offset)
size += offset;
/*
- * Free the original kernel, update the pointers to the
- * decompressed kernel
+ * In case Xen is not using the static heap feature, free the original
+ * kernel, update the pointers to the decompressed kernel
*/
- fw_unreserved_regions(addr, addr + size, init_domheap_pages, 0);
+ if ( !xen_is_using_staticheap() )
+ fw_unreserved_regions(addr, addr + size, init_domheap_pages, 0);
return 0;
}
@@ -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 ( !xen_is_using_staticheap() )
+ {
+ init_domheap_pages(pa, pa + len);
+ printk("Freed %ldkB init memory.\n",
+ (long)(__init_end-__init_begin) >> 10);
+ }
}
/**
@@ -206,24 +206,25 @@ void __init discard_initial_modules(void)
struct bootmodules *mi = &bootinfo.modules;
int i;
- for ( i = 0; i < mi->nr_mods; i++ )
+ if ( !xen_is_using_staticheap() )
{
- paddr_t s = mi->module[i].start;
- paddr_t e = s + PAGE_ALIGN(mi->module[i].size);
-
- if ( mi->module[i].kind == BOOTMOD_XEN )
- continue;
+ for ( i = 0; i < mi->nr_mods; i++ )
+ {
+ paddr_t s = mi->module[i].start;
+ paddr_t e = s + PAGE_ALIGN(mi->module[i].size);
- if ( !mfn_valid(maddr_to_mfn(s)) ||
- !mfn_valid(maddr_to_mfn(e)) )
- continue;
+ if ( mi->module[i].kind == BOOTMOD_XEN )
+ continue;
- fw_unreserved_regions(s, e, init_domheap_pages, 0);
- }
+ if ( !mfn_valid(maddr_to_mfn(s)) ||
+ !mfn_valid(maddr_to_mfn(e)) )
+ continue;
- mi->nr_mods = 0;
+ fw_unreserved_regions(s, e, init_domheap_pages, 0);
+ }
- remove_early_mappings();
+ mi->nr_mods = 0;
+ }
}
/* Relocate the FDT in Xen heap */
@@ -403,7 +403,9 @@ static int __init process_chosen_node(const void *fdt, int node,
if ( rc )
return rc;
- bootinfo.static_heap = true;
+#ifdef CONFIG_STATIC_MEMORY
+ static_heap = true;
+#endif
}
printk("Checking for initrd in /chosen\n");
@@ -386,7 +386,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 ( xen_is_using_staticheap() )
{
for ( i = 0 ; i < reserved_mem->nr_banks; i++ )
{
@@ -164,6 +164,11 @@
#define PGT_TYPE_INFO_INITIALIZER 0
#endif
+#ifdef CONFIG_STATIC_MEMORY
+/* Flag saved when Xen is using the static heap feature (xen,static-heap) */
+bool __ro_after_init static_heap;
+#endif
+
unsigned long __read_mostly max_page;
unsigned long __read_mostly total_pages;
paddr_t __ro_after_init mem_hotplug;
@@ -132,7 +132,6 @@ struct bootinfo {
#ifdef CONFIG_STATIC_SHM
struct shared_meminfo shmem;
#endif
- bool static_heap;
};
#ifdef CONFIG_ACPI
@@ -157,6 +156,10 @@ struct bootinfo {
extern struct bootinfo bootinfo;
+#ifdef CONFIG_STATIC_MEMORY
+extern bool static_heap;
+#endif
+
bool check_reserved_regions_overlap(paddr_t region_start,
paddr_t region_size);
@@ -206,4 +209,13 @@ static inline struct shmem_membank_extra *bootinfo_get_shmem_extra(void)
}
#endif
+static inline bool xen_is_using_staticheap(void)
+{
+#ifdef CONFIG_STATIC_MEMORY
+ return static_heap;
+#else
+ return false;
+#endif
+}
+
#endif /* XEN_BOOTFDT_H */