mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zsolt Kajtar <soci@c64.rulez.org>
To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
	gregkh@linuxfoundation.org, jirislaby@kernel.org
Cc: Zsolt Kajtar <soci@c64.rulez.org>
Subject: [PATCH 2/3] tty/vt: Prevent 8th bit corruption with soft cursor
Date: Fri, 29 Aug 2025 21:49:07 +0200	[thread overview]
Message-ID: <20250829194908.24852-3-soci@c64.rulez.org> (raw)
In-Reply-To: <20250829194908.24852-1-soci@c64.rulez.org>

The attributes of the soft cursor are configurable and one would rightly
expect that only the attributes are to be affected. But that's not
guaranteed for a font with 512 glyphs as the 8th bit is in the attribute
byte. This patch makes sure that really only the attribute bits are
changed by the cursor and not the glyph's appearance.

Signed-off-by: Zsolt Kajtar <soci@c64.rulez.org>
---
 drivers/tty/vt/vt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index c6c931047..d54f4d24e 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -823,6 +823,7 @@ static void add_softcursor(struct vc_data *vc)
 {
 	int i = scr_readw((u16 *) vc->vc_pos);
 	u32 type = vc->vc_cursor_type;
+	int mask = vc->vc_hi_font_mask | 0xff;
 
 	if (!(type & CUR_SW))
 		return;
@@ -836,6 +837,7 @@ static void add_softcursor(struct vc_data *vc)
 		i ^= CUR_BG;
 	if ((type & CUR_INVERT_FG_BG) && (i & CUR_FG) == ((i & CUR_BG) >> 4))
 		i ^= CUR_FG;
+	i = (i & ~mask) | (softcursor_original & mask);
 	scr_writew(i, (u16 *)vc->vc_pos);
 	if (con_should_update(vc))
 		con_putc(vc, i, vc->state.y, vc->state.x);
-- 
2.30.2


  parent reply	other threads:[~2025-08-29 19:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-29 19:49 [PATCH 0/3] tty/vt: fix various 512 glyph font issues Zsolt Kajtar
2025-08-29 19:49 ` [PATCH 1/3] tty/vt: 8th bit location in vc_uniscr routines Zsolt Kajtar
2025-08-31  6:14   ` Jiri Slaby
2025-08-29 19:49 ` Zsolt Kajtar [this message]
2025-08-31  6:25   ` [PATCH 2/3] tty/vt: Prevent 8th bit corruption with soft cursor Jiri Slaby
2025-08-29 19:49 ` [PATCH 3/3] tty/vt: Fix unreadable kernel messages on vgacon Zsolt Kajtar
2025-08-31  6:28   ` Jiri Slaby

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=20250829194908.24852-3-soci@c64.rulez.org \
    --to=soci@c64.rulez.org \
    --cc=gregkh@linuxfoundation.org \
    --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

all inboxes | Powered by JetHome®