From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmoAY-0001At-SE for qemu-devel@nongnu.org; Fri, 29 Jul 2011 10:36:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QmoAX-0006Kn-GL for qemu-devel@nongnu.org; Fri, 29 Jul 2011 10:36:06 -0400 Received: from mail-yi0-f45.google.com ([209.85.218.45]:33228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmoAX-0006Kj-Do for qemu-devel@nongnu.org; Fri, 29 Jul 2011 10:36:05 -0400 Received: by yia25 with SMTP id 25so3074920yia.4 for ; Fri, 29 Jul 2011 07:36:04 -0700 (PDT) Message-ID: <4E32C552.9040508@codemonkey.ws> Date: Fri, 29 Jul 2011 09:36:02 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <874o2bhdv5.fsf@industria.weinholt.se> In-Reply-To: <874o2bhdv5.fsf@industria.weinholt.se> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2] multiboot: Fix bss segment support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?B?R8O2cmFuIFdlaW5ob2x0?= Cc: qemu-devel@nongnu.org On 07/24/2011 10:55 AM, Göran Weinholt wrote: > Multiboot images can specify a bss segment. The boot loader must clear > the memory of the bss and ensure that no modules or structures are > allocated inside it. Several fields are provided in the Multiboot > header that were previously not used properly. The header is now used > to determine how much data should be read from the image and how much > memory should be reserved to the bss segment. > > Signed-off-by: Göran Weinholt Applied. Thanks. Regards, Anthony Liguori > --- > hw/multiboot.c | 14 +++++++++----- > 1 files changed, 9 insertions(+), 5 deletions(-) > > diff --git a/hw/multiboot.c b/hw/multiboot.c > index 2426e84..a1d3f41 100644 > --- a/hw/multiboot.c > +++ b/hw/multiboot.c > @@ -198,11 +198,14 @@ int load_multiboot(void *fw_cfg, > } else { > /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_ADDR. */ > uint32_t mh_header_addr = ldl_p(header+i+12); > + uint32_t mh_load_end_addr = ldl_p(header+i+20); > + 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; > > mh_entry_addr = ldl_p(header+i+28); > - mb_kernel_size = kernel_file_size - mb_kernel_text_offset; > + mb_kernel_size = mh_bss_end_addr - mh_load_addr; > > /* Valid if mh_flags sets MULTIBOOT_HEADER_HAS_VBE. > uint32_t mh_mode_type = ldl_p(header+i+32); > @@ -212,17 +215,18 @@ int load_multiboot(void *fw_cfg, > > mb_debug("multiboot: mh_header_addr = %#x\n", mh_header_addr); > mb_debug("multiboot: mh_load_addr = %#x\n", mh_load_addr); > - mb_debug("multiboot: mh_load_end_addr = %#x\n", ldl_p(header+i+20)); > - mb_debug("multiboot: mh_bss_end_addr = %#x\n", ldl_p(header+i+24)); > + mb_debug("multiboot: mh_load_end_addr = %#x\n", mh_load_end_addr); > + mb_debug("multiboot: mh_bss_end_addr = %#x\n", mh_bss_end_addr); > mb_debug("qemu: loading multiboot kernel (%#x bytes) at %#x\n", > - mb_kernel_size, mh_load_addr); > + mb_load_size, mh_load_addr); > > mbs.mb_buf = qemu_malloc(mb_kernel_size); > fseek(f, mb_kernel_text_offset, SEEK_SET); > - if (fread(mbs.mb_buf, 1, mb_kernel_size, f) != mb_kernel_size) { > + if (fread(mbs.mb_buf, 1, mb_load_size, f) != mb_load_size) { > fprintf(stderr, "fread() failed\n"); > exit(1); > } > + memset(mbs.mb_buf + mb_load_size, 0, mb_kernel_size - mb_load_size); > fclose(f); > } >