efi: stub: override RT_PROP table supported mask based on EFI variable
Subsystems (2)
Ard Biesheuvel
maintainerPATCH 1/1 efi: stub: override RT_PROP table supported mask based on EFI variable
Allow EFI systems to override the set of supported runtime services declared via the RT_PROP table, by checking for the existence of a 'OverrideSupported' EFI variable of the appropriate size under the RT_PROP table GUID, and if it does, combine the supported mask using logical AND. (This means the override can only remove support, not add it back).
--- drivers/firmware/efi/libstub/efi-stub.c | 37 ++++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/firmware/efi/libstub/efi-stub.c +37 -0
@@ -96,6 +96,41 @@ static void install_memreserve_table(void)efi_err ("Failed to install memreserve config table!\n" ); } +static void check_rt_properties_table_override (void ) +{ +static const efi_guid_t rt_prop_guid =EFI_RT_PROPERTIES_TABLE_GUID ; +efi_rt_properties_table_t *table; +unsigned long size =sizeof (u32); +efi_status_t status; +u32 override; + + status =get_efi_var (L"OverrideSupported" , &rt_prop_guid,NULL , &size, &override); +if (status !=EFI_SUCCESS || size !=sizeof (override)) +return ; + + table =get_efi_config_table (rt_prop_guid); +if (!table) { +/* no table exists yet - allocate a new one */ + status =efi_bs_call (allocate_pool,EFI_RUNTIME_SERVICES_DATA , +sizeof (*table), (void **)&table); +if (status !=EFI_SUCCESS ) +return ; + table->version =EFI_RT_PROPERTIES_TABLE_VERSION ; + table->length =sizeof (*table); + table->runtime_services_supported =EFI_RT_SUPPORTED_ALL ; + + status =efi_bs_call (install_configuration_table, + (efi_guid_t *)&rt_prop_guid, table); +if (status !=EFI_SUCCESS ) { +efi_warn ("Failed to install RT_PROP override table\n" ); +return ; + } + } + +efi_info ("Applying RT_PROP table override from EFI variable\n" ); + table->runtime_services_supported &= override; +} +static u32 get_supported_rt_services (void ) {const efi_rt_properties_table_t *rt_prop_table;
@@ -210,6 +245,8 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, secure_boot =efi_get_secureboot (); +check_rt_properties_table_override (); +/* * Unauthenticated device tree data is a security hazard, so ignore * 'dtb=' unless UEFI Secure Boot is disabled. We assume that secure
Signature · 1 line
2.30.1
Quoted 7 lines · Ard Biesheuvel
Allow EFI systems to override the set of supported runtime services declared via the
RT_PROPtable, by checking for the existence of a 'OverrideSupported' EFI variable of the appropriate size under theRT_PROPtable GUID, and if it does, combine the supported mask using logical AND. (This means the override can only remove support, not add it back).
Quoted 8 lines
Cc Jeffrey Hugo <[email protected]>,Cc Bjorn Andersson <[email protected]>Cc Shawn Guo <[email protected]>Cc Rob Clark <[email protected]>Cc Leif Lindholm <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>
Awesome, Ard! On both Lenovo Yoga C630 and Flex 5G latops:
With 'OverrideSupported' EFI variable added from UEFI Shell, we can drop 'efi=novamap' kernel cmdline and get around the broken poweroff runtime services nicely. Thanks!
Shawn
Ard Biesheuvel
maintainerQuoted 18 lines · Shawn Guo
Quoted 7 lines · Ard Biesheuvel
Allow EFI systems to override the set of supported runtime services declared via the
RT_PROPtable, by checking for the existence of a 'OverrideSupported' EFI variable of the appropriate size under theRT_PROPtable GUID, and if it does, combine the supported mask using logical AND. (This means the override can only remove support, not add it back).Quoted 8 lines
Cc Jeffrey Hugo <[email protected]>,Cc Bjorn Andersson <[email protected]>Cc Shawn Guo <[email protected]>Cc Rob Clark <[email protected]>Cc Leif Lindholm <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>
Quoted 8 lines
Awesome, Ard! On both Lenovo Yoga C630 and Flex 5G latops:
Tested-by Shawn Guo <[email protected]>With 'OverrideSupported' EFI variable added from UEFI Shell, we can drop 'efi=novamap' kernel cmdline and get around the broken poweroff runtime services nicely. Thanks!
Thanks for confirming.
However, I am not going to merge this without some justification, and hopefully some input from other folks (Leif?)
RTPROP already provides what we need on all platforms that use DtbLoader, and the patch for that is queued up for v5.12-rcX, with a cc:stable to v5.10. This allows any RT service to be marked as disabled, including SetVirtualAddressMap().
So afaict, that means that this patch would be a special case for Flex5G, right? So how are platforms such as this one going to load the DTB? If some loader will be involved (or even just GRUB), shouldn't it be that component that sets RTPROP like DtbLoader will, not the kernel itself.
Btw I don't think ACPI boot is a use case here. I don't see a software framebuffer with no wifi support as a usage mode that justifies carrying EFI stub hacks for everyone.
Signature · 1 line
Ard.
Quoted 33 lines · Ard Biesheuvel
Quoted 18 lines · Shawn Guo
Quoted 7 lines · Ard Biesheuvel
Allow EFI systems to override the set of supported runtime services declared via the
RT_PROPtable, by checking for the existence of a 'OverrideSupported' EFI variable of the appropriate size under theRT_PROPtable GUID, and if it does, combine the supported mask using logical AND. (This means the override can only remove support, not add it back).Quoted 8 lines
Cc Jeffrey Hugo <[email protected]>,Cc Bjorn Andersson <[email protected]>Cc Shawn Guo <[email protected]>Cc Rob Clark <[email protected]>Cc Leif Lindholm <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>Quoted 8 lines
Awesome, Ard! On both Lenovo Yoga C630 and Flex 5G latops:
Tested-by Shawn Guo <[email protected]>With 'OverrideSupported' EFI variable added from UEFI Shell, we can drop 'efi=novamap' kernel cmdline and get around the broken poweroff runtime services nicely. Thanks!
Thanks for confirming.
However, I am not going to merge this without some justification, and hopefully some input from other folks (Leif?)
Quoted 7 lines
RTPROP already provides what we need on all platforms that use DtbLoader, and the patch for that is queued up for v5.12-rcX, with a cc:stable to v5.10. This allows any RT service to be marked as disabled, including
SetVirtualAddressMap().So afaict, that means that this patch would be a special case for Flex5G, right?
It's for all Snapdragon based laptops, as we need to disable SetVirtualAddressMap runtime services on all of them.
Quoted 2 lines
So how are platforms such as this one going to load the DTB? If some loader will be involved (or even just GRUB),
Yes, GRUB.
Quoted 7 lines
shouldn't it
be that component that sets RTPROP like DtbLoader will, not the kernel itself.Btw I don't think ACPI boot is a use case here. I don't see a software framebuffer with no wifi support as a usage mode that justifies carrying EFI stub hacks for everyone.
Okay. I'm fine to carry it as an out-of-tree patch until someday you consider ACPI boot is useful for everyone. But I do boot these laptops with ACPI at daily basis right now as arm64 native build machine, with USB Ethernet adapter.
Shawn
Ard Biesheuvel
maintainerQuoted 55 lines · Shawn Guo
Quoted 33 lines · Ard Biesheuvel
Quoted 18 lines · Shawn Guo
Quoted 7 lines · Ard Biesheuvel
Allow EFI systems to override the set of supported runtime services declared via the
RT_PROPtable, by checking for the existence of a 'OverrideSupported' EFI variable of the appropriate size under theRT_PROPtable GUID, and if it does, combine the supported mask using logical AND. (This means the override can only remove support, not add it back).Quoted 8 lines
Cc Jeffrey Hugo <[email protected]>,Cc Bjorn Andersson <[email protected]>Cc Shawn Guo <[email protected]>Cc Rob Clark <[email protected]>Cc Leif Lindholm <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>Quoted 8 lines
Awesome, Ard! On both Lenovo Yoga C630 and Flex 5G latops:
Tested-by Shawn Guo <[email protected]>With 'OverrideSupported' EFI variable added from UEFI Shell, we can drop 'efi=novamap' kernel cmdline and get around the broken poweroff runtime services nicely. Thanks!
Thanks for confirming.
However, I am not going to merge this without some justification, and hopefully some input from other folks (Leif?)
Quoted 7 lines
RTPROP already provides what we need on all platforms that use DtbLoader, and the patch for that is queued up for v5.12-rcX, with a cc:stable to v5.10. This allows any RT service to be marked as disabled, including
SetVirtualAddressMap().So afaict, that means that this patch would be a special case for Flex5G, right?
It's for all Snapdragon based laptops, as we need to disable SetVirtualAddressMap runtime services on all of them.
Quoted 2 lines
So how are platforms such as this one going to load the DTB? If some loader will be involved (or even just GRUB),
Yes, GRUB.
Quoted 4 lines
shouldn't it
be that component that sets RTPROP like DtbLoader will, not the kernel itself.
Quoted 9 lines
Quoted 3 lines
Btw I don't think ACPI boot is a use case here. I don't see a software framebuffer with no wifi support as a usage mode that justifies carrying EFI stub hacks for everyone.
Okay. I'm fine to carry it as an out-of-tree patch until someday you consider ACPI boot is useful for everyone. But I do boot these laptops with ACPI at daily basis right now as arm64 native build machine, with USB Ethernet adapter.
There may be several reasons why this patch might become worthwhile for upstream, but until that moment, I'd rather not merge it, as it will affect all users, including ones that boot with EFI secure boot enabled. (I haven't quite convinced myself that disabling runtime services arbitrarily using a EFI variable is not something that can be abused)
Quoted 55 lines · Shawn Guo
Quoted 33 lines · Ard Biesheuvel
Quoted 18 lines · Shawn Guo
Quoted 7 lines · Ard Biesheuvel
Allow EFI systems to override the set of supported runtime services declared via the
RT_PROPtable, by checking for the existence of a 'OverrideSupported' EFI variable of the appropriate size under theRT_PROPtable GUID, and if it does, combine the supported mask using logical AND. (This means the override can only remove support, not add it back).Quoted 8 lines
Cc Jeffrey Hugo <[email protected]>,Cc Bjorn Andersson <[email protected]>Cc Shawn Guo <[email protected]>Cc Rob Clark <[email protected]>Cc Leif Lindholm <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>Quoted 8 lines
Awesome, Ard! On both Lenovo Yoga C630 and Flex 5G latops:
Tested-by Shawn Guo <[email protected]>With 'OverrideSupported' EFI variable added from UEFI Shell, we can drop 'efi=novamap' kernel cmdline and get around the broken poweroff runtime services nicely. Thanks!
Thanks for confirming.
However, I am not going to merge this without some justification, and hopefully some input from other folks (Leif?)
Quoted 7 lines
RTPROP already provides what we need on all platforms that use DtbLoader, and the patch for that is queued up for v5.12-rcX, with a cc:stable to v5.10. This allows any RT service to be marked as disabled, including
SetVirtualAddressMap().So afaict, that means that this patch would be a special case for Flex5G, right?
It's for all Snapdragon based laptops, as we need to disable SetVirtualAddressMap runtime services on all of them.
Quoted 2 lines
So how are platforms such as this one going to load the DTB? If some loader will be involved (or even just GRUB),
Yes, GRUB.
Quoted 4 lines
shouldn't it
be that component that sets RTPROP like DtbLoader will, not the kernel itself.
Quoted 8 lines
Quoted 3 lines
Btw I don't think ACPI boot is a use case here. I don't see a software framebuffer with no wifi support as a usage mode that justifies carrying EFI stub hacks for everyone.
Okay. I'm fine to carry it as an out-of-tree patch until someday you consider ACPI boot is useful for everyone. But I do boot these laptops with ACPI at daily basis right now as arm64 native build machine, with USB Ethernet adapter.
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest kernel/dtb/etc
it is a small use-case, but kinda an important step ;-)
BR,
-R
Ard Biesheuvel
maintainerQuoted 66 lines · Rob Clark
Quoted 55 lines · Shawn Guo
Quoted 33 lines · Ard Biesheuvel
Quoted 18 lines · Shawn Guo
Quoted 7 lines · Ard Biesheuvel
Allow EFI systems to override the set of supported runtime services declared via the
RT_PROPtable, by checking for the existence of a 'OverrideSupported' EFI variable of the appropriate size under theRT_PROPtable GUID, and if it does, combine the supported mask using logical AND. (This means the override can only remove support, not add it back).Quoted 8 lines
Cc Jeffrey Hugo <[email protected]>,Cc Bjorn Andersson <[email protected]>Cc Shawn Guo <[email protected]>Cc Rob Clark <[email protected]>Cc Leif Lindholm <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>Quoted 8 lines
Awesome, Ard! On both Lenovo Yoga C630 and Flex 5G latops:
Tested-by Shawn Guo <[email protected]>With 'OverrideSupported' EFI variable added from UEFI Shell, we can drop 'efi=novamap' kernel cmdline and get around the broken poweroff runtime services nicely. Thanks!
Thanks for confirming.
However, I am not going to merge this without some justification, and hopefully some input from other folks (Leif?)
Quoted 7 lines
RTPROP already provides what we need on all platforms that use DtbLoader, and the patch for that is queued up for v5.12-rcX, with a cc:stable to v5.10. This allows any RT service to be marked as disabled, including
SetVirtualAddressMap().So afaict, that means that this patch would be a special case for Flex5G, right?
It's for all Snapdragon based laptops, as we need to disable SetVirtualAddressMap runtime services on all of them.
Quoted 2 lines
So how are platforms such as this one going to load the DTB? If some loader will be involved (or even just GRUB),
Yes, GRUB.
Quoted 4 lines
shouldn't it
be that component that sets RTPROP like DtbLoader will, not the kernel itself.Quoted 8 lines
Quoted 3 lines
Btw I don't think ACPI boot is a use case here. I don't see a software framebuffer with no wifi support as a usage mode that justifies carrying EFI stub hacks for everyone.
Okay. I'm fine to carry it as an out-of-tree patch until someday you consider ACPI boot is useful for everyone. But I do boot these laptops with ACPI at daily basis right now as arm64 native build machine, with USB Ethernet adapter.
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5g
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using SetVirtualAddressMap() altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.
Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 87 lines · Ard Biesheuvel
Quoted 66 lines · Rob Clark
Quoted 55 lines · Shawn Guo
Quoted 33 lines · Ard Biesheuvel
Quoted 18 lines · Shawn Guo
Quoted 7 lines · Ard Biesheuvel
Allow EFI systems to override the set of supported runtime services declared via the
RT_PROPtable, by checking for the existence of a 'OverrideSupported' EFI variable of the appropriate size under theRT_PROPtable GUID, and if it does, combine the supported mask using logical AND. (This means the override can only remove support, not add it back).Quoted 8 lines
Cc Jeffrey Hugo <[email protected]>,Cc Bjorn Andersson <[email protected]>Cc Shawn Guo <[email protected]>Cc Rob Clark <[email protected]>Cc Leif Lindholm <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>Quoted 8 lines
Awesome, Ard! On both Lenovo Yoga C630 and Flex 5G latops:
Tested-by Shawn Guo <[email protected]>With 'OverrideSupported' EFI variable added from UEFI Shell, we can drop 'efi=novamap' kernel cmdline and get around the broken poweroff runtime services nicely. Thanks!
Thanks for confirming.
However, I am not going to merge this without some justification, and hopefully some input from other folks (Leif?)
Quoted 7 lines
RTPROP already provides what we need on all platforms that use DtbLoader, and the patch for that is queued up for v5.12-rcX, with a cc:stable to v5.10. This allows any RT service to be marked as disabled, including
SetVirtualAddressMap().So afaict, that means that this patch would be a special case for Flex5G, right?
It's for all Snapdragon based laptops, as we need to disable SetVirtualAddressMap runtime services on all of them.
Quoted 2 lines
So how are platforms such as this one going to load the DTB? If some loader will be involved (or even just GRUB),
Yes, GRUB.
Quoted 4 lines
shouldn't it
be that component that sets RTPROP like DtbLoader will, not the kernel itself.Quoted 8 lines
Quoted 3 lines
Btw I don't think ACPI boot is a use case here. I don't see a software framebuffer with no wifi support as a usage mode that justifies carrying EFI stub hacks for everyone.
Okay. I'm fine to carry it as an out-of-tree patch until someday you consider ACPI boot is useful for everyone. But I do boot these laptops with ACPI at daily basis right now as arm64 native build machine, with USB Ethernet adapter.
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gSo an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.
Quoted 7 lines
Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Fair, it was less of an argument for/against the patch, and more just reminding folks that there is an ACPI boot use case ;-)
BR,
-R
Quoted 72 lines · Ard Biesheuvel
Quoted 71 lines · Rob Clark
Quoted 55 lines · Shawn Guo
Quoted 33 lines · Ard Biesheuvel
Quoted 18 lines · Shawn Guo
Quoted 7 lines · Ard Biesheuvel
Allow EFI systems to override the set of supported runtime services declared via the
RT_PROPtable, by checking for the existence of a 'OverrideSupported' EFI variable of the appropriate size under theRT_PROPtable GUID, and if it does, combine the supported mask using logical AND. (This means the override can only remove support, not add it back).Quoted 8 lines
Cc Jeffrey Hugo <[email protected]>,Cc Bjorn Andersson <[email protected]>Cc Shawn Guo <[email protected]>Cc Rob Clark <[email protected]>Cc Leif Lindholm <[email protected]>Signed-off-by Ard Biesheuvel <[email protected]>Quoted 8 lines
Awesome, Ard! On both Lenovo Yoga C630 and Flex 5G latops:
Tested-by Shawn Guo <[email protected]>With 'OverrideSupported' EFI variable added from UEFI Shell, we can drop 'efi=novamap' kernel cmdline and get around the broken poweroff runtime services nicely. Thanks!
Thanks for confirming.
However, I am not going to merge this without some justification, and hopefully some input from other folks (Leif?)
Quoted 7 lines
RTPROP already provides what we need on all platforms that use DtbLoader, and the patch for that is queued up for v5.12-rcX, with a cc:stable to v5.10. This allows any RT service to be marked as disabled, including
SetVirtualAddressMap().So afaict, that means that this patch would be a special case for Flex5G, right?
It's for all Snapdragon based laptops, as we need to disable SetVirtualAddressMap runtime services on all of them.
Quoted 2 lines
So how are platforms such as this one going to load the DTB? If some loader will be involved (or even just GRUB),
Yes, GRUB.
Quoted 4 lines
shouldn't it
be that component that sets RTPROP like DtbLoader will, not the kernel itself.Quoted 8 lines
Quoted 3 lines
Btw I don't think ACPI boot is a use case here. I don't see a software framebuffer with no wifi support as a usage mode that justifies carrying EFI stub hacks for everyone.
Okay. I'm fine to carry it as an out-of-tree patch until someday you consider ACPI boot is useful for everyone. But I do boot these laptops with ACPI at daily basis right now as arm64 native build machine, with USB Ethernet adapter.
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etc
Quoted 6 lines
Quoted 2 lines
it is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5g
One more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice OverrideSupported support, we will be able to drop that hack completely.
Quoted 8 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.
Quoted 7 lines
Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this OverrideSupported thing is definitely a big step to that.
Shawn
[1] https://salsa.debian.org/installer-team/grub-installer/-/merge_requests/5
Ard Biesheuvel
maintainerQuoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 34 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 11 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
Quoted 9 lines
Quoted 4 lines
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.
So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
This is not only a problem on Snapdragon systems afaik - most Uboot based arm64 systems booting via EFI are affected by this as well.
So it would be good if we could align with those folks, and maybe the ones working on RISC-V as well, to see if we can get some consensus around taking this approach.
For the folks newly cc'ed on this thread: full version here
https://lore.kernel.org/linux-arm-msm/[email protected]/
Note that I am both the author of the patch, and the maintainer pushing back on it. Please chime in if you think there are reasons why we want this, something like this or nothing like this.
Signature · 1 line
Ard.
Quoted 61 lines · Ard Biesheuvel
Quoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 34 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 11 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
Quoted 9 lines
Quoted 4 lines
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
This is not only a problem on Snapdragon systems afaik - most Uboot based arm64 systems booting via EFI are affected by this as well.
So it would be good if we could align with those folks, and maybe the ones working on RISC-V as well, to see if we can get some consensus around taking this approach.
Quoted 7 lines
For the folks newly cc'ed on this thread: full version here
https://lore.kernel.org/linux-arm-msm/[email protected]/Note that I am both the author of the patch, and the maintainer pushing back on it. Please chime in if you think there are reasons why we want this, something like this or nothing like this.
Hello Ard,
looking at this thread it is hard to understand why this patch should be needed.
If an UEFI application does not want to consume a service, it can do so without having to manipulate the RT properties table.
Which UEFI applications are broken? Why can't they be fixed instead of patching the kernel?
Can we have complete descriptions of the deficiencies of the involved applications. I saw GRUB and the Debian installer mentioned in the thread. Are there others?
Best regards
Heinrich
Quoted 45 lines · Ard Biesheuvel
Quoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 39 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 15 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on efi_variables_supported() check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.
Shawn
[1] https://github.com/rhboot/efibootmgr/blob/master/src/efibootmgr.c#L1764
Ard Biesheuvel
maintainerQuoted 78 lines · Heinrich Schuchardt
Quoted 61 lines · Ard Biesheuvel
Quoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 34 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 11 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
Quoted 9 lines
Quoted 4 lines
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
This is not only a problem on Snapdragon systems afaik - most Uboot based arm64 systems booting via EFI are affected by this as well.
So it would be good if we could align with those folks, and maybe the ones working on RISC-V as well, to see if we can get some consensus around taking this approach.
Quoted 7 lines
For the folks newly cc'ed on this thread: full version here
https://lore.kernel.org/linux-arm-msm/[email protected]/Note that I am both the author of the patch, and the maintainer pushing back on it. Please chime in if you think there are reasons why we want this, something like this or nothing like this.
Hello Ard,
looking at this thread it is hard to understand why this patch should be needed.
If an UEFI application does not want to consume a service, it can do so without having to manipulate the RT properties table.
Quoted 7 lines
Which UEFI applications are broken? Why can't they be fixed instead of patching the kernel?
Can we have complete descriptions of the deficiencies of the involved applications. I saw GRUB and the Debian installer mentioned in the thread. Are there others?
The problem is that the proprietary EDK2 / UEFI firmware on Qualcomm Snapdragon based laptops that were built to run Windows does not implement get/setvariable after ExitBootServices. Instead, every call to any of the variable services returns with an EFI_UNSUPPORTED error.
The correct way to address this is a RT_PROP table that encodes this behavior, and this is what we added in the special DtbLoader driver that is used to boot Linux in DT mode (as the firmware only implements ACPI support). So for systems that can/will run DtbLoader, the problem is solved.
What remains is ACPI boot, or boot modes where DtbLoader does not work. In those cases, it would be useful to have another way to convey this information to the OS in a way that does not rely on the kernel command line.
But thinking about this, perhaps we should be fixing this in efibootmgr instead. EFI_UNSUPPORTED is a valid and documented return code that conveys that the operation did not fail with an error, but that efibootmgr is not supported to begin with on the platform in question.
Ard Biesheuvel
maintainerQuoted 56 lines · Shawn Guo
Quoted 45 lines · Ard Biesheuvel
Quoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 39 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 15 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.
OK, so I suggest we fix efibootmgr, by extending the efi_variables_supported() check to perform a GetVariable() call on an arbitrary variable (e.g., BootOrder), and treat EFI_UNSUPPORTED as a special case that means that carrying on is pointless.
(but someone please confirm that the snapdragon efi firmware does return EFI_UNSUPPORTED and not some other return value when calling GetVariable() from under the OS)
Ilias Apalodimas
reviewerHi Ard,
Quoted 103 lines · Ard Biesheuvel
Quoted 78 lines · Heinrich Schuchardt
Quoted 61 lines · Ard Biesheuvel
Quoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 34 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 11 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
Quoted 9 lines
Quoted 4 lines
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
This is not only a problem on Snapdragon systems afaik - most Uboot based arm64 systems booting via EFI are affected by this as well.
So it would be good if we could align with those folks, and maybe the ones working on RISC-V as well, to see if we can get some consensus around taking this approach.
Quoted 7 lines
For the folks newly cc'ed on this thread: full version here
https://lore.kernel.org/linux-arm-msm/[email protected]/Note that I am both the author of the patch, and the maintainer pushing back on it. Please chime in if you think there are reasons why we want this, something like this or nothing like this.
Hello Ard,
looking at this thread it is hard to understand why this patch should be needed.
If an UEFI application does not want to consume a service, it can do so without having to manipulate the RT properties table.
Quoted 7 lines
Which UEFI applications are broken? Why can't they be fixed instead of patching the kernel?
Can we have complete descriptions of the deficiencies of the involved applications. I saw GRUB and the Debian installer mentioned in the thread. Are there others?
The problem is that the proprietary EDK2 / UEFI firmware on Qualcomm Snapdragon based laptops that were built to run Windows does not implement get/setvariable after ExitBootServices. Instead, every call to any of the variable services returns with an
EFI_UNSUPPORTEDerror.The correct way to address this is a
RT_PROPtable that encodes this behavior, and this is what we added in the special DtbLoader driver that is used to boot Linux in DT mode (as the firmware only implements ACPI support). So for systems that can/will run DtbLoader, the problem is solved.What remains is ACPI boot, or boot modes where DtbLoader does not work. In those cases, it would be useful to have another way to convey this information to the OS in a way that does not rely on the kernel command line.
Quoted 5 lines
But thinking about this, perhaps we should be fixing this in efibootmgr instead.
EFI_UNSUPPORTEDis a valid and documented return code that conveys that the operation did not fail with an error, but that efibootmgr is not supported to begin with on the platform in question.
It all depends on how smart we want to make the efi stub. In essence it's an OS loader, that we have complete control over and we can play tricks on broken/incompatible firmwares, but is that what we want ? And if yes, were do we draw the line of what we fix or not?
I think the current problem doesn't make a strong case to add such functionality. U-Boot doesn't expose SetVariable at all, but even if it did and returned EFI_UNSUPPORTED, I'd expect the consuming applications to handle the error gracefully. I mean why should we treat EFI_UNSUPPORTED differently than EFI_DEVICE_ERROR or EFI_INVALID_PARAMETER (or all the allowed return codes)?
Cheers
/Ilias
Ard Biesheuvel
maintainerQuoted 6 lines · Ilias Apalodimas
Hi Ard,
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Heinrich Schuchardt
...
Quoted 41 lines
Quoted 30 lines
Quoted 6 lines
looking at this thread it is hard to understand why this patch should be needed.
If an UEFI application does not want to consume a service, it can do so without having to manipulate the RT properties table.
Quoted 7 lines
Which UEFI applications are broken? Why can't they be fixed instead of patching the kernel?
Can we have complete descriptions of the deficiencies of the involved applications. I saw GRUB and the Debian installer mentioned in the thread. Are there others?
The problem is that the proprietary EDK2 / UEFI firmware on Qualcomm Snapdragon based laptops that were built to run Windows does not implement get/setvariable after ExitBootServices. Instead, every call to any of the variable services returns with an
EFI_UNSUPPORTEDerror.The correct way to address this is a
RT_PROPtable that encodes this behavior, and this is what we added in the special DtbLoader driver that is used to boot Linux in DT mode (as the firmware only implements ACPI support). So for systems that can/will run DtbLoader, the problem is solved.What remains is ACPI boot, or boot modes where DtbLoader does not work. In those cases, it would be useful to have another way to convey this information to the OS in a way that does not rely on the kernel command line.
Quoted 5 lines
But thinking about this, perhaps we should be fixing this in efibootmgr instead.
EFI_UNSUPPORTEDis a valid and documented return code that conveys that the operation did not fail with an error, but that efibootmgr is not supported to begin with on the platform in question.It all depends on how smart we want to make the efi stub. In essence it's an OS loader, that we have complete control over and we can play tricks on broken/incompatible firmwares, but is that what we want ? And if yes, were do we draw the line of what we fix or not?
Quoted 7 lines
I think the current problem doesn't make a strong case to add such functionality. U-Boot doesn't expose SetVariable at all, but even if it did and returned
EFI_UNSUPPORTED, I'd expect the consuming applications to handle the error gracefully. I mean why should we treatEFI_UNSUPPORTEDdifferently thanEFI_DEVICE_ERRORorEFI_INVALID_PARAMETER(or all the allowed return codes)?
EFI_DEVICE_ERROR or EFI_INVALID_PARAMETER means that the particular call resulted in an error, which may be related to the values of the arguments, the state of the the flash, etc etc
EFI_UNSUPPORTED means that the platform in question does not support the routine at all at runtime, and the arguments or the context is irrelevant.
Given that GRUB already tolerates the second condition, but only if it is communicated explicitly (via --no-nvram) or implicitly when efivarfs is absent altogether, I am saying that we should classify a EFI_UNSUPPORTED return value in the same way, and tolerate it rather than abort the install.
Ilias Apalodimas
reviewerQuoted 58 lines · Ard Biesheuvel
Quoted 6 lines · Ilias Apalodimas
Hi Ard,
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Heinrich Schuchardt
...
Quoted 41 lines
Quoted 30 lines
Quoted 6 lines
looking at this thread it is hard to understand why this patch should be needed.
If an UEFI application does not want to consume a service, it can do so without having to manipulate the RT properties table.
Quoted 7 lines
Which UEFI applications are broken? Why can't they be fixed instead of patching the kernel?
Can we have complete descriptions of the deficiencies of the involved applications. I saw GRUB and the Debian installer mentioned in the thread. Are there others?
The problem is that the proprietary EDK2 / UEFI firmware on Qualcomm Snapdragon based laptops that were built to run Windows does not implement get/setvariable after ExitBootServices. Instead, every call to any of the variable services returns with an
EFI_UNSUPPORTEDerror.The correct way to address this is a
RT_PROPtable that encodes this behavior, and this is what we added in the special DtbLoader driver that is used to boot Linux in DT mode (as the firmware only implements ACPI support). So for systems that can/will run DtbLoader, the problem is solved.What remains is ACPI boot, or boot modes where DtbLoader does not work. In those cases, it would be useful to have another way to convey this information to the OS in a way that does not rely on the kernel command line.
Quoted 5 lines
But thinking about this, perhaps we should be fixing this in efibootmgr instead.
EFI_UNSUPPORTEDis a valid and documented return code that conveys that the operation did not fail with an error, but that efibootmgr is not supported to begin with on the platform in question.It all depends on how smart we want to make the efi stub. In essence it's an OS loader, that we have complete control over and we can play tricks on broken/incompatible firmwares, but is that what we want ? And if yes, were do we draw the line of what we fix or not?
Quoted 7 lines
I think the current problem doesn't make a strong case to add such functionality. U-Boot doesn't expose SetVariable at all, but even if it did and returned
EFI_UNSUPPORTED, I'd expect the consuming applications to handle the error gracefully. I mean why should we treatEFI_UNSUPPORTEDdifferently thanEFI_DEVICE_ERRORorEFI_INVALID_PARAMETER(or all the allowed return codes)?
Quoted 7 lines
EFI_DEVICE_ERRORorEFI_INVALID_PARAMETERmeans that the particular call resulted in an error, which may be related to the values of the arguments, the state of the the flash, etc etc
EFI_UNSUPPORTEDmeans that the platform in question does not support the routine at all at runtime, and the arguments or the context is irrelevant.
By differently I implied 'not handle the error correctly'.
So my point was that an application must handle all errors that are allowed from the spec. Not select the ones it prefers in a meaningfull way. Which brings us to your next point.
Quoted 6 lines
Given that GRUB already tolerates the second condition, but only if it is communicated explicitly (via --no-nvram) or implicitly when efivarfs is absent altogether, I am saying that we should classify a
EFI_UNSUPPORTEDreturn value in the same way, and tolerate it rather than abort the install.
+1
Thanks
/Ilias
Quoted 64 lines · Ard Biesheuvel
Quoted 56 lines · Shawn Guo
Quoted 45 lines · Ard Biesheuvel
Quoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 39 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 15 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.
Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),
Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and efi_variables_supported() is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO, right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.
Shawn
Quoted 6 lines
and treat
EFI_UNSUPPORTEDas a
special case that means that carrying on is pointless.(but someone please confirm that the snapdragon efi firmware does return
EFI_UNSUPPORTEDand not some other return value when callingGetVariable()from under the OS)
Ard Biesheuvel
maintainerQuoted 70 lines · Shawn Guo
Quoted 64 lines · Ard Biesheuvel
Quoted 56 lines · Shawn Guo
Quoted 45 lines · Ard Biesheuvel
Quoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 39 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 15 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),
Quoted 8 lines
Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and
efi_variables_supported()is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO, right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.
I disagree.
My Yoga returns
efivars: get_next_variable: status=8000000000000003
which is documented in the UEFI spec 2.8B section 8.2 as
"""EFI_UNSUPPORTED
After ExitBootServices() has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via an EFI_RT_PROPERTIES_TABLE configuration table.
"""
No other condition is documented under which GetNextVariable() can return EFI_UNSUPPORTED, so it is perfectly suitable to decide whether the platform in question supports variable services at runtime at all.
Ideally, the platform should describe this in the RT_PROP table, but the spec is very clear that the runtime services themselves should still be callable, but return EFI_UNSUPPORTED in that case.
Ilias Apalodimas
reviewerHi Shawn,
Quoted 35 lines
Quoted 31 lines
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),
Quoted 7 lines
Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and
efi_variables_supported()is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO, right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.
But the EFI_UNSUPPORTED is an error that's allowed from the spec. Yes the sane thing to do is not expose it at all, but it's not violating any spec by doing so.
So why shouldn't a userspace application be able to handle all return codes explicitly and instead treat them as a single error? And when that happens why should the kernel mask that error out for it?
Thanks
/Ilias
Quoted 9 lines
Shawn
Quoted 6 lines
and treat
EFI_UNSUPPORTEDas a
special case that means that carrying on is pointless.(but someone please confirm that the snapdragon efi firmware does return
EFI_UNSUPPORTEDand not some other return value when callingGetVariable()from under the OS)
Quoted 41 lines · Ilias Apalodimas
Hi Shawn,
Quoted 39 lines
Quoted 31 lines
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and
efi_variables_supported()is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO,
No, there is not one but there are three EFI variable services.
GetVariable() available after ExitBootServices() and SetVariable() not available() is completely legal according to the current UEFI specification.
Quoted 3 lines
Quoted 3 lines
right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.
Please, describe:
* Which UEFI version is reported by your Snapdragon laptop?
* What is the observed behavior?
Quoted 7 lines
But the
EFI_UNSUPPORTEDis an error that's allowed from the spec. Yes the sane thing to do is not expose it at all, but it's not violating any spec by doing so.
So why shouldn't a userspace application be able to handle all return codes explicitly and instead treat them as a single error? And when that happens why should the kernel mask that error out for it?
The runtime services must always be callable even they can only report EFI_UNSUPPORTED.
Only since UEFI specification 2.8 errata B do we have the EFI_RT_PROPERTIES_TABLE which tells us which runtime services are implemented.
UEFI 2.8 B makes it clear that any runtime service may be reported as unsupported. EFI applications are expected to cope with a service being unavailable.
For embedded systems we have the EBBR specification which specifies that the SetVariable() runtime service is not required to be implemented at runtime
(https://github.com/ARM-software/ebbr/blob/main/source/chapter2-uefi.rst#uefi-runtime-services).
Ony SetVirtualAddressMap() and ConvertPointer() are required by the EBBR.
Software should not mess with EFI variables without explicit consent by the user. In this respect GRUB is a real nuisance. Given a Windows computer installing GRUB changes the BootOrder variable. This results in a system that directly starts into GRUB instead of Windows. GRUB provides a menu entry for Windows that cannot boot because it conflicts with Windows measured boot.
Best regards
Heinrich
Quoted 12 lines
Thanks
/IliasQuoted 9 lines
Shawn
Quoted 6 lines
and treat
EFI_UNSUPPORTEDas a
special case that means that carrying on is pointless.(but someone please confirm that the snapdragon efi firmware does return
EFI_UNSUPPORTEDand not some other return value when callingGetVariable()from under the OS)
Ard Biesheuvel
maintainerQuoted 44 lines · Heinrich Schuchardt
Quoted 41 lines · Ilias Apalodimas
Hi Shawn,
Quoted 39 lines
Quoted 31 lines
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and
efi_variables_supported()is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO,
Quoted 5 lines
No, there is not one but there are three EFI variable services.
GetVariable()available afterExitBootServices()andSetVariable()notavailable()is completely legal according to the current UEFI specification.
This is a valid point. efibootmgr may be able to read the Boot#### variables, but may be unable to change them.
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.
Please, describe:
* Which UEFI version is reported by your Snapdragon laptop?
* What is the observed behavior?
These laptops have the EFI varstore in a eMMC partition. This is basically the same problem that many uboot based platforms have as well, i.e., that it is not possible for the OS and the firmware to share the MMC because the ownership of the MMC controller cannot be shared.
Quoted 11 lines
Quoted 7 lines
But the
EFI_UNSUPPORTEDis an error that's allowed from the spec. Yes the sane thing to do is not expose it at all, but it's not violating any spec by doing so.
So why shouldn't a userspace application be able to handle all return codes explicitly and instead treat them as a single error? And when that happens why shouldut the kernel mask that error out for it?The runtime services must always be callable even they can only report
EFI_UNSUPPORTED.
Quoted 8 lines
Only since UEFI specification 2.8 errata B do we have the
EFI_RT_PROPERTIES_TABLEwhich tells us which runtime services are implemented.UEFI 2.8 B makes it clear that any runtime service may be reported as unsupported. EFI applications are expected to cope with a service being unavailable.
Indeed. The firmware on these machines predates the UEFI 2.8B specification, but given the fact that EFI_UNSUPPORTED is a valid return code now for these services, we should deal with them gracefully anyway. And apparently, doing so would also remove the need for special hacks to support installing GRUB on these platforms.
Quoted 90 lines · Ard Biesheuvel
Quoted 44 lines · Heinrich Schuchardt
Quoted 41 lines · Ilias Apalodimas
Hi Shawn,
Quoted 39 lines
Quoted 31 lines
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and
efi_variables_supported()is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO,Quoted 5 lines
No, there is not one but there are three EFI variable services.
GetVariable()available afterExitBootServices()andSetVariable()notavailable()is completely legal according to the current UEFI specification.This is a valid point. efibootmgr may be able to read the Boot#### variables, but may be unable to change them.
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.
Please, describe:
* Which UEFI version is reported by your Snapdragon laptop?
* What is the observed behavior?These laptops have the EFI varstore in a eMMC partition. This is basically the same problem that many uboot based platforms have as well, i.e., that it is not possible for the OS and the firmware to share the MMC because the ownership of the MMC controller cannot be shared.
Quoted 11 lines
Quoted 7 lines
But the
EFI_UNSUPPORTEDis an error that's allowed from the spec. Yes the sane thing to do is not expose it at all, but it's not violating any spec by doing so.
So why shouldn't a userspace application be able to handle all return codes explicitly and instead treat them as a single error? And when that happens why shouldut the kernel mask that error out for it?The runtime services must always be callable even they can only report
EFI_UNSUPPORTED.Quoted 8 lines
Only since UEFI specification 2.8 errata B do we have the
EFI_RT_PROPERTIES_TABLEwhich tells us which runtime services are implemented.UEFI 2.8 B makes it clear that any runtime service may be reported as unsupported. EFI applications are expected to cope with a service being unavailable.
Quoted 6 lines
Indeed. The firmware on these machines predates the UEFI 2.8B specification, but given the fact that
EFI_UNSUPPORTEDis a valid return code now for these services, we should deal with them gracefully anyway. And apparently, doing so would also remove the need for special hacks to support installing GRUB on these platforms.
Hello Ard,
it is still unclear to why you would need the patch. Why should a user provide a UEFI variable telling which service is not working correctly?
Is the firmware correctly returning EFI_UNSUPPORTED for unsupported services?
For which services?
In which software is the bug that cannot gracefully deal with unsupported services?
GRUB never gave me a problem on boards with U-Boot which only provides GetVariable() and not SetVariable(). GRUB spits out warnings but works as expected.
Best regards
Heinrich
Ard Biesheuvel
maintainerQuoted 99 lines · Heinrich Schuchardt
Quoted 90 lines · Ard Biesheuvel
Quoted 44 lines · Heinrich Schuchardt
Quoted 41 lines · Ilias Apalodimas
Hi Shawn,
Quoted 39 lines
Quoted 31 lines
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and
efi_variables_supported()is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO,Quoted 5 lines
No, there is not one but there are three EFI variable services.
GetVariable()available afterExitBootServices()andSetVariable()notavailable()is completely legal according to the current UEFI specification.This is a valid point. efibootmgr may be able to read the Boot#### variables, but may be unable to change them.
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.
Please, describe:
* Which UEFI version is reported by your Snapdragon laptop?
* What is the observed behavior?These laptops have the EFI varstore in a eMMC partition. This is basically the same problem that many uboot based platforms have as well, i.e., that it is not possible for the OS and the firmware to share the MMC because the ownership of the MMC controller cannot be shared.
Quoted 11 lines
Quoted 7 lines
But the
EFI_UNSUPPORTEDis an error that's allowed from the spec. Yes the sane thing to do is not expose it at all, but it's not violating any spec by doing so.
So why shouldn't a userspace application be able to handle all return codes explicitly and instead treat them as a single error? And when that happens why shouldut the kernel mask that error out for it?The runtime services must always be callable even they can only report
EFI_UNSUPPORTED.Quoted 8 lines
Only since UEFI specification 2.8 errata B do we have the
EFI_RT_PROPERTIES_TABLEwhich tells us which runtime services are implemented.UEFI 2.8 B makes it clear that any runtime service may be reported as unsupported. EFI applications are expected to cope with a service being unavailable.
Quoted 6 lines
Indeed. The firmware on these machines predates the UEFI 2.8B specification, but given the fact that
EFI_UNSUPPORTEDis a valid return code now for these services, we should deal with them gracefully anyway. And apparently, doing so would also remove the need for special hacks to support installing GRUB on these platforms.
Quoted 5 lines
Hello Ard,
it is still unclear to why you would need the patch. Why should a user provide a UEFI variable telling which service is not working correctly?
Why would it be the user setting this variable?
Quoted 2 lines
Is the firmware correctly returning
EFI_UNSUPPORTEDfor unsupported services?
Yes
Quoted 2 lines
For which services?
All runtime services except SetVirtualAddressMap() and ResetSystem()
Quoted 3 lines
In which software is the bug that cannot gracefully deal with unsupported services?
The debian installer gives up if it cannot set the boot path for GRUB.
Quoted 7 lines
GRUB never gave me a problem on boards with U-Boot which only provides
GetVariable()and notSetVariable(). GRUB spits out warnings but works as expected.Best regards
Heinrich
Quoted 116 lines · Ard Biesheuvel
Quoted 99 lines · Heinrich Schuchardt
Quoted 90 lines · Ard Biesheuvel
Quoted 44 lines · Heinrich Schuchardt
Quoted 41 lines · Ilias Apalodimas
Hi Shawn,
Quoted 39 lines
Quoted 31 lines
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and
efi_variables_supported()is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO,Quoted 5 lines
No, there is not one but there are three EFI variable services.
GetVariable()available afterExitBootServices()andSetVariable()notavailable()is completely legal according to the current UEFI specification.This is a valid point. efibootmgr may be able to read the Boot#### variables, but may be unable to change them.
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.
Please, describe:
* Which UEFI version is reported by your Snapdragon laptop?
* What is the observed behavior?These laptops have the EFI varstore in a eMMC partition. This is basically the same problem that many uboot based platforms have as well, i.e., that it is not possible for the OS and the firmware to share the MMC because the ownership of the MMC controller cannot be shared.
Quoted 11 lines
Quoted 7 lines
But the
EFI_UNSUPPORTEDis an error that's allowed from the spec. Yes the sane thing to do is not expose it at all, but it's not violating any spec by doing so.
So why shouldn't a userspace application be able to handle all return codes explicitly and instead treat them as a single error? And when that happens why shouldut the kernel mask that error out for it?The runtime services must always be callable even they can only report
EFI_UNSUPPORTED.Quoted 8 lines
Only since UEFI specification 2.8 errata B do we have the
EFI_RT_PROPERTIES_TABLEwhich tells us which runtime services are implemented.UEFI 2.8 B makes it clear that any runtime service may be reported as unsupported. EFI applications are expected to cope with a service being unavailable.
Quoted 6 lines
Indeed. The firmware on these machines predates the UEFI 2.8B specification, but given the fact that
EFI_UNSUPPORTEDis a valid return code now for these services, we should deal with them gracefully anyway. And apparently, doing so would also remove the need for special hacks to support installing GRUB on these platforms.Quoted 5 lines
Hello Ard,
it is still unclear to why you would need the patch. Why should a user provide a UEFI variable telling which service is not working correctly?
Why would it be the user setting this variable?
Quoted 2 lines
Is the firmware correctly returning
EFI_UNSUPPORTEDfor unsupported services?Yes
Quoted 2 lines
For which services?
Quoted 7 lines
All runtime services except
SetVirtualAddressMap()andResetSystem()Quoted 3 lines
In which software is the bug that cannot gracefully deal with unsupported services?
The debian installer gives up if it cannot set the boot path for GRUB.
The installer should simply open a message box asking the user to set up a boot option for shimaa64.efi (or grubaa64.efi).
This is nothing that can be fixed in the Linux kernel.
Best regards
Heinrich
Quoted 8 lines
Quoted 8 lines
GRUB never gave me a problem on boards with U-Boot which only provides
GetVariable()and notSetVariable(). GRUB spits out warnings but works as expected.Best regards
Heinrich
Quoted 96 lines · Ard Biesheuvel
Quoted 70 lines · Shawn Guo
Quoted 64 lines · Ard Biesheuvel
Quoted 56 lines · Shawn Guo
Quoted 45 lines · Ard Biesheuvel
Quoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 39 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 15 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),Quoted 8 lines
Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and
efi_variables_supported()is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO, right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.I disagree.
My Yoga returns
efivars:
get_next_variable: status=8000000000000003which is documented in the UEFI spec 2.8B section 8.2 as
"""
EFI_UNSUPPORTED
AfterExitBootServices()has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via anEFI_RT_PROPERTIES_TABLEconfiguration table.
"""
Quoted 3 lines
No other condition is documented under which
GetNextVariable()can returnEFI_UNSUPPORTED, so it is perfectly suitable to decide whether the platform in question supports variable services at runtime at all.
I'm not arguing against ideal of checking EFI_UNSUPPORTED. Instead, I agree with that. What I'm arguing is that this should be done by kernel rather than efibootmgr. The efi_variables_supported() of efibootmgr checks EFIVARFS_MAGIC on /sys/firmware/efi/efivars. So if we have kernel function efivar_init() check and respect EFI_UNSUPPORTED return and stop right there, we are all good then. Could you take a look at the patch attached and see if it's acceptable?
Shawn
------8<---------------
From a30a9a03ed254e0f893b831618b30eaffe7f2da7 Mon Sep 17 00:00:00 2001
From: Shawn Guo <[email protected]>
Date: Wed, 17 Mar 2021 11:57:58 +0800
Subject: [PATCH] efivars: respect EFI_UNSUPPORTED return from firmware
As per UEFI spec 2.8B section 8.2, EFI_UNSUPPORTED may be returned by EFI variable runtime services if no variable storage is supported by firmware. In this case, there is no point for kernel to continue efivars initialization. That said, efivar_init() should fail by returning an error code, so that efivarfs will not be mounted on /sys/firmware/efi/efivars at all. Otherwise, user space like efibootmgr will be confused by the EFIVARFS_MAGIC seen there, while EFI variable calls cannot be made successfully.
--- drivers/firmware/efi/vars.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/firmware/efi/vars.c +4 -0
@@ -484,6 +484,10 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), } } +break ; +case EFI_UNSUPPORTED : + err = -EOPNOTSUPP ; + status =EFI_NOT_FOUND ;break ;case EFI_NOT_FOUND :break ;
Signature · 1 line
2.17.1
Quoted 128 lines · Shawn Guo
Quoted 96 lines · Ard Biesheuvel
Quoted 70 lines · Shawn Guo
Quoted 64 lines · Ard Biesheuvel
Quoted 56 lines · Shawn Guo
Quoted 45 lines · Ard Biesheuvel
Quoted 4 lines · Shawn Guo
Quoted 2 lines · Ard Biesheuvel
Quoted 1 line · Rob Clark
...
Quoted 39 lines
Quoted 11 lines
Quoted 7 lines
fwiw, the valid use-case for ACPI boot on these things is for distro installer.. it might not be the shiny accelerated experience, but you want to be able to get thru the installer and then install updates to get latest
kernel/dtb/etcit is a small use-case, but kinda an important step ;-)
That is a fair point. However, as I understand it, we need this to work around
- the need to pass efi=novamap
- broken poweroff on Flex5gOne more: broken EFI variable runtime services on all Snapdragon laptops
It's been another pain of running debian-installer (d-i) on these laptops, where EFI NV variables are just stored on UFS disk. So after Linux takes over the control of UFS, EFI NV variable runtime services then become out of service. Currently, we have to apply a hack [1] on d-i grub-installer to get around the issue, and it's been the only remaining out-of-tree patch we have to carry for d-i. With this nice
OverrideSupportedsupport, we will be able to drop that hack completely.Quoted 15 lines
So an installer either needs to set the EFI variable, or pass efi=novamap on the first boot. Note that there are no arm64 EFI systems known where efi=novamap causes problems. In fact, I would prefer to stop using
SetVirtualAddressMap()altogether, as it does not provide any benefit whatsoever. So perhaps we should make efi=novamap the default and be done with it.Broken poweroff is hardly a showstopper for an installer, given that we cannot even install GRUB correctly.
In summary, I am more than happy to collaborate constructively on this (which is why I wrote the patch), but I don't think we're at a point yet where this is the only thing standing in our way when it comes to a smooth out-of-the-box Linux installation experience.
Quoted 8 lines
Quoted 4 lines
There might be more to be done for getting a smooth Linux installation experience. But IMHO, this
OverrideSupportedthing is definitely a big step to that.So the problem here seems to be that grub-install (or efibootmgr) tolerates efivarfs being absent entirely, but bails out if it exists but gives an error when trying to access it, right?
Quoted 6 lines
Yes, with EFI variables runtime service marked as unsupported, efibootmgr will just exit on
efi_variables_supported()check [1] in a way that its parent process, i.e. grub-install, doesn't take as an error. But otherwise, efibootmgr will go much further and exit with a real error when trying to access efivars.Quoted 3 lines
OK, so I suggest we fix efibootmgr, by extending the
efi_variables_supported()check to perform aGetVariable()call on an arbitrary variable (e.g., BootOrder),Quoted 8 lines
Hmm, I'm not sure we should ask more from user space, as it's already been doing the right thing, and
efi_variables_supported()is proved to work properly with any sane low-level software (kernel + firmware), either EFI variables service is supported or not. That said, IMHO, right now the low-level software on Snapdragon laptops is insane, i.e. the unsupported/broken EFI runtime services are not communicated to user space properly in established way.I disagree.
My Yoga returns
efivars:
get_next_variable: status=8000000000000003which is documented in the UEFI spec 2.8B section 8.2 as
"""
EFI_UNSUPPORTED
AfterExitBootServices()has been called, this return code may be returned if no variable storage is supported. The platform should describe this runtime service as unsupported at runtime via anEFI_RT_PROPERTIES_TABLEconfiguration table.
"""Quoted 3 lines
No other condition is documented under which
GetNextVariable()can returnEFI_UNSUPPORTED, so it is perfectly suitable to decide whether the platform in question supports variable services at runtime at all.I'm not arguing against ideal of checking
EFI_UNSUPPORTED. Instead, I agree with that. What I'm arguing is that this should be done by kernel rather than efibootmgr. Theefi_variables_supported()of efibootmgr checksEFIVARFS_MAGICon/sys/firmware/efi/efivars. So if we have kernel functionefivar_init()check and respectEFI_UNSUPPORTEDreturn and stop right there, we are all good then. Could you take a look at the patch attached and see if it's acceptable?Shawn
------8<---------------
From
a30a9a03ed254e0f893b831618b30eaffe7f2da7Mon Sep 17 00:00:00 2001
From: Shawn Guo <[email protected]>
Date: Wed, 17 Mar 2021 11:57:58 +0800
Subject: [PATCH] efivars: respectEFI_UNSUPPORTEDreturn from firmwareAs per UEFI spec 2.8B section 8.2,
EFI_UNSUPPORTEDmay be returned by EFI variable runtime services if no variable storage is supported by firmware. In this case, there is no point for kernel to continue efivars initialization. That said,efivar_init()should fail by returning an error code, so that efivarfs will not be mounted on/sys/firmware/efi/efivarsat all. Otherwise, user space like efibootmgr will be confused by theEFIVARFS_MAGICseen there, while EFI variable calls cannot be made successfully.
Quoted 1 line
Signed-off-by Shawn Guo <[email protected]>
Yes, this makes sense.
I'll queue this up
Quoted 22 lines
--- drivers/firmware/efi/vars.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/firmware/efi/vars.c +4
-1@@ -484,6 +484,10 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), } } +break ; +case EFI_UNSUPPORTED : + err = -EOPNOTSUPP ; + status =EFI_NOT_FOUND ;break ;case EFI_NOT_FOUND :break ; --2.17.1