From: Alan Mackenzie <acm@muc.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>,
Simona Vetter <simona@ffwll.ch>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Helge Deller <deller@gmx.de>,
Thomas Zimmermann <tzimmermann@suse.de>,
linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org
Cc: acm@muc.de
Subject: [Patch 7/9]: vt: Handle up to 2^21 glyphs, rather than 256/512
Date: Thu, 27 Aug 2026 18:54:40 +0000 [thread overview]
Message-ID: <apCH8Pt7qdDjUWuW@MAC.fritz.box> (raw)
In-Reply-To: <apCEDM2sWv_M354-@MAC.fritz.box>
vt: 32b glyph: 7. Handle up to 2^21 glyphs, rather than 256/512
Replace/supplement tests for number of glyphs with the full
Unicode limits.
Signed-off-by: Alan Mackenzie <acm@muc.de>
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index 8f467b22b799..0c389a564357 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -4905,6 +4961,7 @@ void reset_palette(struct vc_data *vc)
#define max_font_width 64
#define max_font_height 128
#define max_font_glyphs 512
+#define max_font_glyphs21 0x110000
#define max_font_size (max_font_glyphs*max_font_width*max_font_height)
static int con_font_get(struct vc_data *vc, struct console_font_op *op)
@@ -4960,17 +5017,23 @@ static int con_font_set(struct vc_data *vc, const struct console_font_op *op)
if (!op->data)
return -EINVAL;
+#ifndef CONFIG_FB_GLYPH_21BIT
if (op->charcount > max_font_glyphs)
return -EINVAL;
+#else
+ if (op->charcount > max_font_glyphs21)
+ return -EINVAL;
+#endif
if (op->width <= 0 || op->width > max_font_width || !op->height ||
op->height > max_font_height)
return -EINVAL;
if (vpitch < op->height)
return -EINVAL;
size = DIV_ROUND_UP(op->width, 8) * vpitch * op->charcount;
+#ifndef CONFIG_FB_GLYPH_21BIT
if (size > max_font_size)
return -ENOSPC;
-
+#endif
void *font_data __free(kfree) = font.data = memdup_user(op->data, size);
if (IS_ERR(font.data))
return PTR_ERR(font.data);
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index 9f5c4c101581..18fbf7cf11dd 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -2331,7 +2366,9 @@ static int fbcon_get_font(struct vc_data *vc, struct console_font *font, unsigne
font->height = vc->vc_font.height;
if (font->height > vpitch)
return -ENOSPC;
- font->charcount = vc->vc_hi_font_mask ? 512 : 256;
+ font->charcount = vc->vc_font.charcount;
+ if (!font->data)
+ return 0;
return font_data_export(p->fontdata, font, vpitch);
}
@@ -2420,10 +2468,13 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,
vc->vc_font.width = w;
vc->vc_font.height = h;
vc->vc_font.charcount = charcount;
- if (vc->vc_hi_font_mask && charcount == 256)
- set_vc_hi_font(vc, false);
- else if (!vc->vc_hi_font_mask && charcount == 512)
+
+#ifndef CONFIG_FB_GLYPH_21BIT
+ if (charcount == 512 && !vc->vc_hi_font_mask)
set_vc_hi_font(vc, true);
+ else if (charcount == 256 && vc->vc_hi_font_mask)
+ set_vc_hi_font(vc, false);
+#endif
if (resize) {
int cols, rows;
@@ -2465,8 +2518,9 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,
}
/*
- * User asked to set font; we are guaranteed that charcount does not exceed 512
- * but lets not assume that, since charcount of 512 is small for unicode support.
+ * User asked to set font; we were once guaranteed that charcount did not
+ * exceed 512 but that is no longer the case, since charcount of 512 is too
+ * small for unicode support.
*/
static int fbcon_set_font(struct vc_data *vc, const struct console_font *font,
@@ -2479,10 +2533,18 @@ static int fbcon_set_font(struct vc_data *vc, const struct console_font *font,
int i, ret;
font_data_t *new_data;
- /* Is there a reason why fbconsole couldn't handle any charcount >256?
- * If not this check should be changed to charcount < 256 */
+#ifdef CONFIG_FB_GLYPH_21BIT
+ if (charcount < 256)
+ return -EINVAL;
+#else
+ /* There is no longer any reason why fbconsole can't handle
+ * any charcount >256, when CONFIG_FB_GLYPH_21BIT is #defined.
+ * Hence this check has been changed to charcount < 256
+ * above.
+ */
if (charcount != 256 && charcount != 512)
return -EINVAL;
+#endif
/* font bigger than screen resolution ? */
if (w > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) ||
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2026-08-27 18:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 18:38 vt: Enlarge the framebuffer glyph size from 16 to 32 bits Alan Mackenzie
2026-08-27 18:42 ` [Patch 1/9]: Make consolemap.c handle Unicode planes outside BMP Alan Mackenzie
2026-08-28 4:57 ` Jiri Slaby
2026-08-27 18:45 ` [Patch 2/9]: Glyph size: Use GLYPH_SZ/HW rather than hardcoded 2, 1 Alan Mackenzie
2026-08-27 18:47 ` [Patch 3/9]: Replace scr_readw/writew by scr_readg/writeg, etc Alan Mackenzie
2026-08-27 18:48 ` [Patch 4/9]: Amend internal manipulation of glyph structure Alan Mackenzie
2026-08-27 18:50 ` [Patch 5/9]: vt: Amend three Kconfig files Alan Mackenzie
2026-08-27 18:52 ` [Patch 6/9]: vt: Use u32 and typedef u1632 to handle whole glyphs Alan Mackenzie
2026-08-27 18:54 ` Alan Mackenzie [this message]
2026-08-27 18:56 ` [Patch 8/9]: vt: Enhancements to the VT ioctl interface Alan Mackenzie
2026-08-27 18:58 ` [Patch 9/9]: vt: Misc changes, e.g. to #include directives Alan Mackenzie
2026-08-28 6:12 ` vt: Enlarge the framebuffer glyph size from 16 to 32 bits Thomas Zimmermann
2026-08-28 14:36 ` Alan Mackenzie
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=apCH8Pt7qdDjUWuW@MAC.fritz.box \
--to=acm@muc.de \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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®