if ( assign_pages(mfn_to_page(_mfn(mfn++)), 1, d, 0) )
BUG();
}
+
+ /*
+ * We have either:
+ * - Mapped the initrd directly into dom0, or
+ * - Copied it and freed the module.
+ *
+ * Either way, tell discard_initial_images() to not free it a second
+ * time.
+ */
initrd->mod_end = 0;
iommu_memory_setup(d, "initrd", mfn_to_page(_mfn(initrd_mfn)),
return nr;
}
-void __init discard_initial_images(void)
+void __init discard_initial_images(void) /* a.k.a. Free boot modules */
{
struct boot_info *bi = &xen_boot_info;
unsigned int i;
for ( i = 0; i < bi->nr_modules; ++i )
{
uint64_t start = pfn_to_paddr(bi->mods[i].mod->mod_start);
+ uint64_t size = bi->mods[i].mod->mod_end;
- init_domheap_pages(start,
- start + PAGE_ALIGN(bi->mods[i].mod->mod_end));
+ /*
+ * Sometimes the initrd is mapped, rather than copied, into dom0.
+ * Size being 0 is how we're instructed to leave the module alone.
+ */
+ if ( size == 0 )
+ continue;
+
+ init_domheap_pages(start, start + PAGE_ALIGN(size));
}
bi->nr_modules = 0;