Skip to contentSkip to conversation

EFI/menu: Do not print messages when autobooting with TIMEOUT_STYLE_HIDDEN

PATCH In review Hans de Goede 3 participants 7 messages Jan 28, 2022 – Mar 22, 2022

lore
Share & tools
lore
#0 lore raw

cover EFI/menu: Do not print messages when autobooting with TIMEOUT_STYLE_HIDDEN

Hi All,

This series in essence is a renewed attempt to get grub to really be truly hidden when autobooting with TIMEOUT_STYLE_HIDDEN.

This is something which multiple big Linux distributions want, this is a minimized version of my previous attempt from March 2018:
https://lists.gnu.org/archive/html/grub-devel/2018-03/msg00126.html
With some discussion about this patch in April 2018:
https://lists.gnu.org/archive/html/grub-devel/2018-04/msg00009.html

The first patch silences the notify_booting() callback from grub-core/normal/menu.c based on the timeout_style (1), as suggested in the original discussion.

After that there is just one message left, from grub-core/kern/main.c which is printed before the config file loads. When timeout_style is not set to hidden this will only show very briefly to then be replaced by the menu / countdown; and with timeout_style=hidden we actually want it to behave the same as any other grub messages and have it hidden. The second patch makes this happen by just disabling the logging of the message for EFI builds.

This also fixes the message briefly flashing by (in an ugly manner because of the "flash" part) when timeout_style!=hidden.

Regards,

Hans

1) It is only silenced when autobooting with TIMEOUT_STYLE_HIDDEN

Hans de Goede (2):
normal/menu: Don't show "Booting `%s'" msg when auto-booting with
TIMEOUT_STYLE_HIDDEN
EFI: suppress the "Welcome to GRUB!" message in EFI builds

 grub-core/kern/main.c   |  3 +++
 grub-core/normal/menu.c | 25 +++++++++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)
Signature · 1 line
2.33.1
#1 lore raw

PATCH 1/2 normal/menu: Don't show "Booting `%s'" msg when auto-booting with TIMEOUT_STYLE_HIDDEN

When the user has asked the menu code to be hidden/quiet and the current entry is being autobooted because the timeout has expired don't show the "Booting `%s'" msg.

This is necessary to let flicker-free boots really be flicker free, otherwise the "Booting `%s'" msg will kick the EFI fb into text mode and show the msg, breaking the flicker-free experience.

---
 grub-core/normal/menu.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
grub-core/normal/menu.c +16 -8
index 8397886fa..fa4871a62 100644
@@ -573,13 +573,15 @@ print_countdown (struct grub_term_coordinate *pos, int n)
    entry to be executed is a result of an automatic default selection because
    of the timeout.  */
 static int
-run_menu (grub_menu_t menu, int nested, int *auto_boot)
+run_menu (grub_menu_t menu, int nested, int *auto_boot, int *notify_boot)
 {
   grub_uint64_t saved_time;
   int default_entry, current_entry;
   int timeout;
   enum timeout_style timeout_style;
 
+  *notify_boot = 1;
+
   default_entry = get_entry_number (menu, "default");
 
   /* If DEFAULT_ENTRY is not within the menu entries, fall back to
@@ -654,6 +656,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
   if (timeout == 0)
     {
       *auto_boot = 1;
+      *notify_boot = timeout_style != TIMEOUT_STYLE_HIDDEN;
       return default_entry;
     }
 
@@ -807,12 +810,16 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot)
 
 /* Callback invoked immediately before a menu entry is executed.  */
 static void
-notify_booting (grub_menu_entry_t entry,
-		void *userdata __attribute__((unused)))
+notify_booting (grub_menu_entry_t entry, void *userdata)
 {
-  grub_printf ("  ");
-  grub_printf_ (N_("Booting `%s'"), entry->title);
-  grub_printf ("\n\n");
+  int *notify_boot = userdata;
+
+  if (*notify_boot)
+    {
+      grub_printf ("  ");
+      grub_printf_ (N_("Booting `%s'"), entry->title);
+      grub_printf ("\n\n");
+    }
 }
 
 /* Callback invoked when a default menu entry executed because of a timeout
@@ -860,8 +867,9 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
       int boot_entry;
       grub_menu_entry_t e;
       int auto_boot;
+      int notify_boot;
 
-      boot_entry = run_menu (menu, nested, &auto_boot);
+      boot_entry = run_menu (menu, nested, &auto_boot, &notify_boot);
       if (boot_entry < 0)
 	break;
 
@@ -873,7 +881,7 @@ show_menu (grub_menu_t menu, int nested, int autobooted)
 
       if (auto_boot)
 	grub_menu_execute_with_fallback (menu, e, autobooted,
-					 &execution_callback, 0);
+					 &execution_callback, &notify_boot);
       else
 	grub_menu_execute_entry (e, 0);
       if (autobooted)
Signature · 1 line
2.33.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] normal/menu: Don't show "Booting `%s'" msg when auto-booting with TIMEOUT_STYLE_HIDDEN

Quoted 4 lines · Hans de Goede

When the user has asked the menu code to be hidden/quiet and the current entry is being autobooted because the timeout has expired don't show the "Booting `%s'" msg.

Quoted 8 lines

This is necessary to let flicker-free boots really be flicker free, otherwise the "Booting `%s'" msg will kick the EFI fb into text mode and show the msg, breaking the flicker-free experience.

---
 grub-core/normal/menu.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

Be well,
--Robbie

#3 lore raw

PATCH 2/2 EFI: suppress the "Welcome to GRUB!" message in EFI builds

In reply to Hans de Goede

Grub EFI builds are now often used in combination with flicker-free boot, but this breaks with upstream grub because the "Welcome to GRUB!" message will kick the EFI fb into text mode and show the msg, breaking the flicker-free experience.

EFI systems are so fast, that when the menu or the countdown are enabled the message will be immediately overwritten, so in these cases not printing the message does not matter.

And in case when the timeout_style is set to TIMEOUT_STYLE_HIDDEN, the user has asked grub to be quiet (for example to allow flickfree boot) annd thus the message should not be printed.

---
 grub-core/kern/main.c | 3 +++
 1 file changed, 3 insertions(+)
grub-core/kern/main.c +3 -0
index 73967e2f5..e811dc3b1 100644
@@ -270,10 +270,13 @@ grub_main (void)
 
   grub_boot_time ("After machine init.");
 
+  /* This breaks flicker-free boot on EFI systems, so disable it there. */
+#ifndef GRUB_MACHINE_EFI
   /* Hello.  */
   grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
   grub_printf ("Welcome to GRUB!\n\n");
   grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
+#endif
 
   /* Init verifiers API. */
   grub_verifiers_init ();
Signature · 1 line
2.33.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] EFI: suppress the "Welcome to GRUB!" message in EFI builds

