Skip to content
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

edk2: add custom patch for bootorder support in CSM mode #194

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

mihalicyn
Copy link
Member

@mihalicyn mihalicyn commented Nov 15, 2023

From ("edk2: force CSM boot mode for bootorder") description: 
========
If "-fw_cfg name=opt/com.canonical.lxd/force_csm,string=yes" is specified in the Qemu commandline then treat bootorder settings from Qemu as settings for CSM boot. Right now bootorder from Qemu is always considered as UEFI and CSM boot is always last in the priority list. Even worser, you can't really make CSM to be the first in the bootorder, because in the SetBootOrderFromQemu() function we always fixup bootorder in accordance with Qemu provided and setting from NVRAM are always got reset.

Fortunately, we don't need to patch SeaBIOS, because it already handles bootorder from Qemu properly. So, we just need to pass execution from UEFI to SeaBIOS and from this point everything will work just fine.

This is a very hacky solution but we have no choice here. Because the alternative here is to extend Qemu fwcfg "bootorder" interface to make it aware of CSM/UEFI boot modes and then patch UEFI and SeaBIOS to handle all of that. This can be an ready-to-upstream solution, but I'm not sure that it can be interesting for edk2 folks, because all of this CSM stuff considered as a legacy thing.

This thing is enabled only when CSM_ENABLE=TRUE AND "-fw_cfg name=opt/com.canonical.lxd/force_csm,string=yes" specified in the Qemu cmdline.
========

Fixes canonical/lxd#11908
Related to canonical/lxd#12564

@mihalicyn
Copy link
Member Author

Let's wait until:
canonical/lxd#12522
canonical/lxd#12515
will be merged

Copy link
Member

@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the extent I could review. There are a few minor English mistakes in the patch description which is probably fine as this won't be upstream'ed.

patches/edk2-0007-force-CSM-boot-mode-for-bootorder.patch Outdated Show resolved Hide resolved
From ("edk2: force CSM boot mode for bootorder") description:
========
If "-fw_cfg name=opt/com.canonical.lxd/force_csm,string=yes" is specified
in the Qemu commandline then treat bootorder settings from Qemu
as settings for CSM boot. Right now bootorder from Qemu is always considered
as UEFI and CSM boot is always last in the priority list. Even worser,
you can't really make CSM to be the first in the bootorder, because in the
SetBootOrderFromQemu() function we always fixup bootorder in accordance with
Qemu provided and setting from NVRAM are always got reset.

Fortunately, we don't need to patch SeaBIOS, because it already handles
bootorder from Qemu properly. So, we just need to pass execution from
UEFI to SeaBIOS and from this point everything will work just fine.

This is a very hacky solution but we have no choice here. Because
the alternative here is to extend Qemu fwcfg "bootorder" interface
to make it aware of CSM/UEFI boot modes and then patch UEFI and SeaBIOS
to handle all of that. This can be an ready-to-upstream solution,
but I'm not sure that it can be interesting for edk2 folks, because
all of this CSM stuff considered as a legacy thing.

This thing is enabled only when CSM_ENABLE=TRUE AND
"-fw_cfg name=opt/com.canonical.lxd/force_csm,string=yes"
specified in the Qemu cmdline.
========

Signed-off-by: Alexander Mikhalitsyn <[email protected]>
@mihalicyn mihalicyn marked this pull request as ready for review November 28, 2023 09:50
Copy link
Member

@tomponline tomponline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@tomponline tomponline merged commit 8499e23 into canonical:latest-edge Nov 28, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't programmatically boot into CSM legacy disk
3 participants