Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oX2Uw-0002dz-HD for mharc-grub-devel@gnu.org; Sat, 10 Sep 2022 11:34:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oX1mh-0002IX-Un for grub-devel@gnu.org; Sat, 10 Sep 2022 10:48:39 -0400 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]:34317) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oX1mf-0000e6-MM for grub-devel@gnu.org; Sat, 10 Sep 2022 10:48:39 -0400 Received: by mail-ot1-x332.google.com with SMTP id q39-20020a056830442700b0063889adc0ddso2926584otv.1 for ; Sat, 10 Sep 2022 07:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=7NWEtCtaK8zF50lZ6GNwJEkCYtQ9GZL+eW0xphqEfQg=; b=GeQcsURarlG7ZZIZsG6M36rCsin3x5ULJMKIq3q7xT3PFIRepGN5g/c/471x8TEO8k ElNROf4cCOTEmst2Gw1z1tJWODlgxMBdSQEG+A8QOCGuiwxDOlCSmVY3GL/Ps0w/FcNO vMPqs3mMN8vmRlW+Fsr9Z0o9PXShaDqSofMIuRPzpPNnxfdNHk9Id7B6r/G56xk1tR2M zs1sECZkBJAq35tmXxDeZe6sz06/U2huq/x4U6ACAIzflIizz9MSSBDCdK1QBXWKCNsd QvkUTGJ94qen3lXpGS4gD1TLkFBIgEN7Y9qSsecD0VadH6uSmParupWg8tXJ04PFKyoa D0vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=7NWEtCtaK8zF50lZ6GNwJEkCYtQ9GZL+eW0xphqEfQg=; b=2FS2aEAai2q7XnjdgSkMWU/aQn8itKFILJ7iP6E9FLqEMujz7aKzEdaNFtPDgyTNVQ c3ggtSZbtd1o1tldFjL2jCvmQd0i+sWhMljwYfOC8eZlvkqbZQNX6IFDhiYSo/Tj2K7I kkc71mayoQJ1xxHvYxC+6u48EIY9yP+LNiJJuVr2oZnR8MpvcPxwynPN5jrnwTIoatje asIGKZ3uj4AL/EH6el6SFGsarH7HK1puhyI1Hh/LDKsj38H1iMwwraUT9QbUvIS8GHr4 yurwiDAJEGz7Fv8JFGyAZW7QInI+JG/2yNjksxShQTyK6e3ewqIRY9EJmP3br8Wjkbcj lHCA== X-Gm-Message-State: ACgBeo1+c+dEqeJK09dC0xNcdHTK/K9RKG1sEOKW8vQ4uojWXlES5eon TcV2ABxY2/2sMWGGp7Cdvgcl3Bvz+jM= X-Google-Smtp-Source: AA6agR6E+hZjdw1yD3uS2LVgtmT/0PGisKluo1GopVAcXP80xpJzWsMGxHBRtdWq1JGMbmdW2pyIrQ== X-Received: by 2002:a9d:748a:0:b0:637:1cf2:c8c4 with SMTP id t10-20020a9d748a000000b006371cf2c8c4mr7382700otk.274.1662821315483; Sat, 10 Sep 2022 07:48:35 -0700 (PDT) Received: from localhost ([2806:2f0:4060:fff1:4ae7:daff:fe31:3285]) by smtp.gmail.com with ESMTPSA id f11-20020a9d7b4b000000b006394136eae0sm1419653oto.57.2022.09.10.07.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Sep 2022 07:48:34 -0700 (PDT) From: Felipe Contreras To: grub-devel@gnu.org Cc: Felipe Contreras , Javier Martinez Canillas , Robbie Harwood , Dimitri John Ledkov Subject: [PATCH] efi: add feature_efifwsetup_check Date: Sat, 10 Sep 2022 09:48:33 -0500 Message-Id: <20220910144833.2986-1-felipe.contreras@gmail.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::332; envelope-from=felipe.contreras@gmail.com; helo=mail-ot1-x332.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 10 Sep 2022 11:34:21 -0400 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Sep 2022 14:48:40 -0000 In commit 26031d3b1 (efi: Don't display a uefi-firmware entry if it's not supported, 2022-08-18) an unconditional call to `fwsetup --is-supported` was added which causes the system to reboot if `grub-install` hasn't been run because `fwsetup` doesn't have the new option. This is a huge regression. To make sure `fwsetup --is-supported` works we add a new feature that only newer GRUB installations have: feature_efifwsetup_check. If the feature is available the current behavior is maintained (`fwsetup --is-supported`) but if it's not available the behavior before 26031d3b1 is maintained (unconditionally show the menu entry on EFI platforms). Also do this only on the EFI platform as Dimitri John Ledkov suggested. Cc: Javier Martinez Canillas Cc: Robbie Harwood Cc: Dimitri John Ledkov Signed-off-by: Felipe Contreras --- grub-core/normal/main.c | 2 +- util/grub.d/30_uefi-firmware.in | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index cb0e8e7fd..072e8e681 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -506,7 +506,7 @@ static const char *features[] = { "feature_chainloader_bpb", "feature_ntldr", "feature_platform_search_hint", "feature_default_font_path", "feature_all_video_module", "feature_menuentry_id", "feature_menuentry_options", "feature_200_final", - "feature_nativedisk_cmd", "feature_timeout_style" + "feature_nativedisk_cmd", "feature_timeout_style", "feature_efifwsetup_check" }; GRUB_MOD_INIT(normal) diff --git a/util/grub.d/30_uefi-firmware.in b/util/grub.d/30_uefi-firmware.in index c1731e5bb..c23d84741 100644 --- a/util/grub.d/30_uefi-firmware.in +++ b/util/grub.d/30_uefi-firmware.in @@ -31,10 +31,16 @@ LABEL="UEFI Firmware Settings" gettext_printf "Adding boot menu entry for UEFI Firmware Settings ...\n" >&2 cat << EOF -fwsetup --is-supported -if [ "\$grub_platform" = "efi" -a "\$?" = 0 ]; then - menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { - fwsetup - } +if [ "\$grub_platform" = "efi" ]; then + if [ "\$feature_efifwsetup_check" = "y" ] ; then + fwsetup --is-supported + else + true + fi + if [ "\$?" = 0 ]; then + menuentry '$LABEL' \$menuentry_id_option 'uefi-firmware' { + fwsetup + } + fi fi EOF -- 2.37.3