QEMU 64 bit multiboot image
Posted: Tue Mar 23, 2021 8:33 am
By default QEMU internal loader (`-kernel` option) can't load multiboot images from 64 bit ELF files. On the other hand GRUB does it perfectly fine. I wonder if there is any reason for this. `-kernel` option makes kernel debugging much easier, because there is no need to rebuild or modify whole disk image every time.
IMO, this limitation serves no purpose at all. I've removed the check from QEMU source and I am using it for over a month now. Nothing seems to be broken by my modification. I wanted to contribute my change to main QEMU repository but their contribution procedure is way too much hassle for an outsider. If anyone here is involved in QEMU project, feel free to forward my patch to the main project repo.
IMO, this limitation serves no purpose at all. I've removed the check from QEMU source and I am using it for over a month now. Nothing seems to be broken by my modification. I wanted to contribute my change to main QEMU repository but their contribution procedure is way too much hassle for an outsider. If anyone here is involved in QEMU project, feel free to forward my patch to the main project repo.
Code: Select all
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
index 9e7d69d470..e8d337744b 100644
--- a/hw/i386/multiboot.c
+++ b/hw/i386/multiboot.c
@@ -193,14 +193,10 @@ int load_multiboot(FWCfgState *fw_cfg,
int kernel_size;
fclose(f);
- if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) {
- error_report("Cannot load x86-64 image, give a 32bit one.");
- exit(1);
- }
-
kernel_size = load_elf(kernel_filename, NULL, NULL, NULL, &elf_entry,
&elf_low, &elf_high, NULL, 0, I386_ELF_MACHINE,
0, 0);
+
if (kernel_size < 0) {
error_report("Error while loading elf kernel");
exit(1);