]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
term/efi/console: Do not set colorstate until the first text output
authorHans de Goede <hdegoede@redhat.com>
Fri, 28 Jan 2022 11:43:48 +0000 (12:43 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 21 Mar 2022 20:40:31 +0000 (21:40 +0100)
GRUB_MOD_INIT(normal) does an unconditional:

  grub_env_set ("color_normal", "light-gray/black");

which triggers a grub_term_setcolorstate() call. The original version
of the "efi/console: Do not set text-mode until we actually need it" patch,
https://lists.gnu.org/archive/html/grub-devel/2018-03/msg00125.html,
protected against this by caching the requested state in
grub_console_setcolorstate() and then only applying it when the first
text output actually happens. During refactoring to move the
grub_console_setcolorstate() up higher in the grub-core/term/efi/console.c
file the code to cache the color-state + bail early was accidentally dropped.
Restore the cache the color-state + bail early behavior from the original.

Fixes: 2d7c3abd871f (efi/console: Do not set text-mode until we actually need it)
Cc: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/term/efi/console.c

index 2f1ae85ba7dde6ce8190f38b1e63ae7e6da6081a..c44b2ac318cb06c642b6c2d710ea1ddd24472473 100644 (file)
@@ -82,6 +82,16 @@ grub_console_setcolorstate (struct grub_term_output *term
 {
   grub_efi_simple_text_output_interface_t *o;
 
+  if (grub_efi_is_finished || text_mode != GRUB_TEXT_MODE_AVAILABLE)
+    {
+      /*
+       * Cache colorstate changes before the first text-output, this avoids
+       * "color_normal" environment writes causing a switch to textmode.
+       */
+      text_colorstate = state;
+      return;
+    }
+
   if (grub_efi_is_finished)
     return;