Quoted 9 lines · Hans de Goede

Grub EFI builds are now often used in combination with flicker-free boot, but this breaks with upstream grub because the "Welcome to GRUB!" message will kick the EFI fb into text mode and show the msg, breaking the flicker-free experience.

EFI systems are so fast, that when the menu or the countdown are enabled the message will be immediately overwritten, so in these cases not printing the message does not matter.

Quoted 5 lines

And in case when the timeout_style is set to TIMEOUT_STYLE_HIDDEN, the user has asked grub to be quiet (for example to allow flickfree boot) annd thus the message should not be printed.

Be well,
--Robbie

author Reviewed-by Robbie Harwood on the v1 series
#5 lore raw
In reply to Hans de Goede

Hi Daniel,

Quoted 26 lines · Hans de Goede

Hi All,

This series in essence is a renewed attempt to get grub to really be truly hidden when autobooting with TIMEOUT_STYLE_HIDDEN.

This is something which multiple big Linux distributions want, this is a minimized version of my previous attempt from March 2018:
https://lists.gnu.org/archive/html/grub-devel/2018-03/msg00126.html
With some discussion about this patch in April 2018:
https://lists.gnu.org/archive/html/grub-devel/2018-04/msg00009.html

The first patch silences the notify_booting() callback from grub-core/normal/menu.c based on the timeout_style (1), as suggested in the original discussion.

After that there is just one message left, from grub-core/kern/main.c which is printed before the config file loads. When timeout_style is not set to hidden this will only show very briefly to then be replaced by the menu / countdown; and with timeout_style=hidden we actually want it to behave the same as any other grub messages and have it hidden. The second patch makes this happen by just disabling the logging of the message for EFI builds.

This also fixes the message briefly flashing by (in an ugly manner because of the "flash" part) when timeout_style!=hidden.

Quoted 6 lines

Regards,

Hans

1) It is only silenced when autobooting with TIMEOUT_STYLE_HIDDEN

What is the status of this series? It has been well over a month and both patches have received a Reviewed-by and no other comments:

Regards,

Hans

Quoted 9 lines

Hans de Goede (2):
normal/menu: Don't show "Booting `%s'" msg when auto-booting with
TIMEOUT_STYLE_HIDDEN
EFI: suppress the "Welcome to GRUB!" message in EFI builds

 grub-core/kern/main.c   |  3 +++
 grub-core/normal/menu.c | 25 +++++++++++++++++--------
 2 files changed, 20 insertions(+), 8 deletions(-)
Reviewed-by
#6 lore raw
Quoted 34 lines · Hans de Goede

Hi Daniel,

Quoted 31 lines · Hans de Goede

Hi All,

This series in essence is a renewed attempt to get grub to really be truly hidden when autobooting with TIMEOUT_STYLE_HIDDEN.

This is something which multiple big Linux distributions want, this is a minimized version of my previous attempt from March 2018:
https://lists.gnu.org/archive/html/grub-devel/2018-03/msg00126.html
With some discussion about this patch in April 2018:
https://lists.gnu.org/archive/html/grub-devel/2018-04/msg00009.html

The first patch silences the notify_booting() callback from grub-core/normal/menu.c based on the timeout_style (1), as suggested in the original discussion.

After that there is just one message left, from grub-core/kern/main.c which is printed before the config file loads. When timeout_style is not set to hidden this will only show very briefly to then be replaced by the menu / countdown; and with timeout_style=hidden we actually want it to behave the same as any other grub messages and have it hidden. The second patch makes this happen by just disabling the logging of the message for EFI builds.

This also fixes the message briefly flashing by (in an ugly manner because of the "flash" part) when timeout_style!=hidden.

Regards,

Hans

Quoted 6 lines
Quoted 1 line

1) It is only silenced when autobooting with TIMEOUT_STYLE_HIDDEN

What is the status of this series? It has been well over a month and both patches have received a Reviewed-by and no other comments:

Daniel