Blame SOURCES/0196-EFI-console-Do-not-set-colorstate-until-the-first-te.patch

fd0330
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
fd0330
From: Hans de Goede <hdegoede@redhat.com>
fd0330
Date: Fri, 28 Jan 2022 12:43:48 +0100
fd0330
Subject: [PATCH] EFI: console: Do not set colorstate until the first text
fd0330
 output
fd0330
fd0330
GRUB_MOD_INIT(normal) does an unconditional:
fd0330
fd0330
grub_env_set ("color_normal", "light-gray/black");
fd0330
fd0330
which triggers a grub_term_setcolorstate() call. The original version
fd0330
of the "efi/console: Do not set text-mode until we actually need it" patch:
fd0330
https://lists.gnu.org/archive/html/grub-devel/2018-03/msg00125.html
fd0330
fd0330
Protected against this by caching the requested state in
fd0330
grub_console_setcolorstate () and then only applying it when the first
fd0330
text output actually happens. During refactoring to move the
fd0330
grub_console_setcolorstate () up higher in the grub-core/term/efi/console.c
fd0330
file the code to cache the color-state + bail early was accidentally
fd0330
dropped.
fd0330
fd0330
Restore the cache the color-state + bail early behavior from the original.
fd0330
fd0330
Cc: Javier Martinez Canillas <javierm@redhat.com>
fd0330
Fixes: 2d7c3abd871f ("efi/console: Do not set text-mode until we actually need it")
fd0330
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
fd0330
---
fd0330
 grub-core/term/efi/console.c | 10 ++++++++++
fd0330
 1 file changed, 10 insertions(+)
fd0330
fd0330
diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
fd0330
index 2f1ae85ba7..c44b2ac318 100644
fd0330
--- a/grub-core/term/efi/console.c
fd0330
+++ b/grub-core/term/efi/console.c
fd0330
@@ -82,6 +82,16 @@ grub_console_setcolorstate (struct grub_term_output *term
fd0330
 {
fd0330
   grub_efi_simple_text_output_interface_t *o;
fd0330
 
fd0330
+  if (grub_efi_is_finished || text_mode != GRUB_TEXT_MODE_AVAILABLE)
fd0330
+    {
fd0330
+      /*
fd0330
+       * Cache colorstate changes before the first text-output, this avoids
fd0330
+       * "color_normal" environment writes causing a switch to textmode.
fd0330
+       */
fd0330
+      text_colorstate = state;
fd0330
+      return;
fd0330
+    }
fd0330
+
fd0330
   if (grub_efi_is_finished)
fd0330
     return;
fd0330