FS#53182 - Support for booting the 64-bit official installation image on 32-bit UEFI (i386-efi) only systems.

Attached to Project: Release Engineering
Opened by Mortan (Mortan1961) - Monday, 06 March 2017, 17:40 GMT
Last edited by Gerardo Exequiel Pozzi (djgera) - Saturday, 23 June 2018, 22:52 GMT
Task Type Feature Request
Category ArchISO
Status Closed
Assigned To Gerardo Exequiel Pozzi (djgera)
Architecture x86_64
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

To preface: This report has nothing to do with the now deprecated i686 architecture.

Some background: A core concept of the UEFI Specification is that the OS and firmware architecture need to match. For most non-Intel processors, this isn’t a big deal since they only have one architecture. The x86 compatible processor is a bit different, and can switch into various 16/32/64 bit modes for application compatibility. Because most Intel platforms support both 32-bit & 64-bit architecture, along with old school Intel 8086/80286 16-bit instructions, the UEFI firmware on these platforms can be compiled in IA32 or x64 mode.

As tablets and cheaper laptops came into the market, more manufacturers started to ship Microsoft Windows 32-bit version. A 64-bit OS does theoretically perform better than a 32-bit OS, but those performance gains are tied to larger amounts of memory (over 4GB). The 64-bit version of Windows takes up more disk space, thanks to larger binaries and any underlying 64/32-bit translation layers. This means your Black Friday special purchase with 2GB of RAM and 16-32GB of internal flash storage doesn't see any 64-bit architecture benefits.

For Intel, it was easy to support, just recompile the UEFI C-code in IA32 mode instead of x64.

That means that 32-bit UEFI systems can't execute 64-bit code in firmware, even if the CPU is capable of it. A 64-bit OS can only boot on 32-bit UEFI if it has very ugly compatibility hacks, including having to rewrite structures and register state every time it makes a UEFI call.

The Linux kernel since version 3.15 has support for this mixed EFI mode, however it is necessary for operating systems to ship boot loaders for x86_64-efi and i386-efi targets in addition to i386-pc for BIOS systems.

The current state of affairs: Arch ships Linux with CONFIG_EFI_MIXED=y by default and it is therefore possible to enable i386-efi booting from an existing installation, but the official installation image only can boot from x86_64-efi and i386-pc.

The official installation image will not even show up on the boot list on these i386-efi systems and because they do not support i386-pc it is impossible boot the installation image on these systems even though they are perfectly capable of running Arch.

What needs to be done: An i386-efi bootloader that supports the EFI handover protocol (no EFI boot stub) must be installed to '/EFI/boot/bootia32.efi' on the official installation image.

I am unsure on how the official installation image is built and what boot loaders it currently uses, but on an existing installation I was able to boot from one of these i386-efi only computers with:
pacman -S --needed dosfstools efibootmgr grub intel-ucode
grub-install --target=i386-efi --efi-directory=/boot --removable
grub-mkconfig -o /boot/grub/grub.cfg

So a starting point for booting from everything with official installation image's file system layout might be:
pacman -S --needed dosfstools efibootmgr grub intel-ucode
grub-install --target=x86_64-efi --efi-directory=/ --removable
grub-install --target=i386-efi --efi-directory=/ --removable
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /grub/grub.cfg

It would also help to update the Installation Guide to inform people on how to support booting installations from everything.

Many other operating systems, like Debian, have supported booting from these i386-efi only systems for a while now in their standard stable official installation images.

I really hope that this simple fix can be applied to address this critical issue so a that large class of devices can support installing Arch.

If necessary, I can test installation images on real i386-efi only hardware to ensure that they work.

Thanks for your consideration and work.
This task depends upon

Closed by  Gerardo Exequiel Pozzi (djgera)
Saturday, 23 June 2018, 22:52 GMT
Reason for closing:  Won't implement
Comment by Gerardo Exequiel Pozzi (djgera) - Tuesday, 07 March 2017, 00:18 GMT
critical? I closed these kind of request before, for these ugly systems. Maybe can be considered this time, only if:

* syslinux works. I do not like at all grub, too much complex.
* adding more boot methods does not break systems that currently works.

At the end we have, syslinux (bios), systemd-boot (efi-64), syslinux (efi-32)...

PS: x86-32 is ugly beyond 1GiB of physical memory, not 4GiB. Virtual address space should be >>> than physical address space.
Comment by Gerardo Exequiel Pozzi (djgera) - Tuesday, 07 March 2017, 03:55 GMT
Here is the patch, please test on real hardware, thanks.

