From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=46279 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OeeiK-0005ai-MT for qemu-devel@nongnu.org; Thu, 29 Jul 2010 21:48:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OeeiI-0003lF-7E for qemu-devel@nongnu.org; Thu, 29 Jul 2010 21:48:43 -0400 Received: from qmta03.westchester.pa.mail.comcast.net ([76.96.62.32]:50040) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OeeiI-0003l8-5N for qemu-devel@nongnu.org; Thu, 29 Jul 2010 21:48:42 -0400 From: Hollis Blanchard Date: Thu, 29 Jul 2010 18:48:24 -0700 Message-Id: <1280454504-31224-2-git-send-email-hollis@penguinppc.org> In-Reply-To: <1280454504-31224-1-git-send-email-hollis@penguinppc.org> References: <1280454504-31224-1-git-send-email-hollis@penguinppc.org> Subject: [Qemu-devel] [PATCH] loader: pad kernel size when loaded from a uImage List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm-ppc@vger.kernel.org, Hollis Blanchard The kernel's BSS size is lost by mkimage, which only considers file size. As a result, loading other blobs (e.g. device tree, initrd) immediately after the kernel location can result in them being zeroed by the kernel's BSS initialization code. Signed-off-by: Hollis Blanchard --- hw/loader.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/hw/loader.c b/hw/loader.c index 79a6f95..35bc25a 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -507,6 +507,13 @@ int load_uimage(const char *filename, target_phys_addr_t *ep, ret = hdr->ih_size; + /* The kernel's BSS size is lost by mkimage, which only considers file + * size. We don't know how big it is, but we do know we can't place + * anything immediately after the kernel. The padding seems like it should + * be proportional to overall file size, but we also make sure it's at + * least 4-byte aligned. */ + ret += (hdr->ih_size / 16) & ~0x3; + out: if (data) qemu_free(data); -- 1.7.1.1