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 From: =?utf-8?Q?G=C3=B6ran?= Weinholt Date: Mon, 23 Jan 2012 13:49:15 +0100 Message-ID: <87mx9ezir8.fsf@industria.weinholt.se> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH] multiboot: mh_load_end_addr and mh_bss_end_addr may be zero List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Justin M. Forbes" , =?utf-8?Q?Ren=C3=A9?= Rebe , Alexander Graf , qemu-stable@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=C3=B6ran 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 =3D ldl_p(header+i+24); mh_load_addr =3D ldl_p(header+i+16); uint32_t mb_kernel_text_offset =3D i - (mh_header_addr - mh_load_a= ddr); - uint32_t mb_load_size =3D 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 =3D 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 =3D mh_load_end_addr; + } =20 mh_entry_addr =3D ldl_p(header+i+28); mb_kernel_size =3D mh_bss_end_addr - mh_load_addr; + mb_load_size =3D mh_load_end_addr - mh_load_addr; =20 /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. uint32_t mh_mode_type =3D ldl_p(header+i+32); --=20 1.7.2.5