[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 11/13] xen: move initrd away from e820 non-ram area



When adapting the dom0 memory layout to that of the host make sure
the initrd isn't moved to another pfn range, as it won't be found
there any more.

The easiest way to accomplish that is by copying the initrd to an
area which is RAM according to the E820 map.

Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
---
 arch/x86/xen/enlighten.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 78a881b..21c82dfd 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1530,6 +1530,25 @@ static void __init xen_pvh_early_guest_init(void)
 }
 #endif    /* CONFIG_XEN_PVH */
 
+static int __init xen_initrd_mem_conflict(phys_addr_t start, phys_addr_t size)
+{
+       phys_addr_t new;
+
+       new = xen_find_free_area(size);
+       if (!new)
+               panic("initrd is located at position conflicting with E820 
map!\n");
+
+       xen_phys_memcpy(new, start, size);
+       pr_info("initrd moved from [mem %#010llx-%#010llx] to [mem 
%#010llx-%#010llx]\n",
+               start, start + size, new, new + size);
+       memblock_free(start, size);
+
+       boot_params.hdr.ramdisk_image = new;
+       boot_params.ext_ramdisk_image = new >> 32;
+
+       return 1;
+}
+
 /* First C function to be called on Xen boot */
 asmlinkage __visible void __init xen_start_kernel(void)
 {
@@ -1691,6 +1710,9 @@ asmlinkage __visible void __init xen_start_kernel(void)
        boot_params.hdr.ramdisk_size = xen_start_info->mod_len;
        boot_params.hdr.cmd_line_ptr = __pa(xen_start_info->cmd_line);
 
+       xen_add_reserved_area(initrd_start, xen_start_info->mod_len,
+                             xen_initrd_mem_conflict, 0);
+
        if (!xen_initial_domain()) {
                add_preferred_console("xenboot", 0, NULL);
                add_preferred_console("tty", 0, NULL);
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.