From patchwork Mon Jan 23 12:49:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?G=C3=B6ran_Weinholt?= X-Patchwork-Id: 137353 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BE30AB6FBC for ; Mon, 23 Jan 2012 23:50:27 +1100 (EST) Received: from localhost ([::1]:60790 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpJLo-00049z-BZ for incoming@patchwork.ozlabs.org; Mon, 23 Jan 2012 07:50:20 -0500 Received: from eggs.gnu.org ([140.186.70.92]:52255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpJLf-00049u-5r for qemu-devel@nongnu.org; Mon, 23 Jan 2012 07:50:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RpJLZ-0003XZ-4Y for qemu-devel@nongnu.org; Mon, 23 Jan 2012 07:50:11 -0500 Received: from gula.weinholt.se ([95.80.32.2]:59020 helo=mail.weinholt.se) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RpJLY-0003V0-Di; Mon, 23 Jan 2012 07:50:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=weinholt.se; s=gula2011; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:Cc:To:From; bh=OtDiHKDOaZyjmuckPBjKY3ekP6uiw3am2oqPeSDaoA8=; b=Xh86zxRS+llySI7rSShBnuX3fMuqMnyMAP+/Z1GpMDiCY+jafzKYf3Fh6POffB/GpRMMAjj/SKGPtW+n+lAZ3qSXSCSiyhwnLzP8QE4YqnQE1eoNugqi8zPVAhid9lwk41UR+iHGXGOF+v7mrlz2LXBf0sWhlymSouzVC5V1+tE9Q3YWHXu5oOFlxQ4sSALSuSd9Wt7i0VkvHRgrp8246i3Q6/0w5L4L71mU6bGE1g9CjUuNcMuECH4JD1a2q8tz; Received: from Uindustria by mail.weinholt.se with local-bsmtp (Exim 4.72) (envelope-from ) id 1RpJLL-0001Yq-T2; Mon, 23 Jan 2012 13:49:52 +0100 Received: from weinholt by localhost with local (Exim 4.72) (envelope-from ) id 1RpJKl-0000rk-FM; Mon, 23 Jan 2012 13:49:15 +0100 X-Hashcash: 1:20:120123:qemu-devel@nongnu.org::TBQ3CAW4yz/+Tusc:00000000000000000000000000000000000000005CT7 X-Hashcash: 1:20:120123:agraf@suse.de::iiEn64l4RU/JtF1B:00002LVm X-Hashcash: 1:20:120123:rene@exactcode.de::fZ77R400ezbhcPOj:0000000000000000000000000000000000000000000049db X-Hashcash: 1:20:120123:jmforbes@linuxtx.org::oz8k60vjys1AOGga:000000000000000000000000000000000000000000LE5 X-Hashcash: 1:20:120123:qemu-stable@nongnu.org::wKsKhA+xxFN+WE1d:0000000000000000000000000000000000000000Vjp X-Hashcash: 1:20:120123:kwolf@redhat.com::J+ym6+xlr1rQiom2:006qd From: =?utf-8?Q?G=C3=B6ran?= Weinholt To: qemu-devel@nongnu.org Date: Mon, 23 Jan 2012 13:49:15 +0100 Message-ID: <87mx9ezir8.fsf@industria.weinholt.se> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 95.80.32.2 Cc: Kevin Wolf , "Justin M. Forbes" , =?utf-8?Q?Ren=C3=A9?= Rebe , Alexander Graf , qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH] multiboot: mh_load_end_addr and mh_bss_end_addr may be zero X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org There are two special cases in the address fields of the multiboot format. If mh_load_end_addr is zero then the whole image file should be loaded and if mh_bss_end_addr is zero then there is no bss segment. With this change it is again possible to boot kernels where these fields are zero. Signed-off-by: Göran Weinholt Tested-by: Alexander Graf --- hw/multiboot.c | 15 ++++++++++++++- 1 files changed, 14 insertions(+), 1 deletions(-) diff --git a/hw/multiboot.c b/hw/multiboot.c index b4484a3..db28328 100644 --- a/hw/multiboot.c +++ b/hw/multiboot.c @@ -202,10 +202,23 @@ int load_multiboot(void *fw_cfg, uint32_t mh_bss_end_addr = ldl_p(header+i+24); mh_load_addr = ldl_p(header+i+16); uint32_t mb_kernel_text_offset = i - (mh_header_addr - mh_load_addr); - uint32_t mb_load_size = mh_load_end_addr - mh_load_addr; + uint32_t mb_load_size; + + /* A load end address of zero indicates that the whole file + * should be loaded. */ + if (!mh_load_end_addr) { + mh_load_end_addr = kernel_file_size + mh_load_addr; + } + + /* A bss end address of zero indicates that there is no bss + * segment. */ + if (!mh_bss_end_addr) { + mh_bss_end_addr = mh_load_end_addr; + } mh_entry_addr = ldl_p(header+i+28); mb_kernel_size = mh_bss_end_addr - mh_load_addr; + mb_load_size = mh_load_end_addr - mh_load_addr; /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. uint32_t mh_mode_type = ldl_p(header+i+32);