Only tested on qemu with ovmf with bad results:
in cd-rom, qemu just crash, in "hybrid", freeze.
Comment by Mortan (Mortan1961) - Tuesday, 07 March 2017, 19:07 GMT
I built an image with:
sudo pacman -S archiso
cp -r /usr/share/archiso/configs configs
curl -JLO https://bugs.archlinux.org/task/53182?getfile=15068
git apply 0001-configs-releng-Add-32-bit-EFI-support.patch
sudo ./configs/releng/build.sh -v

On real hardware it did show up in the UEFI boot menu and did boot a syslinux boot menu, however upon selecting the only option "Boot Arch Linux (x86_64)" it failed with "Loading /EFI/archiso/vmlinuz... failed: No such file or directory"


Also, sorry for incorrectly marking it as critical. The wiki at https://wiki.archlinux.org/index.php/Reporting_bug_guidelines#Severity says "Critical - ...severe boot failure that is likely to affect more than just you..." so I thought it applied.
Comment by Gerardo Exequiel Pozzi (djgera) - Tuesday, 07 March 2017, 22:09 GMT
Many thanks for test!

Ok, I made a mistake, vmlinuz in efiboot.img for "el torito" (cdrom) is called vmlinuz.efi. So if you edit the cmdline (e key), will work.

I you can also test usb (hybrid) mode will be great.

New patch attached.
Comment by Gerardo Exequiel Pozzi (djgera) - Tuesday, 07 March 2017, 23:32 GMT
Now I build a new ovmf (1:r21286.7babb4372e-1), in cdrom mode, yields a internal error (if -enable-kvm) or a stop error "Trying to execute code outside RAM or ROM at 0x00000000000b0000" without -enable-kvm before reaching syslinux. In hybrid mode, syslinux works but after loading kernel+initrd, just reboot.
Comment by Mortan (Mortan1961) - Tuesday, 07 March 2017, 23:45 GMT
Built new image with:
cp -r /usr/share/archiso/configs .
curl -JLO https://bugs.archlinux.org/task/53182?getfile=15071
git apply 0001-configs-releng-Add-32-bit-EFI-support.patch
sudo ./configs/releng/build.sh -v

Booting it prints:
Loading /EFI/archiso/vmlinuz.efi... ok
Loading /EFI/archiso/intel_ucode.img...ok
Loading /EFI/archiso/archiso.img...ok

Then it does nothing.

To clarify, I have only tried booting these images from a USB flash drive.
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 08 March 2017, 00:20 GMT
Interesting, then I guess this is an issue with syslinux in this efi32-to-x86_64 mode. syslinux works fine booting efi64-to-x86_64 (many real hardware I use, and on qemu+ovmf)

PS: I will try to test using syslinux build from git.
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 08 March 2017, 01:42 GMT
Nop, same thing happens with 6.04-pre1. Loading only vmlinuz has the same issue.
Comment by Mortan (Mortan1961) - Wednesday, 08 March 2017, 17:29 GMT
According to https://lwn.net/Articles/589193/ Syslinux should work.
Comment by Gerardo Exequiel Pozzi (djgera) - Wednesday, 08 March 2017, 22:32 GMT
Sure, but it does not. Should be reported to upstream to fix.
Comment by Gerardo Exequiel Pozzi (djgera) - Thursday, 09 March 2017, 23:26 GMT
Linux 4.4.52 boots fine.
Comment by Gerardo Exequiel Pozzi (djgera) - Friday, 10 March 2017, 02:06 GMT
I made a upstream report here: https://bugzilla.syslinux.org/show_bug.cgi?id=75 please follow to see if info of real hardware is needed. Thanks.
Comment by Tom Yan (tom.ty89) - Tuesday, 04 April 2017, 07:58 GMT
Actually you can boot Arch ISO with the decent loop_mnt hook in any case. Suppose /dev/sdXY is a vfat-formatted partition:

mount /dev/sdXY /mnt
grub-install --target i386-efi --efi-directory /mnt --boot-directory /mnt --removable

You can even run grub-install again appropriately with other targets to make the drive bootable on 64-bit UEFI and BIOS.

Then put the arch iso image file under /mnt and write a grub.cfg to /mnt/grub manually. See the attached one for reference.

This way you can even use the remaining space of the drive.

The hook/method is documented here: https://git.archlinux.org/archiso.git/tree/docs
   grub.cfg (0.3 KiB)

Loading...