Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1394341rwj; Sun, 18 Dec 2022 07:26:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5J8hpFca+iawTWin7N1XiGRZXIl+NhpLFigVwDx1Brnth07jw/6zvl89JhaFcRj6WWphbZ X-Received: by 2002:aa7:d4cb:0:b0:46d:35f6:5a9b with SMTP id t11-20020aa7d4cb000000b0046d35f65a9bmr29103740edr.24.1671377196970; Sun, 18 Dec 2022 07:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671377196; cv=none; d=google.com; s=arc-20160816; b=zZ8FQ6yrrMdbA3+uBpgP9T39XK/bzI28FpJSVCcg4uuZ+6uJDlzLHajUfMcxGX/5T6 t4Ck7xxfV196lLa2WG+ClsTmjLsitMe/O9kRx754WwsfzCAy85jDE46+U52Nmla4DwIC STFDYTJardVqGLkzlI9r8xiLijqTf3hBGJLJIqg2X/TIwFdwvjSPFgbhP95Me1LcWpyt TdJksCKtPIxY89z97o0DJ8Lu+myhKtDbIpjEcWtDS4T860V9RrRnD+Z+hdmt2pieP8gQ 1VheZapNvH/1NOjoiqZg3mjmURjUG7TurUAxSTaOSJ8cw0OzC3OYj39n6zJFQhW6dclj ZLcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Vlo89W7jNmeirwBxtVtXH3P8zy+OoPwII3z5z5OuZvs=; b=bAAyoqf3xJyTHtzvIx+zz8FbxO5M+/BGh+zFgLoVmtZP4EYEy3GKKVvNgnyZnZbvSR 2c1OUSSbw/WGiUSCbE+AdgTcF2P4dQVsW8zjumNXUZSWF6aN+ocivyYVvLsneH1wp7Ma huneh0dn0R5z7xYMw2OmFWVtrmvV51/cQJt6laagZBjjjDM+Ag0q21CenrpOf4UyTwd7 1SwL2B2oF4q10YnCwdx6c2vfjQVthHhipvMya22uuNdPKZymxbk/1vDIEAmmmM1k+q1H /Fibts1jwSIDu4t5E1HBcMaSSnuieUpUR9OPEds9umlCOJaz61PvyXwG/uLh/ossOwgM lEmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EPelM1UB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a056402151000b0046b692e8c79si6351248edw.610.2022.12.18.07.26.19; Sun, 18 Dec 2022 07:26:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EPelM1UB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230251AbiLROjs (ORCPT + 71 others); Sun, 18 Dec 2022 09:39:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbiLROjq (ORCPT ); Sun, 18 Dec 2022 09:39:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAA9B65CA for ; Sun, 18 Dec 2022 06:39:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8654F60D34 for ; Sun, 18 Dec 2022 14:39:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92CC1C433EF; Sun, 18 Dec 2022 14:39:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671374383; bh=nXWI4NnPj2evLqQogx54Y6YnlZ05bcN4H6W54oI+B14=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EPelM1UBbt6zo1O+xsJFsUJe2nR96ebNUDshAgwXWubP6AUWwkHLHMazP4AXX2xU3 B4V+9CpL5R5k6QwfT610jNxAQ5v9ehLkDVxv5WWuNRP361vaUapKEy+B/8ONLqn1fY fX/RnZguGkyy/RuirUYbUffsFvN87j5VrKR+76zj4WsGvIfwE7yPeyaLv5H0+1bvDY L7B87jxn2BuBafPwRRYgTc24aby8alQ2fb0W5A98tP69BQMsMU0uW/pwFw45p/gRDa pr/WLDyOe+CzFpqlfW/FxG+JWLE48RgP3ygc9omD2vWABbEn0b07nF7nlF70V1HO+s 0PUogyaOkYDoQ== Date: Sun, 18 Dec 2022 15:39:38 +0100 From: Alexey Gladkov To: Samuel Thibault Cc: Greg Kroah-Hartman , Jiri Slaby , kbd@lists.altlinux.org, linux-kernel@vger.kernel.org Subject: Re: [kbd] [patchv2 3/3] VT: Bump font size limitation to 64x128 pixels Message-ID: References: <20221218003209.503539532@ens-lyon.org> <20221218003237.503424466@ens-lyon.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221218003237.503424466@ens-lyon.org> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 18, 2022 at 01:32:12AM +0100, Samuel Thibault wrote: > This moves 32x32 font size limitation checking down to drivers, so that > fbcon can allow large fonts. > > We still keep a limitation to 64x128 pixels so as to have a simple bounded > allocation for con_font_get and in the userland kbd tool. That glyph size > will however be enough to have 128x36 characters on a "16/9 8K display". > > Signed-off-by: Samuel Thibault > > --- > V1 -> V2: Switch con_font_get to kvmalloc/kvfree instead of kmalloc/kfree > > Index: linux-6.0/drivers/tty/vt/vt.c > =================================================================== > --- linux-6.0.orig/drivers/tty/vt/vt.c > +++ linux-6.0/drivers/tty/vt/vt.c > @@ -4575,17 +4575,20 @@ void reset_palette(struct vc_data *vc) > /* > * Font switching > * > - * Currently we only support fonts up to 32 pixels wide, at a maximum height > - * of 32 pixels. Userspace fontdata is stored with 32 bytes (shorts/ints, > - * depending on width) reserved for each character which is kinda wasty, but > - * this is done in order to maintain compatibility with the EGA/VGA fonts. It > - * is up to the actual low-level console-driver convert data into its favorite > - * format (maybe we should add a `fontoffset' field to the `display' > - * structure so we won't have to convert the fontdata all the time. > + * Currently we only support fonts up to 128 pixels wide, at a maximum height > + * of 128 pixels. Userspace fontdata may have to be stored with 32 bytes > + * (shorts/ints, depending on width) reserved for each character which is > + * kinda wasty, but this is done in order to maintain compatibility with the > + * EGA/VGA fonts. It is up to the actual low-level console-driver convert data > + * into its favorite format (maybe we should add a `fontoffset' field to the > + * `display' structure so we won't have to convert the fontdata all the time. > * /Jes > */ > > -#define max_font_size 65536 > +#define max_font_width 64 > +#define max_font_height 128 > +#define max_font_glyphs 512 > +#define max_font_size (max_font_glyphs*max_font_width*max_font_height) As a suggestion that you can safely ignore. Maybe make max_font_glyphs a sysctl parameter to be able to use larger fonts ? I get requests from time to time in kbd that it is not possible to load a larger font. > static int con_font_get(struct vc_data *vc, struct console_font_op *op) > { > @@ -4595,7 +4598,7 @@ static int con_font_get(struct vc_data * > unsigned int vpitch = op->op == KD_FONT_OP_GET_TALL ? op->height : 32; > > if (op->data) { > - font.data = kmalloc(max_font_size, GFP_KERNEL); > + font.data = kvmalloc(max_font_size, GFP_KERNEL); > if (!font.data) > return -ENOMEM; > } else > @@ -4630,7 +4633,7 @@ static int con_font_get(struct vc_data * > rc = -EFAULT; > > out: > - kfree(font.data); > + kvfree(font.data); > return rc; > } > > @@ -4645,9 +4648,10 @@ static int con_font_set(struct vc_data * > return -EINVAL; > if (!op->data) > return -EINVAL; > - if (op->charcount > 512) > + if (op->charcount > max_font_glyphs) > return -EINVAL; > - if (op->width <= 0 || op->width > 32 || !op->height || op->height > 32) > + if (op->width <= 0 || op->width > max_font_width || !op->height || > + op->height > max_font_height) > return -EINVAL; > if (vpitch < op->height) > return -EINVAL; > Index: linux-6.0/drivers/usb/misc/sisusbvga/sisusb_con.c > =================================================================== > --- linux-6.0.orig/drivers/usb/misc/sisusbvga/sisusb_con.c > +++ linux-6.0/drivers/usb/misc/sisusbvga/sisusb_con.c > @@ -1203,7 +1203,7 @@ sisusbcon_font_set(struct vc_data *c, st > struct sisusb_usb_data *sisusb; > unsigned charcount = font->charcount; > > - if (font->width != 8 || vpitch != 32 || > + if (font->width != 8 || font->height > 32 || vpitch != 32 || > (charcount != 256 && charcount != 512)) > return -EINVAL; > > Index: linux-6.0/drivers/video/console/vgacon.c > =================================================================== > --- linux-6.0.orig/drivers/video/console/vgacon.c > +++ linux-6.0/drivers/video/console/vgacon.c > @@ -1037,7 +1037,7 @@ static int vgacon_font_set(struct vc_dat > if (vga_video_type < VIDEO_TYPE_EGAM) > return -EINVAL; > > - if (font->width != VGA_FONTWIDTH || vpitch != 32 || > + if (font->width != VGA_FONTWIDTH || font->height > 32 || vpitch != 32 || > (charcount != 256 && charcount != 512)) > return -EINVAL; > > Index: linux-6.0/drivers/video/fbdev/core/fbcon.c > =================================================================== > --- linux-6.0.orig/drivers/video/fbdev/core/fbcon.c > +++ linux-6.0/drivers/video/fbdev/core/fbcon.c > @@ -2279,6 +2279,8 @@ static int fbcon_get_font(struct vc_data > > font->width = vc->vc_font.width; > font->height = vc->vc_font.height; > + if (font->height > vpitch) > + return -ENOSPC; > font->charcount = vc->vc_hi_font_mask ? 512 : 256; > if (!font->data) > return 0; > > _______________________________________________ > kbd mailing list > kbd@lists.altlinux.org > https://lists.altlinux.org/mailman/listinfo/kbd > -- Rgrds, legion