grub2/0215-efi-Print-an-error-if-boot-to-firmware-setup-is-not-.patch
Javier Martinez Canillas 67f07b7c9e
Another set of fixes for 2.06
- Add luks2 to GRUB_MODULES
- 20-grub-install: Create a symvers.gz symbolic link
- 20-grub-install: Always use fedora as the boot entry --class
  Resolves: rhbz#1957014
- grub.macros: Install font in /boot/grub2 instead of the ESP
  Resolves: rhbz#1739762
- grub.macros: Use consistent file mode for legacy and EFI
  Resolves: rhbz#1965794
- Drop grub2 prelink configuration
  Resolves: rhbz#1659675
- Remove triggers needed to upgrade from legacy GRUB
- Don't harcode grub2 in the spec file
- Update to unifont-13.0.06
  Resolves: rhbz#1939125
- 20-grub-install: Use relative paths for btrfs in BLS snippets
  Resolves: rhbz#1906191
- Don't update the cmdline when generating legacy menuentry commands
- Suppress gettext error message
  Resolves: rhbz#1592124
- grub-boot-success.timer: Only run if not in a container
  Resolves: rhbz#1914571
- grub-set-password: Always use /boot/grub2/user.cfg as password default
  Resolves: rhbz#1955294
- Remove outdated URL for BLS document
  Resolves: rhbz#1926453
- templates: Check for EFI at runtime instead of config generation time
  Resolves: rhbz#1823864
- efi: Print an error if boot to firmware setup is not supported
  Resolves: rhbz#1823864

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
2021-07-06 11:18:04 +02:00

93 lines
2.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Javier Martinez Canillas <javierm@redhat.com>
Date: Tue, 6 Jul 2021 01:10:18 +0200
Subject: [PATCH] efi: Print an error if boot to firmware setup is not
supported
The "fwsetup" command is only registered if the firmware supports booting
to the firmware setup UI. But it could be possible that the GRUB config
already contains a "fwsetup" entry, because it was generated in a machine
that has support for this feature.
To prevent users getting a "can't find command `fwsetup`" error if it is
not supported by the firmware, let's just always register the command but
print a more accurate message if the firmware doesn't support this option.
Resolves: rhbz#1823864
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
---
grub-core/commands/efi/efifwsetup.c | 43 ++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/grub-core/commands/efi/efifwsetup.c b/grub-core/commands/efi/efifwsetup.c
index eaca0328388..328c45e82e0 100644
--- a/grub-core/commands/efi/efifwsetup.c
+++ b/grub-core/commands/efi/efifwsetup.c
@@ -27,6 +27,25 @@
GRUB_MOD_LICENSE ("GPLv3+");
+static grub_efi_boolean_t
+efifwsetup_is_supported (void)
+{
+ grub_efi_uint64_t *os_indications_supported = NULL;
+ grub_size_t oi_size = 0;
+ grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+
+ grub_efi_get_variable ("OsIndicationsSupported", &global, &oi_size,
+ (void **) &os_indications_supported);
+
+ if (!os_indications_supported)
+ return 0;
+
+ if (*os_indications_supported & GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI)
+ return 1;
+
+ return 0;
+}
+
static grub_err_t
grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
@@ -38,6 +57,10 @@ grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
grub_size_t oi_size;
grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
+ if (!efifwsetup_is_supported ())
+ return grub_error (GRUB_ERR_INVALID_COMMAND,
+ N_("Reboot to firmware setup is not supported"));
+
grub_efi_get_variable ("OsIndications", &global, &oi_size,
(void **) &old_os_indications);
@@ -56,28 +79,8 @@ grub_cmd_fwsetup (grub_command_t cmd __attribute__ ((unused)),
static grub_command_t cmd = NULL;
-static grub_efi_boolean_t
-efifwsetup_is_supported (void)
-{
- grub_efi_uint64_t *os_indications_supported = NULL;
- grub_size_t oi_size = 0;
- grub_efi_guid_t global = GRUB_EFI_GLOBAL_VARIABLE_GUID;
-
- grub_efi_get_variable ("OsIndicationsSupported", &global, &oi_size,
- (void **) &os_indications_supported);
-
- if (!os_indications_supported)
- return 0;
-
- if (*os_indications_supported & GRUB_EFI_OS_INDICATIONS_BOOT_TO_FW_UI)
- return 1;
-
- return 0;
-}
-
GRUB_MOD_INIT (efifwsetup)
{
- if (efifwsetup_is_supported ())
cmd = grub_register_command ("fwsetup", grub_cmd_fwsetup, NULL,
N_("Reboot into firmware setup menu."));