Skip to contentSkip to conversation

fix multiboot loading if load_end_addr == 0 (fwd)

PATCH In review Scott Moser 4 participants 6 messages Mar 18, 2012 – May 27, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix multiboot loading if load_end_addr == 0 (fwd)

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 <[email protected]>
To: [email protected]
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

hw/multiboot.c +9 -3
index b4484a3..b1e04c5 100644
@@ -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);
Tested-by Serge Hallyn on v1 1/1
#1 lore raw
Quoted 19 lines · Scott Moser

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 <[email protected]>
To: [email protected]
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.

Quoted 3 lines

This was raised initially as launchpad bug
https://bugs.launchpad.net/qemu/+bug/957622

Quoted 24 lines
hw/multiboot.c +9 -3
index b4484a3..b1e04c5 100644
@@ -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);
#2 lore raw
In reply to Scott Moser
Quoted 1 line · Scott Moser

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

Quoted 46 lines

---------- Forwarded message ----------
Date: Sat, 17 Mar 2012 00:08:06
From: Scott Moser<[email protected]>
To: [email protected]
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

hw/multiboot.c +9 -3
index b4484a3..b1e04c5 100644
@@ -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);
#3 lore raw

PATCH 1/1 fix multiboot loading if load_end_addr == 0

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.

hw/multiboot.c +9 -3
index b4484a3..b1e04c5 100644
@@ -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);
#4 lore raw

Re: [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0

Am Montag, 26. März 2012 21:27:00 schrieb Scott Moser:

Quoted 28 lines

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.

hw/multiboot.c +0 -0
index b4484a3..b1e04c5 100644
@@ -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;

hw/multiboot.c +2 -2
-
+        uint32_t mb_load_size = 0;
         mh_entry_addr = ldl_p(header+i+28);
-        mb_kernel_size = mh_bss_end_addr - mh_load_addr;
+

hw/multiboot.c int load_multiboot(void *fw_cfg, · line 217

Quoted 10 lines
hw/multiboot.c +7 -0
+        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

#5 lore raw

Re: [Qemu-devel] [PATCH] fix multiboot loading if load_end_addr == 0

Quoted 37 lines · Kevin Wolf

Am Montag, 26. März 2012 21:27:00 schrieb Scott Moser:

Quoted 36 lines

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.

hw/multiboot.c +0 -0
index b4484a3..b1e04c5 100644
@@ -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;

hw/multiboot.c +9 -2
-
+        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;
+        }
Quoted 5 lines
Quoted 2 lines
          /* 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.

Quoted 1 line

Can we still get it into 1.1?

Yeah, I'll queue it.

Regards,

Anthony Liguori

Quoted 2 lines

Kevin