-
Notifications
You must be signed in to change notification settings - Fork 156
Efi arm64 loader fixes #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: fedora-44
Are you sure you want to change the base?
Conversation
This fully reverts commit ae0fba3. This will break RISC-V builds, but further reverts in this series will completely remove the troublesome parse_pe_header() function. Note the modifed code is not used on x86 (#ifdef !x86). This is part of a series of reverts to move non x86 vmlinuz loading back to using EFI boot services load_image + start_image calls. The current DYI approach breaks booting kernel EFI binaries which have the stubble stub for automatic DTB loading. Switching back to EFI boot services load_image + start_image fixes this and also brings Fedora's grub inline with how upstream grub is loading and booting kernels on arm64 platforms. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
…NX is required." This fully reverts commit b899582. Note this is actually a no-op since the modified linux_cmd() x86-only code is not used on x86 at all, instead x86 uses the linux_cmd() function from grub-core/loader/i386/efi/linux.c . This is part of a series of reverts to move non x86 vmlinuz loading back to using EFI boot services load_image + start_image calls. The current DYI approach breaks booting kernel EFI binaries which have the stubble stub for automatic DTB loading. Switching back to EFI boot services load_image + start_image fixes this and also brings Fedora's grub inline with how upstream grub is loading and booting kernels on arm64 platforms. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
This reverts a small part of commit be61be0. The only reverted bits are the changes to grub_cmd_linux() these changes call grub_efi_check_nx_image_support() and store the result into a local variable, which is then never used. So reverting these changes is a no-op as the removed code only reads a flag which is never used. Also note that this version of grub_cmd_linux() is never used on x86, which uses linux_cmd() from grub-core/loader/i386/efi/linux.c . This is part of a series of reverts to move non x86 vmlinuz loading back to using EFI boot services load_image + start_image calls. This partial revert is done to make further reverts in this series cleaner. The current DYI approach breaks booting kernel EFI binaries which have the stubble stub for automatic DTB loading. Switching back to EFI boot services load_image + start_image fixes this and also brings Fedora's grub inline with how upstream grub is loading and booting kernels on arm64 platforms. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
This fully reverts commit 9728e07. Note that the modifed version of grub_cmd_linux() is never used on x86, which uses linux_cmd() from grub-core/loader/i386/efi/linux.c . This is part of a series of reverts to move non x86 vmlinuz loading back to using EFI boot services load_image + start_image calls. The current DYI approach breaks booting kernel EFI binaries which have the stubble stub for automatic DTB loading. Switching back to EFI boot services load_image + start_image fixes this and also brings Fedora's grub inline with how upstream grub is loading and booting kernels on arm64 platforms. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
This fully reverts commit ba84a3e. Note the modifed code is not used on x86 (#ifdef !x86). This is part of a series of reverts to move non x86 vmlinuz loading back to using EFI boot services load_image + start_image calls. The current DYI approach breaks booting kernel EFI binaries which have the stubble stub for automatic DTB loading. Switching back to EFI boot services load_image + start_image fixes this and also brings Fedora's grub inline with how upstream grub is loading and booting kernels on arm64 platforms. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
This fully reverts commit 81dbbbc. Note the modifed code is not used on x86 (#ifdef !x86). This is part of a series of reverts to move non x86 vmlinuz loading back to using EFI boot services load_image + start_image calls. The current DYI approach breaks booting kernel EFI binaries which have the stubble stub for automatic DTB loading. Switching back to EFI boot services load_image + start_image fixes this and also brings Fedora's grub inline with how upstream grub is loading and booting kernels on arm64 platforms. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
This fully reverts commit 3cfd4a1. Note the modifed code is not used on x86 (#ifdef !x86). This is part of a series of reverts to move non x86 vmlinuz loading back to using EFI boot services load_image + start_image calls. The current DYI approach breaks booting kernel EFI binaries which have the stubble stub for automatic DTB loading. Switching back to EFI boot services load_image + start_image fixes this and also brings Fedora's grub inline with how upstream grub is loading and booting kernels on arm64 platforms. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
This fully reverts commit fa8f199. Note that the modifed version of grub_cmd_linux() is never used on x86, which uses linux_cmd() from grub-core/loader/i386/efi/linux.c . This concludes the series of reverts to move non x86 vmlinuz loading back to using EFI boot services load_image + start_image calls. The current DYI approach breaks booting kernel EFI binaries which have the stubble stub for automatic DTB loading. Switching back to EFI boot services load_image + start_image fixes this and also brings Fedora's grub inline with how upstream grub is loading and booting kernels on arm64 platforms. This also fixes 2 issues with the xen_hypervisor and xen_module commands: 1) With the now reverted move of setting loaded_image->load_options in finalize_params() the commandline would no longer be set for the xen case. 2) The handover_offset variable passed by grub_efi_linux_boot is a global variable set by the linux cmd and this would either be 0 or the value from the last run linux cmd, neither of which is likely correct for the xen case. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Fix grub_arch_efi_linux_boot_image () leaking the memory allocated for mempath by freeing it after use. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
Fix grub_arch_efi_linux_boot_image () not unloading the loaded image when allocating memory for the commandline fails. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
When building grub for x86_64-efi or i386-efi then loader/i386/efi/linux.c already registers "linux" and "initrd" commands and those will be used instead of those defined in the generic loader/efi/linux.c code. Disable (#ifdef out) the unused code in loader/efi/linux.c when building for x86. This also avoids registering the linux and initrd commands twice. Signed-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>
|
If it is deemed desirable to keep doing our own PE binary loading + jumping to the entry point then I suggest using the new upstream mechanism to hook the load- and start-image boot services calls, which is already (partly) backported on the fedora-44 branch, combined with this patch: This provides a much cleaner (and easier to rebase) to do our own PE binary loading + starting vs the current broken code. For now this can be used on just aarch64, but on the next rebase (once 2.14) is out I would suggest to also switch to this code for i386/x86_64 which would greatly reduce the delta vs upstream and if both Ubuntu and Fedora are using this it would seem reasonable to try and upstream this. Let me know if you want to go the route of using the mechanism to hook the load- and start-image boot services calls together with Ubuntu's peimage module patch which uses these hooks, then I'll update this pull-request to include these patches. |
|
I think you should go ahead and do this with the new upstream mechanism. |
|
Also, FYI, I think this branch is out of date compared to what's in Dist-Git: https://src.fedoraproject.org/rpms/grub2/blob/rawhide/f/grub.patches |
Now this branch should be sync |
|
@jwrdegoede thanks for your patches. Let us revisit them ASAP. |
|
Thank you for fixing the fedora-44 branch being out of sync. @lsandov1 I'm not sure what you mean with "Let us revisit them ASAP"? Do you mean that you're going to take a look when you have some time ? Or do you want me to rebase, finish the backport of the load-image + start-image hooks and add the peimage patch from Ubuntu which adds a cleaner version of the code to manually load the PE binary and jump to its entry point (vs relying on the UEFI firmware to do this) ? Or maybe both? |
The Fedora 44 change to make aarch64 live isos just work on Windows on Arm laptops:
https://fedoraproject.org/wiki/Changes/Automatic_DTB_selection_for_aarch64_EFI_systems
This uses the auto DTB selection build into the systemd-stub. The modified kernel image is in essence an incomplete UKI containing just a UKI boot-stub and the DTBs, but not an initrd nor a kernel commandline. The host generated initrd and host specific commandline will still be supplied by GRUB as usual, including allowing the user to make changes to the commandline through GRUB.
Currently the rhboot/fedora-44 branch from which Fedora 44's GRUB is build fails to boot the UKI-light kernel images used for this changed.
This is caused by a set of Fedora downstream GRUB changes which replace calling EFI boot services load_image + start_image with code to manually load the PE binary and jump to the entry point.
This pull-requests consists of 8 (partial) reverts, reverting to the grub mainline code for starting EFI PE binaries on aarch64. Note the code changes only influence aarch64, which is why some of the reverts are partial since some of the code is also used on i386/x86_64 builds.
I've put a notice in the commit message which commits are full reverts so that the origin commit + the revert can simply be dropped on the next rebase.
On top of this reverts there are 2 bugfixes and a commit disabling most of the generic grub-core/loader/efi/linux.c code on i386/x86_64 since that is unused on i386/x86_64.