All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 (fwd)
@ 2012-03-18 17:45 Scott Moser
  2012-03-20 15:04 ` Serge E. Hallyn
  2012-03-26 19:17 ` Anthony Liguori
  0 siblings, 2 replies; 6+ messages in thread
From: Scott Moser @ 2012-03-18 17:45 UTC (permalink / raw)
  To: qemu-devel

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 <smoser@ubuntu.com>
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

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 (fwd)
  2012-03-18 17:45 [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 (fwd) Scott Moser
@ 2012-03-20 15:04 ` Serge E. Hallyn
  2012-03-26 19:17 ` Anthony Liguori
  1 sibling, 0 replies; 6+ messages in thread
From: Serge E. Hallyn @ 2012-03-20 15:04 UTC (permalink / raw)
  To: Scott Moser; +Cc: qemu-devel

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 <smoser@ubuntu.com>
> 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 <serge.hallyn@canonical.com>

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 (fwd)
  2012-03-18 17:45 [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 (fwd) Scott Moser
  2012-03-20 15:04 ` Serge E. Hallyn
@ 2012-03-26 19:17 ` Anthony Liguori
  2012-03-26 19:27   ` [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 Scott Moser
  1 sibling, 1 reply; 6+ messages in thread
From: Anthony Liguori @ 2012-03-26 19:17 UTC (permalink / raw)
  To: Scott Moser; +Cc: qemu-devel

On 03/18/2012 12:45 PM, Scott Moser wrote:
> Re-sending to qemu-devel.  I'd originally sent this to kvm mailing list.

Can you submit as a proper patch with a Signed-off-by?

Regards,

Anthony Liguori

>
> ---------- Forwarded message ----------
> Date: Sat, 17 Mar 2012 00:08:06
> From: Scott Moser<smoser@ubuntu.com>
> 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
>
> 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);
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0
  2012-03-26 19:17 ` Anthony Liguori
@ 2012-03-26 19:27   ` Scott Moser
  2012-05-26 22:17     ` Kevin Wolf
  0 siblings, 1 reply; 6+ messages in thread
From: Scott Moser @ 2012-03-26 19:27 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel

The previous multiboot load 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.

Signed-off-by: Scott Moser <smoser@ubuntu.com>

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0
  2012-03-26 19:27   ` [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 Scott Moser
@ 2012-05-26 22:17     ` Kevin Wolf
  2012-05-27  0:52       ` Anthony Liguori
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Wolf @ 2012-05-26 22:17 UTC (permalink / raw)
  To: qemu-devel; +Cc: Scott Moser, Anthony Liguori

Am Montag, 26. März 2012 21:27:00 schrieb Scott Moser:
> The previous multiboot load 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.
>
> Signed-off-by: Scott Moser <smoser@ubuntu.com>
>
> 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);


Anthony, what happened with this patch? Can we still get it into 1.1?

Kevin

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0
  2012-05-26 22:17     ` Kevin Wolf
@ 2012-05-27  0:52       ` Anthony Liguori
  0 siblings, 0 replies; 6+ messages in thread
From: Anthony Liguori @ 2012-05-27  0:52 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Scott Moser, qemu-devel

On 05/26/2012 05:17 PM, Kevin Wolf wrote:
> Am Montag, 26. März 2012 21:27:00 schrieb Scott Moser:
>> The previous multiboot load 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.
>>
>> Signed-off-by: Scott Moser<smoser@ubuntu.com>
>>
>> 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);
>
>
> Anthony, what happened with this patch?

It wasn't top posted so it got lost.

> Can we still get it into 1.1?

Yeah, I'll queue it.

Regards,

Anthony Liguori

>
> Kevin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-05-27  0:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-18 17:45 [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 (fwd) Scott Moser
2012-03-20 15:04 ` Serge E. Hallyn
2012-03-26 19:17 ` Anthony Liguori
2012-03-26 19:27   ` [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0 Scott Moser
2012-05-26 22:17     ` Kevin Wolf
2012-05-27  0:52       ` Anthony Liguori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.