From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753333AbbBRGwn (ORCPT ); Wed, 18 Feb 2015 01:52:43 -0500 Received: from cantor2.suse.de ([195.135.220.15]:37062 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752862AbbBRGwQ (ORCPT ); Wed, 18 Feb 2015 01:52:16 -0500 From: Juergen Gross To: linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com, konrad.wilk@oracle.com, david.vrabel@citrix.com, boris.ostrovsky@oracle.com Cc: Juergen Gross Subject: [PATCH 11/13] xen: move initrd away from e820 non-ram area Date: Wed, 18 Feb 2015 07:52:04 +0100 Message-Id: <1424242326-26611-12-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424242326-26611-1-git-send-email-jgross@suse.com> References: <1424242326-26611-1-git-send-email-jgross@suse.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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