From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57737) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SA0bg-0007bQ-FI for qemu-devel@nongnu.org; Tue, 20 Mar 2012 11:04:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SA0bS-0006IN-UY for qemu-devel@nongnu.org; Tue, 20 Mar 2012 11:04:16 -0400 Received: from 50-56-35-84.static.cloud-ips.com ([50.56.35.84]:60037 helo=mail.hallyn.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SA0bS-0006I9-Qb for qemu-devel@nongnu.org; Tue, 20 Mar 2012 11:04:02 -0400 Date: Tue, 20 Mar 2012 15:04:09 +0000 From: "Serge E. Hallyn" Message-ID: <20120320150408.GA8348@mail.hallyn.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 (fwd) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Scott Moser Cc: qemu-devel@nongnu.org Quoting Scott Moser (smoser@ubuntu.com): > Re-sending to qemu-devel. I'd originally sent this to kvm mailing list. > > > ---------- Forwarded message ---------- > Date: Sat, 17 Mar 2012 00:08:06 > From: Scott Moser > To: kvm@vger.kernel.org > Subject: [PATCH] fix multiboot loading if load_end_addr == 0 > > The previous code did not treat the case where load_end_addr was 0 > specially. The multiboot specification says the following: > * load_end_addr > Contains the physical address of the end of the data segment. > (load_end_addr - load_addr) specifies how much data to load. This > implies that the text and data segments must be consecutive in the > OS image; this is true for existing a.out executable formats. If > this field is zero, the boot loader assumes that the text and data > segments occupy the whole OS image file. > > This was raised initially as launchpad bug > https://bugs.launchpad.net/qemu/+bug/957622 > Tested-by: Serge Hallyn > diff --git a/hw/multiboot.c b/hw/multiboot.c > index b4484a3..b1e04c5 100644 > --- a/hw/multiboot.c > +++ b/hw/multiboot.c > @@ -202,10 +202,16 @@ 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 = 0; > mh_entry_addr = ldl_p(header+i+28); > - mb_kernel_size = mh_bss_end_addr - mh_load_addr; > + > + if (mh_load_end_addr) { > + mb_kernel_size = mh_bss_end_addr - mh_load_addr; > + mb_load_size = mh_load_end_addr - mh_load_addr; > + } else { > + mb_kernel_size = kernel_file_size - mb_kernel_text_offset; > + mb_load_size = mb_kernel_size; > + } > > /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. > uint32_t mh_mode_type = ldl_p(header+i+32);