From nobody Fri Oct 3 12:13:04 2025 Received: from c64.rulez.org (c64.rulez.org [79.139.58.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C26C2442C; Mon, 1 Sep 2025 05:54:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.139.58.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756706076; cv=none; b=d4/8TRz6XbMQRWlZzMNtloIi1aolSa9N19xQa3FmtDL5f/RysDvzu3BVOeJfqzx89say1cHZk7HeJbur26ZewYH5pN6CvNE1Cc/SfWQzxlUMnUPGniiRhJcHsqQWYIdHWbMbA8DDf3FfaWseflyRfPqkamCs1Mw/lw7wBwjWJ+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756706076; c=relaxed/simple; bh=ZD50RwRddaDSQ+q3aDocn10Q+tyd9MmUqLG7iZTxacA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oL3cXGbqmN6VAU0EimfeK1LJC3fPY1CJ1l/1ePTuoQIv6Z2/qFLqEDeOCZO6p3p0FX1o4X33ZhB5MmQqttBHXzREkEDnBzmd0breci2uJb9RpT81Bq2acWL6nPYtE7oG4DrtPTgEK219KcTHHuTsWAMIvjJhSHShghSqdITqRkw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org; spf=pass smtp.mailfrom=c64.rulez.org; arc=none smtp.client-ip=79.139.58.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c64.rulez.org Received: by c64.rulez.org (Postfix, from userid 1000) id 61D1D1011A; Mon, 1 Sep 2025 07:54:19 +0200 (CEST) From: Zsolt Kajtar To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: Zsolt Kajtar Subject: [PATCH v2 1/4] tty/vt: 8th bit location in vc_uniscr routines Date: Mon, 1 Sep 2025 07:26:33 +0200 Message-Id: <20250901052636.8981-2-soci@c64.rulez.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250901052636.8981-1-soci@c64.rulez.org> References: <20250901052636.8981-1-soci@c64.rulez.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Both vc_uniscr_check and vc_uniscr_copy_line assume that the 8th bit of glyph is also the 8th bit in the screen buffer. However this is only the case for fbcon at the moment. Vgacon has it on the 11th and so the conversion won't work in that case. The patch adds a helper to read the glyph correctly from the buffer. Signed-off-by: Zsolt Kajtar --- drivers/tty/vt/vt.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 869261141..19ce9c426 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -293,6 +293,17 @@ static inline u16 *screenpos(const struct vc_data *vc,= unsigned int offset, return (u16 *)(origin + offset); } =20 +static inline u16 scr_read_glyph(const struct vc_data *vc, u16 *pos) +{ + u16 w =3D scr_readw(pos); + u16 glyph =3D w & 0xff; + + if (w & vc->vc_hi_font_mask) + glyph |=3D 0x100; + + return glyph; +} + static void con_putc(struct vc_data *vc, u16 ca, unsigned int y, unsigned = int x) { if (vc->vc_sw->con_putc) @@ -493,7 +504,7 @@ int vc_uniscr_check(struct vc_data *vc) { u32 **uni_lines; unsigned short *p; - int x, y, mask; + int x, y; =20 WARN_CONSOLE_UNLOCKED(); =20 @@ -514,11 +525,11 @@ int vc_uniscr_check(struct vc_data *vc) * unicode content will be available after a complete screen refresh. */ p =3D (unsigned short *)vc->vc_origin; - mask =3D vc->vc_hi_font_mask | 0xff; for (y =3D 0; y < vc->vc_rows; y++) { u32 *line =3D uni_lines[y]; for (x =3D 0; x < vc->vc_cols; x++) { - u16 glyph =3D scr_readw(p++) & mask; + u16 glyph =3D scr_read_glyph(vc, p++); + line[x] =3D inverse_translate(vc, glyph, true); } } @@ -561,10 +572,10 @@ void vc_uniscr_copy_line(const struct vc_data *vc, vo= id *dest, bool viewed, * buffer of its own. */ u16 *p =3D (u16 *)pos; - int mask =3D vc->vc_hi_font_mask | 0xff; u32 *uni_buf =3D dest; while (nr--) { - u16 glyph =3D scr_readw(p++) & mask; + u16 glyph =3D scr_read_glyph(vc, p++); + *uni_buf++ =3D inverse_translate(vc, glyph, true); } } @@ -4920,12 +4931,9 @@ int con_font_op(struct vc_data *vc, struct console_f= ont_op *op) /* used by selection */ u16 screen_glyph(const struct vc_data *vc, int offset) { - u16 w =3D scr_readw(screenpos(vc, offset, true)); - u16 c =3D w & 0xff; + u16 *pos =3D screenpos(vc, offset, true); =20 - if (w & vc->vc_hi_font_mask) - c |=3D 0x100; - return c; + return scr_read_glyph(vc, pos); } EXPORT_SYMBOL_GPL(screen_glyph); =20 --=20 2.30.2 From nobody Fri Oct 3 12:13:04 2025 Received: from c64.rulez.org (c64.rulez.org [79.139.58.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D157442C; Mon, 1 Sep 2025 05:54:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.139.58.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756706081; cv=none; b=SW/AKKlUWclsfP9rdGOBPexp/2NoDDR/iwmQrtaBwPT90Swz3LHVrBHWy2Ov88TbvWvrMt51thdjZNMdNEj3llpwJbUcEsmoKOFBz4bAUCLPM22A3ymdOpwBPH0XQZhzs9k6HiPqkD4TFgPNBF9spHtXCPKxoZBSuUlhT04507s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756706081; c=relaxed/simple; bh=13uYvtYgIMVg7BkAxvNbTfqzRDSjeTXqFy5aviaKgsk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PCsLmUtBsC3qdmIa2pOSRAiRgzspg5DERYoN5g2zwXtaogBKVNygSKDZmBbQdTiaI2vq29n0Q0zuJmimlzhmCt3oVcOQssGI0FUy8iXnv8PRSzZTI04qyDhIboT8vPuWsAQKhBH6hp93IGWQX/1+QztFNvVfrkQ+XAMtXVAbU6w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org; spf=pass smtp.mailfrom=c64.rulez.org; arc=none smtp.client-ip=79.139.58.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c64.rulez.org Received: by c64.rulez.org (Postfix, from userid 1000) id 63B1210303; Mon, 1 Sep 2025 07:54:19 +0200 (CEST) From: Zsolt Kajtar To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: Zsolt Kajtar Subject: [PATCH v2 2/4] tty/vt: Prevent 8th bit corruption with soft cursor Date: Mon, 1 Sep 2025 07:26:34 +0200 Message-Id: <20250901052636.8981-3-soci@c64.rulez.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250901052636.8981-1-soci@c64.rulez.org> References: <20250901052636.8981-1-soci@c64.rulez.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 --- 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 19ce9c426..27b1afd5d 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -828,6 +828,7 @@ static void add_softcursor(struct vc_data *vc) { int i =3D scr_readw((u16 *) vc->vc_pos); u32 type =3D vc->vc_cursor_type; + u16 mask =3D vc->vc_hi_font_mask | 0xff; =20 if (!(type & CUR_SW)) return; @@ -841,6 +842,7 @@ static void add_softcursor(struct vc_data *vc) i ^=3D CUR_BG; if ((type & CUR_INVERT_FG_BG) && (i & CUR_FG) =3D=3D ((i & CUR_BG) >> 4)) i ^=3D CUR_FG; + i =3D (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); --=20 2.30.2 From nobody Fri Oct 3 12:13:04 2025 Received: from c64.rulez.org (c64.rulez.org [79.139.58.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0308C2459E5; Mon, 1 Sep 2025 05:54:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.139.58.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756706085; cv=none; b=mgLl4g1qhjVQYdh5Z9GnN9H194m9+unHbaVF2lgQG/ozNIWjtpu2fJQJZqBj0Z0C2H/W5c6R3KjmkjFRaV0/TT7tikQ19LuHNia9KIAzyErVcpvz6J57tC378QEJMNlvM1qF8V6xUHMQK/vehPogwsjZIk/6GFTpzWtEn/iTnHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756706085; c=relaxed/simple; bh=b+JembdX+6ybMa/4m6aMkCM7bVnvXPD1p0kwJv0g+k0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iIARYGt5md7LTiZpFh9kW2bTJBFX8rKuIanMgVUiwmAXfmYfrkwvpADsEKB3hhKbS8mPQDEWA4bHAZaHD1vfi35QNZBz/KCtmLaWxoNzAy5u+aiJHxflxi2pd75UiZf42EY+D+aaH9OppwSVyWdOHGjVAo1KFsHJ++kAqrmgeeM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org; spf=pass smtp.mailfrom=c64.rulez.org; arc=none smtp.client-ip=79.139.58.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c64.rulez.org Received: by c64.rulez.org (Postfix, from userid 1000) id 6751A10336; Mon, 1 Sep 2025 07:54:19 +0200 (CEST) From: Zsolt Kajtar To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: Zsolt Kajtar Subject: [PATCH v2 3/4] tty/vt: Fix unreadable kernel messages on vgacon Date: Mon, 1 Sep 2025 07:26:35 +0200 Message-Id: <20250901052636.8981-4-soci@c64.rulez.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250901052636.8981-1-soci@c64.rulez.org> References: <20250901052636.8981-1-soci@c64.rulez.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a 512 glyph font is loaded on vgacon and the bold attributes are in effect then the kernel console output (printk) becomes unreadable. It is because the brightness bit (used for bold) is at the same place where the 8th bit of the glyph index is. This patch adds the missing masking to ensure the output will be displayed using the lower half of the font. Signed-off-by: Zsolt Kajtar --- drivers/tty/vt/vt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 27b1afd5d..5d458211b 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -3361,7 +3361,8 @@ static void vt_console_print(struct console *co, cons= t char *b, unsigned count) continue; } vc_uniscr_putc(vc, c); - scr_writew((vc->vc_attr << 8) + c, (unsigned short *)vc->vc_pos); + scr_writew(((vc->vc_attr << 8) & ~vc->vc_hi_font_mask) | c, + (unsigned short *)vc->vc_pos); notify_write(vc, c); cnt++; if (vc->state.x =3D=3D vc->vc_cols - 1) { --=20 2.30.2 From nobody Fri Oct 3 12:13:04 2025 Received: from c64.rulez.org (c64.rulez.org [79.139.58.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A23AD239E63; Mon, 1 Sep 2025 05:54:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.139.58.36 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756706090; cv=none; b=ZgbbJJPrIfzhdiiuG8CVuThcFdH7g8uXeHSmHX2Oo9jItdVcUa7BP+EuGAblPFU/RKVgslrVu65tniw0a2Rg7dD15PsBXSKSkd2fGAoT3PEnTvhBtaUQmH0e+p29PILBNMeAnD9TzT0xaedwEhd2u0VWkVBGOfL/r14C+xhokwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756706090; c=relaxed/simple; bh=nJ9BB9Y3VY69GTDVRQiby0kbXG7hz2ESCGjLDKAqxOE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZBbyOFXgPIn+hwqFmFFbzmaK2DSCZpeDH3uLiFsZ+RkXXtzA0bxYtxdr/52wjg9valut3A2SVLIdN3Q2JFJ3sn05jbA7Sy53JGwjgDLNWxy6/a8fWNpFG/F71BlC/muXiaPRYrEFydYOiUEwHAzcsxV//twBLJPQ4afHynbUXzw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org; spf=pass smtp.mailfrom=c64.rulez.org; arc=none smtp.client-ip=79.139.58.36 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c64.rulez.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c64.rulez.org Received: by c64.rulez.org (Postfix, from userid 1000) id 6E0A110338; Mon, 1 Sep 2025 07:54:19 +0200 (CEST) From: Zsolt Kajtar To: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: Zsolt Kajtar Subject: [PATCH v2 4/4] tty/vt: use correct attribute mask in do_update_region Date: Mon, 1 Sep 2025 07:26:36 +0200 Message-Id: <20250901052636.8981-5-soci@c64.rulez.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20250901052636.8981-1-soci@c64.rulez.org> References: <20250901052636.8981-1-soci@c64.rulez.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The original code assumes all bits in the attribute byte are for attributes. If 512 glyphs are in use then one is used as the 8th bit of the glyph. This can unnecessarily split up a region of uniform attributes whenever that bit changes. Signed-off-by: Zsolt Kajtar --- drivers/tty/vt/vt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 5d458211b..eb60f69f3 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -613,22 +613,23 @@ static void do_update_region(struct vc_data *vc, unsi= gned long start, int count) { unsigned int xx, yy, offset; u16 *p =3D (u16 *)start; + u16 mask =3D 0xff00 & ~vc->vc_hi_font_mask; =20 offset =3D (start - vc->vc_origin) / 2; xx =3D offset % vc->vc_cols; yy =3D offset / vc->vc_cols; =20 for(;;) { - u16 attrib =3D scr_readw(p) & 0xff00; + u16 attrib =3D scr_readw(p) & mask; int startx =3D xx; u16 *q =3D p; while (xx < vc->vc_cols && count) { - if (attrib !=3D (scr_readw(p) & 0xff00)) { + if (attrib !=3D (scr_readw(p) & mask)) { if (p > q) vc->vc_sw->con_putcs(vc, q, p-q, yy, startx); startx =3D xx; q =3D p; - attrib =3D scr_readw(p) & 0xff00; + attrib =3D scr_readw(p) & mask; } p++; xx++; --=20 2.30.2