andreyv / sbupdate

Generate and sign kernel images for UEFI Secure Boot on Arch Linux
GNU General Public License v3.0
225 stars 20 forks source link

vmlinuz-linux-zen no longer fits into allocated section space #32

Closed auriusbendikas closed 2 years ago

auriusbendikas commented 4 years ago

Hi,

I am using Archlinux with ZEN kernel (5.8.8-zen1-1-zen) on 2 of the physical machines and my VirtualBox images at home. I only use sbupdate on my Dell XPS laptop, and for other ones I have build my own UEFI boot image based on sbuupdate code, but without image signing.

And after upgrading to 5.8 release of the kernel all my physical machines started having very different boot problems.

It took me months to figure out the root cause. Looks like the "/boot/vmlinuz-linux-zen" image is not fitting into ".linux" section allocated between "--change-section-vma .linux=0x2000000" and "-change-section-vma .initrd=0x3000000". The image itself is 9458592 (decimal) bytes but for some reason it does not fit into 0x1000000 (assuming this is hexadecimal) bytes allocated.

I am not an expert here what is the right solution, but I have modified a section of the sbupdate that fixed the issue for me:

  objcopy \
    --add-section .osrel="/etc/os-release"                          --change-section-vma .osrel=0x20000    \
    --add-section .cmdline=<(echo -n "${cmdline}")                  --change-section-vma .cmdline=0x30000  \
    --add-section .linux="$2"                                       --change-section-vma .linux=0x40000    \
    --add-section .initrd=<(cat "${INITRD_PREPEND[@]}" "${initrd}") --change-section-vma .initrd=0x2000000 \
    "${EFISTUB}" "${output}"

Note that I am not using ".splash" section, because that gives me a smoothest transition from the Dell logo. Before I was just specifying "/dev/null" as an image and that worked the same.

andreyv commented 3 years ago

Hi,

Sorry to hear that.

If the vmlinuz image would be bigger than 16 MiB, then the issue would be clear. However, as it is around 9 MiB, it should still fit in the allocated region.

From reading systemd EFI stub code, I don't immediately see anything out of place. Comparing the kernel ELF images for linux and linux-zen packages, I don't see many differences; the kernel segment physical and virtual addresses don't differ much.

I could also boot the combined linux-zen 5.9.1.zen2-1 UEFI image normally and in fact am typing this reply from this kernel now.

If you can stil reproduce the problem, you could open an issue at systemd/systemd for the EFI stub component .

auriusbendikas commented 3 years ago

Hi,

Thanks for reply. You are right the image should fit in without any problems. Maybe the solution was the removal of ".splash" section and not the increase of ".linux" image section. Since before I was setting ".splash" section to "/dev/null" and made those two changes at the same time.

Also I started having the issue after upgrading to kernel version 5.8 from 5.7. And have been running without any boot problems for at least a year with the default sbupdate.

But the conclusion is that since I increased ".linux" section and removed the ".splash" section I have never seen the problem coming back.

Maybe we can add an option to make ".splash" section optional?

I will try to see if I will have time to test it this or next month. Am pretty busy lately and need my workstations running stable now :) But I will get back to you on this one.

Thanks for a great job on sbupdate!

andreyv commented 2 years ago

I'm going to close this as not reproducible, since there were no new updates. Please reopen the issue if you encounter it again.

auriusbendikas commented 2 years ago

I forgot about that. It is OK to close. I think I misdiagnosed the issue and it was not caused by the size issue. I suspect it was caused by corrupted EFI partition.

Sorry for incorrect reporting.

andreyv commented 2 years ago

Alright, thanks for responding back.