multiboot: Fix module loading and setting of mmap
PATCH 1/1 multiboot: Fix module loading and setting of mmap
Hi,
I need to following to fix multiboot booting for me.
Should linuxboot.bin and multiboot.bin end up in pc-bios instead of pc-bios/optionrom?
--- hw/pc.c | 4 ++-- pc-bios/optionrom/multiboot.S | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)
hw/pc.c +2 -2
@@ -661,7 +661,7 @@ static int load_multiboot(void *fw_cfg,/* append module data at the end of last module */ mb_kernel_data =qemu_realloc (mb_kernel_data, - mh_load_addr - mb_mod_end); + mb_mod_end - mh_load_addr);load_image (initrd_filename, mb_kernel_data + mb_mod_start - mh_load_addr);
@@ -720,7 +720,7 @@ static int load_multiboot(void *fw_cfg,fw_cfg_add_bytes (fw_cfg,FW_CFG_INITRD_DATA , mb_bootinfo_data,sizeof (bootinfo)); - option_rom[nb_option_roms] ="multiboot.bin" ; + option_rom[nb_option_roms] ="optionrom/multiboot.bin" ; nb_option_roms++;return 1 ;/* yes, we are multiboot */
pc-bios/optionrom/multiboot.S +4 -1
@@ -62,6 +62,9 @@ run_multiboot: add %eax, %ebx movl %ebx, %gs:GS_GDT_DESC + 2 + xor %eax, %eax + mov %eax, %es + /* Read the bootinfo struct into RAM */ read_fw_blob(FW_CFG_INITRD)
@@ -71,7 +74,7 @@ run_multiboot: mov %ax, %fs /* ES = mmap_addr */ - mov %eax, %fs:0x48 + mov %fs:48, %eax shr $4, %eax mov %ax, %es
Signature · 6 lines
1.6.5.2 Adam -- Adam [email protected] Lackorzynski http://os.inf.tu-dresden.de/~adam/
Quoted 19 lines · Adam Lackorzynski
Hi,
I need to following to fix multiboot booting for me.
Should linuxboot.bin and multiboot.bin end up in pc-bios instead of pc-bios/optionrom?
Signed-off-by Adam Lackorzynski <[email protected]>--- hw/pc.c | 4 ++-- pc-bios/optionrom/multiboot.S | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)hw/pc.c +0
-0
hw/pc.c static int load_multiboot(void *fw_cfg, · line 665
Quoted 6 lines
hw/pc.c +1
-1@@ -661,7 +661,7 @@ static int load_multiboot(void *fw_cfg,/* append module data at the end of last module */ mb_kernel_data =qemu_realloc (mb_kernel_data, - mh_load_addr - mb_mod_end); + mb_mod_end - mh_load_addr);
Right. I wonder why it worked for me before?
hw/pc.c static int load_multiboot(void *fw_cfg, · line 724
Quoted 10 lines
hw/pc.c +1
-1load_image (initrd_filename, mb_kernel_data + mb_mod_start - mh_load_addr);@@ -720,7 +720,7 @@ static int load_multiboot(void *fw_cfg,fw_cfg_add_bytes (fw_cfg,FW_CFG_INITRD_DATA , mb_bootinfo_data,sizeof (bootinfo)); - option_rom[nb_option_roms] ="multiboot.bin" ; + option_rom[nb_option_roms] ="optionrom/multiboot.bin" ;
This is wrong. The .bin file should be in pc-bios. It just doesn't get copied over as part of the build process, but instead relies on the committer to make sure the binary is updated on every source change.
Quoted 8 lines
hw/pc.c +0
-0nb_option_roms++;return 1; /* yes, we are multiboot */
pc-bios/optionrom/multiboot.S +0
-0
pc-bios/optionrom/multiboot.S run_multiboot: · line 68
Quoted 7 lines
pc-bios/optionrom/multiboot.S +3
-0@@ -62,6 +62,9 @@ run_multiboot: add %eax, %ebx movl %ebx, %gs:GS_GDT_DESC + 2 + xor %eax, %eax + mov %eax, %es +
Ack. %es could be in any state here.
pc-bios/optionrom/multiboot.S run_multiboot: · line 78
Quoted 10 lines
pc-bios/optionrom/multiboot.S +1
-1/* Read the bootinfo struct into RAM */ read_fw_blob(FW_CFG_INITRD)@@ -71,7 +74,7 @@ run_multiboot: mov %ax, %fs /* ES = mmap_addr */ - mov %eax, %fs:0x48 + mov %fs:48, %eax
Right...
Thanks for catching those!
Alex
Quoted 13 lines · Alexander Graf
Quoted 12 lines · Adam Lackorzynski
I need to following to fix multiboot booting for me.
Should linuxboot.bin and multiboot.bin end up in pc-bios instead of pc-bios/optionrom?
load_image(initrd_filename, mb_kernel_data + mb_mod_start - mh_load_addr);(quoted diff) +0
-0@@ -720,7 +720,7 @@ static int load_multiboot(void *fw_cfg, fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, mb_bootinfo_data, sizeof(bootinfo));
Quoted 7 lines
Review static int load_multiboot(void *fw_cfg, · line 724
Quoted 3 lines
(quoted diff) +1
-1- option_rom[nb_option_roms] = "multiboot.bin"; + option_rom[nb_option_roms] = "optionrom/multiboot.bin";This is wrong. The .bin file should be in pc-bios. It just doesn't get copied over as part of the build process, but instead relies on the committer to make sure the binary is updated on every source change.
Ok, didn't know. Thank you both for clarifying! New patch attached.
--- hw/pc.c | 2 +- pc-bios/multiboot.bin | Bin 512 -> 1024 bytes pc-bios/optionrom/multiboot.S | 5 ++++- 3 files changed, 5 insertions(+), 2 deletions(-)
hw/pc.c +1 -1
@@ -661,7 +661,7 @@ static int load_multiboot(void *fw_cfg,/* append module data at the end of last module */ mb_kernel_data =qemu_realloc (mb_kernel_data, - mh_load_addr - mb_mod_end); + mb_mod_end - mh_load_addr);load_image (initrd_filename, mb_kernel_data + mb_mod_start - mh_load_addr);
pc-bios/multiboot.bin binary +0 -0
pc-bios/optionrom/multiboot.S +4 -1
@@ -62,6 +62,9 @@ run_multiboot: add %eax, %ebx movl %ebx, %gs:GS_GDT_DESC + 2 + xor %eax, %eax + mov %eax, %es + /* Read the bootinfo struct into RAM */ read_fw_blob(FW_CFG_INITRD)
@@ -71,7 +74,7 @@ run_multiboot: mov %ax, %fs /* ES = mmap_addr */ - mov %eax, %fs:0x48 + mov %fs:48, %eax shr $4, %eax mov %ax, %es
Signature · 8 lines
1.6.5.2 Adam -- Adam [email protected] Lackorzynski http://os.inf.tu-dresden.de/~adam/
Alexander Graf
Acked-byQuoted 25 lines · Adam Lackorzynski
Quoted 14 lines · Alexander Graf
Quoted 12 lines · Adam Lackorzynski
I need to following to fix multiboot booting for me.
Should linuxboot.bin and multiboot.bin end up in pc-bios instead of pc-bios/optionrom?
load_image(initrd_filename, mb_kernel_data + mb_mod_start - mh_load_addr);(quoted diff) +0
-0@@ -720,7 +720,7 @@ static int load_multiboot(void *fw_cfg, fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, mb_bootinfo_data, sizeof(bootinfo));Quoted 8 lines
Review static int load_multiboot(void *fw_cfg, · line 725
Quoted 4 lines
(quoted diff) +1
-1- option_rom[nb_option_roms] = "multiboot.bin"; + option_rom[nb_option_roms] = "optionrom/multiboot.bin";This is wrong. The .bin file should be in pc-bios. It just doesn't get copied over as part of the build process, but instead relies on the committer to make sure the binary is updated on every source change.
Quoted 5 lines
Ok, didn't know. Thank you both for clarifying! New patch attached.
Signed-off-by Adam Lackorzynski <[email protected]>
Alex
Quoted 19 lines · Adam Lackorzynski
Hi,
I need to following to fix multiboot booting for me.
Should linuxboot.bin and multiboot.bin end up in pc-bios instead of pc-bios/optionrom?
Signed-off-by Adam Lackorzynski <[email protected]>--- hw/pc.c | 4 ++-- pc-bios/optionrom/multiboot.S | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)hw/pc.c +0
-0
hw/pc.c static int load_multiboot(void *fw_cfg, · line 665
Quoted 6 lines
hw/pc.c +1
-1@@ -661,7 +661,7 @@ static int load_multiboot(void *fw_cfg,/* append module data at the end of last module */ mb_kernel_data =qemu_realloc (mb_kernel_data, - mh_load_addr - mb_mod_end); + mb_mod_end - mh_load_addr);
That bit looks right.
hw/pc.c static int load_multiboot(void *fw_cfg, · line 724
Quoted 10 lines
hw/pc.c +1
-1load_image (initrd_filename, mb_kernel_data + mb_mod_start - mh_load_addr);@@ -720,7 +720,7 @@ static int load_multiboot(void *fw_cfg,fw_cfg_add_bytes (fw_cfg,FW_CFG_INITRD_DATA , mb_bootinfo_data,sizeof (bootinfo)); - option_rom[nb_option_roms] ="multiboot.bin" ; + option_rom[nb_option_roms] ="optionrom/multiboot.bin" ; nb_option_roms++;
This bit doesn't. multiboot.bin gets installed in ${prefix}/share/. There is a blob shipped in pc-bios/ so if you do -L $srcdir/pc-bios it should work. However, if you did -L $objdir/pc-bios where $objdir != $srcdir, it would not work without your patch. The same is true for seabios and the other roms.
Your patch would break the first two though. I'm not sure we have a great solution.
Quoted 17 lines
hw/pc.c +0
-0return 1 ;/* yes, we are multiboot */ pc-bios/optionrom/multiboot.S +3
-0@@ -62,6 +62,9 @@ run_multiboot: add %eax, %ebx movl %ebx, %gs:GS_GDT_DESC + 2 + xor %eax, %eax + mov %eax, %es + /* Read the bootinfo struct into RAM */ read_fw_blob(FW_CFG_INITRD)
pc-bios/optionrom/multiboot.S run_multiboot: · line 80
Quoted 8 lines
pc-bios/optionrom/multiboot.S +1
-1@@ -71,7 +74,7 @@ run_multiboot: mov %ax, %fs /* ES = mmap_addr */ - mov %eax, %fs:0x48 + mov %fs:48, %eax shr $4, %eax mov %ax, %es
This bit needs to be reviewed/acked by Alex.
Regards,
Anthony Liguori