Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1nDPff-0001YF-3j for mharc-grub-devel@gnu.org; Fri, 28 Jan 2022 06:44:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDPfe-0001Y0-4g for grub-devel@gnu.org; Fri, 28 Jan 2022 06:44:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54414) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nDPfb-0002Kj-OG for grub-devel@gnu.org; Fri, 28 Jan 2022 06:44:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643370238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8WA3SGyTgZbje7OMbnhXuRmLSHVUHkBO6a84vRk6vNw=; b=D7+rALtXhyyFqJCP0OOgF0PuzgdMzJxBu2mAEX8RdXErrbUcNj4tmyaNMH/lBiBFLYsF/q kLsaSgzEdQlZZA74R3/r7K1p8es8+ZIEUQwCh/oTDMfrUL7VvPBoYaPUHNO7JDh/MCSArH Cq9NNwOkyaknrc026KB4d6nfnFTyS/Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-443-PTTEFtztMKq1QdkZ0loIAg-1; Fri, 28 Jan 2022 06:43:56 -0500 X-MC-Unique: PTTEFtztMKq1QdkZ0loIAg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4DF153E743 for ; Fri, 28 Jan 2022 11:43:55 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.39.193.191]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54CEC67849; Fri, 28 Jan 2022 11:43:50 +0000 (UTC) From: Hans de Goede To: grub-devel@gnu.org Cc: Robbie Harwood , Hans de Goede , Javier Martinez Canillas Subject: [PATCH 1/2] EFI: console: Do not set colorstate until the first text output Date: Fri, 28 Jan 2022 12:43:48 +0100 Message-Id: <20220128114349.87480-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=hdegoede@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Received-SPF: pass client-ip=170.10.129.124; envelope-from=hdegoede@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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-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: Fri, 28 Jan 2022 11:44:02 -0000 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. Cc: Javier Martinez Canillas Fixes: 2d7c3abd871f ("efi/console: Do not set text-mode until we actually need it") Signed-off-by: Hans de Goede --- grub-core/term/efi/console.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index 2f1ae85ba..c44b2ac31 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -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; -- 2.33.1