Linux Serial subsystem development
 help / color / mirror / Atom feed
From: Jaidev Shastri via B4 Relay <devnull+jaidevshastri.vt.edu@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Jiri Slaby <jirislaby@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
	 Jaidev Shastri <jaidevshastri@vt.edu>
Subject: [PATCH 2/3] vt: order console_blanked between blanking and unblanking
Date: Mon, 21 Sep 2026 21:27:15 -0400	[thread overview]
Message-ID: <20260921-mb-vt-v1-2-71b7990c26c1@vt.edu> (raw)
In-Reply-To: <20260921-mb-vt-v1-0-71b7990c26c1@vt.edu>

From: Jaidev Shastri <jaidevshastri@vt.edu>

do_blank_screen() records the blanked console in console_blanked with a
plain store, after blank_state and the console state have been updated.
do_unblank_screen() tests console_blanked with a plain load before it
uses that state.

Store it with smp_store_release() and read it with smp_load_acquire().

Found with MBCheck, a static herd7-based memory consistency checker.

Signed-off-by: Jaidev Shastri <jaidevshastri@vt.edu>
---
 drivers/tty/vt/vt.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 3abbd6cf9..726402167 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -4683,7 +4683,8 @@ void do_blank_screen(int entering_gfx)
 		hide_cursor(vc);
 		save_screen(vc);
 		vc->vc_sw->con_blank(vc, VESA_VSYNC_SUSPEND, 1);
-		console_blanked = fg_console + 1;
+		/* Pairs with the smp_load_acquire() in do_unblank_screen(). */
+		smp_store_release(&console_blanked, fg_console + 1);
 		blank_state = blank_off;
 		set_origin(vc);
 		return;
@@ -4693,7 +4694,8 @@ void do_blank_screen(int entering_gfx)
 
 	/* don't blank graphics */
 	if (vc->vc_mode != KD_TEXT) {
-		console_blanked = fg_console + 1;
+		/* Pairs with the smp_load_acquire() in do_unblank_screen(). */
+		smp_store_release(&console_blanked, fg_console + 1);
 		return;
 	}
 
@@ -4705,7 +4707,8 @@ void do_blank_screen(int entering_gfx)
 	/* In case we need to reset origin, blanking hook returns 1 */
 	i = vc->vc_sw->con_blank(vc, vesa_off_interval ? VESA_VSYNC_SUSPEND :
 				 (vesa_blank_mode + 1), 0);
-	console_blanked = fg_console + 1;
+	/* Pairs with the smp_load_acquire() in do_unblank_screen(). */
+	smp_store_release(&console_blanked, fg_console + 1);
 	if (i)
 		set_origin(vc);
 
@@ -4737,7 +4740,8 @@ void do_unblank_screen(int leaving_gfx)
 	WARN_CONSOLE_UNLOCKED();
 
 	ignore_poke = 0;
-	if (!console_blanked)
+	/* Pairs with the smp_store_release() in do_blank_screen(). */
+	if (!smp_load_acquire(&console_blanked))
 		return;
 	if (!vc_cons_allocated(fg_console)) {
 		/* impossible */

-- 
2.43.0



  parent reply	other threads:[~2026-09-22  1:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22  1:27 [PATCH 0/3] vt: make the console_lock ordering explicit for three variables Jaidev Shastri via B4 Relay
2026-09-22  1:27 ` [PATCH 1/3] vt: order the fg_console switch against vt_console_print() Jaidev Shastri via B4 Relay
2026-09-22  1:45   ` sashiko-bot
2026-09-23 12:50   ` Greg Kroah-Hartman
2026-09-22  1:27 ` Jaidev Shastri via B4 Relay [this message]
2026-09-22  1:38   ` [PATCH 2/3] vt: order console_blanked between blanking and unblanking sashiko-bot
2026-09-22  1:27 ` [PATCH 3/3] vt: order the vc_cons[] clear against console_callback() Jaidev Shastri via B4 Relay
2026-09-22  1:38   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260921-mb-vt-v1-2-71b7990c26c1@vt.edu \
    --to=devnull+jaidevshastri.vt.edu@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jaidevshastri@vt.edu \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox