Patchwork [v2] multiboot: Fix bss segment support

login
register
mail settings
Submitter Göran Weinholt
Date Dec. 20, 2011, 6:49 p.m.
Message ID <878vm76puh.fsf@industria.weinholt.se>
Download mbox | patch
Permalink /patch/132500/
State New
Headers show

Comments

Göran Weinholt - Dec. 20, 2011, 6:49 p.m.
Alexander Graf <agraf@suse.de> writes:

> Yes, this patch makes things work again :). Thanks a lot!
>
> The only thing I could nitpick on would be the coding style - checkpatch.pl complains :). Could you please resend with braces?
> Justin, Please also queue this for 1.0-stable when it comes in its final form.
>
> Tested-by: Alexander Graf <agraf@suse.de>

Thanks for testing it. Here it is, with braces this time.


From 2a2df801d68a76fb2210e556652fb2e17e0f6711 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=B6ran=20Weinholt?= <goran@weinholt.se>
Date: Tue, 20 Dec 2011 19:36:10 +0100
Subject: [PATCH] multiboot: mh_load_end_addr and mh_bss_end_addr may be zero
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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 <goran@weinholt.se>
Tested-by: Alexander Graf <agraf@suse.de>
---
 hw/multiboot.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)
Alexander Graf - Dec. 20, 2011, 7:46 p.m.
On 20.12.2011, at 19:49, Göran Weinholt <goran@weinholt.se> wrote:

> Alexander Graf <agraf@suse.de> writes:
> 
>> Yes, this patch makes things work again :). Thanks a lot!
>> 
>> The only thing I could nitpick on would be the coding style - checkpatch.pl complains :). Could you please resend with braces?
>> Justin, Please also queue this for 1.0-stable when it comes in its final form.
>> 
>> Tested-by: Alexander Graf <agraf@suse.de>
> 
> Thanks for testing it. Here it is, with braces this time.
> 
> 
> From 2a2df801d68a76fb2210e556652fb2e17e0f6711 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?G=C3=B6ran=20Weinholt?= <goran@weinholt.se>
> Date: Tue, 20 Dec 2011 19:36:10 +0100
> Subject: [PATCH] multiboot: mh_load_end_addr and mh_bss_end_addr may be zero
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> 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 <goran@weinholt.se>
> Tested-by: Alexander Graf <agraf@suse.de>

Acked-by: Alexander Graf <agraf@suse.de>

Alex

> ---
> 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);
> -- 
> 1.7.2.5
> 
> 
> -- 
> Göran Weinholt <goran@weinholt.se>
Kevin Wolf - Jan. 23, 2012, 11:34 a.m.
Am 20.12.2011 19:49, schrieb Göran Weinholt:
> Alexander Graf <agraf@suse.de> writes:
> 
>> Yes, this patch makes things work again :). Thanks a lot!
>>
>> The only thing I could nitpick on would be the coding style - checkpatch.pl complains :). Could you please resend with braces?
>> Justin, Please also queue this for 1.0-stable when it comes in its final form.
>>
>> Tested-by: Alexander Graf <agraf@suse.de>
> 
> Thanks for testing it. Here it is, with braces this time.
> 
> 
> From 2a2df801d68a76fb2210e556652fb2e17e0f6711 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?G=C3=B6ran=20Weinholt?= <goran@weinholt.se>
> Date: Tue, 20 Dec 2011 19:36:10 +0100
> Subject: [PATCH] multiboot: mh_load_end_addr and mh_bss_end_addr may be zero
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
> 
> 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 <goran@weinholt.se>
> Tested-by: Alexander Graf <agraf@suse.de>

This doesn't seem to be applied yet. Can you resend it as a top-level
email instead of deep in some thread where it may be missed?

Kevin

Patch

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);