[PATCH] Revert 9696846600ca ("multiboot: Prevent loading of x86_64 images")

Samuel Thibault posted 1 patch 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260829175047.2710519-1-samuel.thibault@ens-lyon.org
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>
hw/i386/multiboot.c | 5 -----
1 file changed, 5 deletions(-)
[PATCH] Revert 9696846600ca ("multiboot: Prevent loading of x86_64 images")
Posted by Samuel Thibault 4 weeks ago
Loading x86_64 images in multiboot was disabled on the ground that since
multiboot actually boots 64bit kernels in 32bit mode, the binary would
have to be 32bit.

https://lists.gnu.org/archive/html/qemu-devel/2010-08/msg00913.html

But making the binary 32bit makes using debugging tools such as gdb
unnecessarily complex since they don't understand what architecture the
kernel actually is.  Letting qemu load x86_64 images and boot them in 32bit
mode is completely fine, works, and is what the multiboot standard actually
expects.

This notably fixes loading gnumach in x86_64 mode.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 hw/i386/multiboot.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
index d544b62afb..004d5185fb 100644
--- a/hw/i386/multiboot.c
+++ b/hw/i386/multiboot.c
@@ -196,11 +196,6 @@ int load_multiboot(X86MachineState *x86ms,
         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,
                                ELFDATA2LSB, I386_ELF_MACHINE, 0, 0);
-- 
2.53.0
Re: [PATCH] Revert 9696846600ca ("multiboot: Prevent loading of x86_64 images")
Posted by Samuel Thibault 2 weeks, 5 days ago
Hello,

Ping on this?

With regards,
Samuel

Samuel Thibault, le sam. 29 août 2026 19:50:47 +0200, a ecrit:
> Loading x86_64 images in multiboot was disabled on the ground that since
> multiboot actually boots 64bit kernels in 32bit mode, the binary would
> have to be 32bit.
> 
> https://lists.gnu.org/archive/html/qemu-devel/2010-08/msg00913.html
> 
> But making the binary 32bit makes using debugging tools such as gdb
> unnecessarily complex since they don't understand what architecture the
> kernel actually is.  Letting qemu load x86_64 images and boot them in 32bit
> mode is completely fine, works, and is what the multiboot standard actually
> expects.
> 
> This notably fixes loading gnumach in x86_64 mode.
> 
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> ---
>  hw/i386/multiboot.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
> index d544b62afb..004d5185fb 100644
> --- a/hw/i386/multiboot.c
> +++ b/hw/i386/multiboot.c
> @@ -196,11 +196,6 @@ int load_multiboot(X86MachineState *x86ms,
>          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,
>                                 ELFDATA2LSB, I386_ELF_MACHINE, 0, 0);
> -- 
> 2.53.0

Re: [PATCH] Revert 9696846600ca ("multiboot: Prevent loading of x86_64 images")
Posted by Samuel Thibault 1 week, 5 days ago
Hello,

Any opinion on this?

With regards,
Samuel

Samuel Thibault, le lun. 07 sept. 2026 13:41:11 +0200, a ecrit:
> Hello,
> 
> Ping on this?
> 
> With regards,
> Samuel
> 
> Samuel Thibault, le sam. 29 août 2026 19:50:47 +0200, a ecrit:
> > Loading x86_64 images in multiboot was disabled on the ground that since
> > multiboot actually boots 64bit kernels in 32bit mode, the binary would
> > have to be 32bit.
> > 
> > https://lists.gnu.org/archive/html/qemu-devel/2010-08/msg00913.html
> > 
> > But making the binary 32bit makes using debugging tools such as gdb
> > unnecessarily complex since they don't understand what architecture the
> > kernel actually is.  Letting qemu load x86_64 images and boot them in 32bit
> > mode is completely fine, works, and is what the multiboot standard actually
> > expects.
> > 
> > This notably fixes loading gnumach in x86_64 mode.
> > 
> > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > ---
> >  hw/i386/multiboot.c | 5 -----
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
> > index d544b62afb..004d5185fb 100644
> > --- a/hw/i386/multiboot.c
> > +++ b/hw/i386/multiboot.c
> > @@ -196,11 +196,6 @@ int load_multiboot(X86MachineState *x86ms,
> >          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,
> >                                 ELFDATA2LSB, I386_ELF_MACHINE, 0, 0);
> > -- 
> > 2.53.0

-- 
Samuel
Linux, c'est simple : ça s'adresse à une machine qui est parfois un peu
maraboutée mais qui d'habitude n'a pas d'états d'âme. Sur Usenet y'a
plein d'humains et de primates, et ça devient vraiment gore par moment.
-+- TP in : Guide du linuxien pervers - "Le linuxien a-t-il une âme ?" -+-

Re: [PATCH] Revert 9696846600ca ("multiboot: Prevent loading of x86_64 images")
Posted by Samuel Thibault 1 week ago
Hello,

I am still waiting for feedback on this.

With regards,
Samuel

Samuel Thibault, le lun. 14 sept. 2026 01:25:30 +0200, a ecrit:
> Hello,
> 
> Any opinion on this?
> 
> With regards,
> Samuel
> 
> Samuel Thibault, le lun. 07 sept. 2026 13:41:11 +0200, a ecrit:
> > Hello,
> > 
> > Ping on this?
> > 
> > With regards,
> > Samuel
> > 
> > Samuel Thibault, le sam. 29 août 2026 19:50:47 +0200, a ecrit:
> > > Loading x86_64 images in multiboot was disabled on the ground that since
> > > multiboot actually boots 64bit kernels in 32bit mode, the binary would
> > > have to be 32bit.
> > > 
> > > https://lists.gnu.org/archive/html/qemu-devel/2010-08/msg00913.html
> > > 
> > > But making the binary 32bit makes using debugging tools such as gdb
> > > unnecessarily complex since they don't understand what architecture the
> > > kernel actually is.  Letting qemu load x86_64 images and boot them in 32bit
> > > mode is completely fine, works, and is what the multiboot standard actually
> > > expects.
> > > 
> > > This notably fixes loading gnumach in x86_64 mode.
> > > 
> > > Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
> > > ---
> > >  hw/i386/multiboot.c | 5 -----
> > >  1 file changed, 5 deletions(-)
> > > 
> > > diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
> > > index d544b62afb..004d5185fb 100644
> > > --- a/hw/i386/multiboot.c
> > > +++ b/hw/i386/multiboot.c
> > > @@ -196,11 +196,6 @@ int load_multiboot(X86MachineState *x86ms,
> > >          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,
> > >                                 ELFDATA2LSB, I386_ELF_MACHINE, 0, 0);
> > > -- 
> > > 2.53.0