On 18/12/2023 at 08:55, Andrei Borzenkov wrote:

You can also probably load a 32 bit kernel from a 64 bit grub.

Why would you would want to do this ? A 32-bit kernel cannot read or write 64-bit EFI variables.

We are back to the same question - what are criteria for
choosing the "right" kernel that grub needs to implement?
(...)
Besides, distributions may require additional CPU features beyond mere
"supports 64 bit".

Do you mean 32-bit CPU features such as PAE ?

https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels

Debian provides only a single kernel flavour for the amd64 architecture, and two flavours for i386: 686 (without PAE) and 686-pae. So this script should do the trick:

if [ $grub_cpu = x86_64 ]; then
        set arch=amd64
elif [ $grub_cpu = i386 ]; then
        if cpuid -l ; then
                set arch=amd64
        elif cpuid -p ; then
                set arch=686-pae
        else
                set arch=686
        fi
elif [ $grub_cpu = arm64 ]; then
        set arch=arm64
elif [ $grub_cpu = riscv64 ]; then
        set arch=riscv64
fi

Reply via email to