Received: from eggs.gnu.org ([140.186.70.92]:40488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RsOkQ-0007Mk-Fc for qemu-devel@nongnu.org; Tue, 31 Jan 2012 20:12:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RsOkK-0006b9-Jn for qemu-devel@nongnu.org; Tue, 31 Jan 2012 20:12:30 -0500 From: =?utf-8?Q?G=C3=B6ran?= Weinholt References: <87mx9ezir8.fsf@industria.weinholt.se> <4F27F63E.9050307@redhat.com> Date: Wed, 01 Feb 2012 01:44:43 +0100 In-Reply-To: <4F27F63E.9050307@redhat.com> (Kevin Wolf's message of "Tue, 31 Jan 2012 15:10:06 +0100") Message-ID: <87pqdz2xhg.fsf@industria.weinholt.se> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [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: Kevin Wolf Cc: =?utf-8?Q?Ren=C3=A9?= Rebe , qemu-stable@nongnu.org, "Justin M. Forbes" , qemu-devel@nongnu.org, Alexander Graf Kevin Wolf writes: > Am 23.01.2012 13:49, schrieb G=C3=B6ran Weinholt: >> 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. >>=20 >> Signed-off-by: G=C3=B6ran Weinholt >> Tested-by: Alexander Graf >> --- >> hw/multiboot.c | 15 ++++++++++++++- >> 1 files changed, 14 insertions(+), 1 deletions(-) >>=20 >> 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_loa= d_addr); >> - 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; > > This is only right if the OS image starts at offset 0 in the image file. > IIUC, in the general case it starts at byte i - (mh_header_addr - > mh_load_addr), so you need to subtract this from kernel_file_size. I think you're right. It would be good if someone could have a look at fixing the patch. I will not have time to do it myself. Please Cc me so that I can test it on my own kernel images. Regards, --=20 G=C3=B6ran Weinholt "The bus! I have missed the bus! I have become... tardy!" -- Dexter's Lab