Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2074218lqz; Tue, 2 Apr 2024 06:41:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU36hKdKblWrhaqzV0hfR157kxQ91CD5yEP0Iy/7aXZ5vSnVGbdmLPrbEqa1LxLlwATDWq2iaBL/uIiJlUIXtcXHUFkCr+O1zYI5dtn4Q== X-Google-Smtp-Source: AGHT+IFsxU0D7ezdoqcvtNh2jZqyX6LtVry/ddCJrrytxtgGtCooKOJM7vk8drMi2fiDQlFqk5kX X-Received: by 2002:a05:6a20:e605:b0:1a3:dd15:dacb with SMTP id my5-20020a056a20e60500b001a3dd15dacbmr13495665pzb.52.1712065275797; Tue, 02 Apr 2024 06:41:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712065275; cv=pass; d=google.com; s=arc-20160816; b=QrfDxkl9tOOhjJb3py2U26fLSTtc3i4LcU58j174l42T7peNO3OvtEc+asR5xtJ0gJ ZuYSb2PmG0Kgcqf124pQQe7T6NGEIPHIYh3nFWX9YzCRx11v1lVRwRQMEBO+Gm6hib1b SDvL29NGbF4lDKHukIFCePRtWnapdJ5ndACD9kTsIS9hrbouBO4W/E9p5TdyWlp/ZK0i OipaV6cQuwIGmicr0NIN3genb8ateMrLm7nd3JqgxFys6wIcBdjBzfOrOY/kxPFRIC3y bDS92yFsthrceRrh/7uP918sj2h77Jk5zRKSWAsvmrPXILXRK/tXIUO0N4WZobIvVwit amNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1uthWmK1crl+ABT5CNHV3ZKCYbbT5i61IlQyhvT2bXM=; fh=fffhgQomylnSOy2yviDX1N9EZYOf5kPGCLJwk77+9H0=; b=vrIs4YDNj59davZH3MlItygXxEMN6PjRdCPkH1zBgNVu9gUaCFbq4v32yFS7xGDd0M K0eNBMwQe0YVlNNY3Wa7iOsfKDuKco3/qU9pds0FHidrnQR9+S6vxveWKb1tR5PtJM1x 391ARkO2LvdskX+LmY/rn9hm22U9N9F7V7mLAHmTZMmQO5ZRa5fZutTfhZhk3xbC/L60 cU3UWuiC5rbzUkszWRvyFEXu8RR50tMDRjbF4hOExBX5x/H1VJrkhxhwMRj+zVfk/5ac DhF3rvs/+4ZJnNFfvWHIKlX1azdThcvhlUCev/4QMUOqOhltSOPoRrE1puBaupv6x1wg cIPA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MwXOKwDD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-128027-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128027-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id z15-20020aa791cf000000b006ead18b0c3bsi10732072pfa.392.2024.04.02.06.41.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 06:41:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-128027-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MwXOKwDD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-128027-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-128027-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2A2962864FD for ; Tue, 2 Apr 2024 13:19:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D914883CBD; Tue, 2 Apr 2024 13:19:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MwXOKwDD" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D471C8062A; Tue, 2 Apr 2024 13:19:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712063989; cv=none; b=ckOkC0VKLtTLG9zZNW2r0GDGIuMY2lftj1PWvokDYZlLc1UGmcd0wV3Nh8ISFk0D8ZSTJ8bynMjOBfK3Nd+RZmsnWcwWeehmzrkz4BuPszRxyoSOjufLKMbvxIhqn4fX4q/3Ofi/uwbFkPn5h8nUrACVNG/JxXpy5O5UtwE8eYg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712063989; c=relaxed/simple; bh=6D05Yya3KxK0OkWkNXVX0Mp3DXfWGd2Ns0Ca9ovdfaw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=reVBf5iEw0F8eFHbyJp5nBkjllSnp+qvML/xJ02FEoWyhrE0zNG7fSGVOr/RePAbuTelviO3mkEMkjEdn5DNn1eW7y1KaHhxtxsflBh3LESYU+eqmEA+dAsosfbanDMdL/wnelL8tN9mtSYoxlq6IgC4HN+IaxA6UZdUTKLxKIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MwXOKwDD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EAE6C43390; Tue, 2 Apr 2024 13:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712063988; bh=6D05Yya3KxK0OkWkNXVX0Mp3DXfWGd2Ns0Ca9ovdfaw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MwXOKwDDFThNQSSdwFoyIDPuzphqyMHtPg1wzAPeJNlw7LZilwgpYtOb5qPMLjVpV CYUxFWbal2HMJeC93LtARxsmlb6Xu2PACLlFnYHIjXWlmS6M7tWn5kMUJ+qupt3FAv U7fR66IQmSw/jK5b6N9x64B8O/rca4SOIhBepo5bAO1g9f+6nUpApx/hJ1JlMQAnFk Vt3XjdtRfWGVvAnfqY43tgY9tNw2FLYYI90+yZA41lRIHs5PSTjZn1p04QirVPulpo cI7UT62Ym4BcKJKH4D826Xqw5qw7ekg3r8hSuDN2oigtUp8rACw2FP0YND2Aex/qpZ aRT7q6NBPsanQ== Date: Tue, 2 Apr 2024 15:19:43 +0200 From: Alexey Gladkov To: Jiri Slaby Cc: Greg Kroah-Hartman , LKML , kbd@lists.linux.dev, linux-api@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-serial@vger.kernel.org, Helge Deller Subject: Re: [RESEND PATCH v3 1/2] VT: Add KDFONTINFO ioctl Message-ID: References: <74ca50e0-61b1-4d4c-85dd-a5d920548c04@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <74ca50e0-61b1-4d4c-85dd-a5d920548c04@kernel.org> On Tue, Apr 02, 2024 at 01:02:20PM +0200, Jiri Slaby wrote: > Hi, > > On 02. 04. 24, 12:32, Alexey Gladkov wrote: > > Each driver has its own restrictions on font size. There is currently no > > way to understand what the requirements are. The new ioctl allows > > userspace to get the minmum and maximum font size values. > > minimum Typo. Sorry. > > Acked-by: Helge Deller > > Signed-off-by: Alexey Gladkov > > --- > > drivers/tty/vt/vt.c | 24 ++++++++++++++++++++++++ > > drivers/tty/vt/vt_ioctl.c | 13 +++++++++++++ > > include/linux/console.h | 2 ++ > > include/linux/vt_kern.h | 1 + > > include/uapi/linux/kd.h | 13 ++++++++++++- > > 5 files changed, 52 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c > > index 156efda7c80d..8c2a3d98b5ec 100644 > > --- a/drivers/tty/vt/vt.c > > +++ b/drivers/tty/vt/vt.c > > @@ -4680,6 +4680,30 @@ int con_font_op(struct vc_data *vc, struct console_font_op *op) > > return -ENOSYS; > > } > > > > +int con_font_info(struct vc_data *vc, struct console_font_info *info) > > +{ > > + int rc = -EINVAL; > > This initialization appears to be unneeded. > > > + > > + info->min_height = 0; > > + info->max_height = max_font_height; > > + > > + info->min_width = 0; > > + info->max_width = max_font_width; > > + > > + info->flags = KD_FONT_INFO_FLAG_LOW_SIZE | KD_FONT_INFO_FLAG_HIGH_SIZE; > > + > > + console_lock(); > > + if (vc->vc_mode != KD_TEXT) > > + rc = -EINVAL; > > + else if (vc->vc_sw->con_font_info) > > + rc = vc->vc_sw->con_font_info(vc, info); > > + else > > + rc = -ENOSYS; > > + console_unlock(); > > + > > + return rc; > > +} > > + > > /* > > * Interface exported to selection and vcs. > > */ > > diff --git a/drivers/tty/vt/vt_ioctl.c b/drivers/tty/vt/vt_ioctl.c > > index 8c685b501404..b3b4e4b69366 100644 > > --- a/drivers/tty/vt/vt_ioctl.c > > +++ b/drivers/tty/vt/vt_ioctl.c > > @@ -479,6 +479,19 @@ static int vt_k_ioctl(struct tty_struct *tty, unsigned int cmd, > > break; > > } > > > > + case KDFONTINFO: { > > + struct console_font_info fnt_info; > > + > > + if (copy_from_user(&fnt_info, up, sizeof(fnt_info))) > > + return -EFAULT; > > Who uses the copied values? No one. I did it by analogy with KDFONTOP. Thanks! > > + ret = con_font_info(vc, &fnt_info); > > + if (ret) > > + return ret; > > + if (copy_to_user(up, &fnt_info, sizeof(fnt_info))) > > We should do the preferred sizeof(*up) here... > > > + return -EFAULT; > > + break; > > + } > > + > > default: > > return -ENOIOCTLCMD; > > } > ... > > --- a/include/uapi/linux/kd.h > > +++ b/include/uapi/linux/kd.h > > @@ -183,8 +183,19 @@ struct console_font { > > > > #define KD_FONT_FLAG_DONT_RECALC 1 /* Don't recalculate hw charcell size [compat] */ > > > > +#define KDFONTINFO 0x4B73 /* font information */ > > Why not properly define the number using IOC() et al.? K (that 0x4b) is > even reserved for kd.h. I just did the same as the numbers above. This entire header does not use IOC(). Should I convert this header as a separate commit? > > +#define KD_FONT_INFO_FLAG_LOW_SIZE (1U << 0) /* 256 */ > > +#define KD_FONT_INFO_FLAG_HIGH_SIZE (1U << 1) /* 512 */ > > _BITUL() Make sense. I will use it. > > +struct console_font_info { > > + unsigned int min_width, min_height; /* minimal font size */ > > + unsigned int max_width, max_height; /* maximum font size */ > > + unsigned int flags; /* KD_FONT_INFO_FLAG_* */ > > This does not look like a well-defined™ and extendable uapi structure. > While it won't change anything here, still use fixed-length __u32. > > And you should perhaps add some reserved fields. Do not repeat the same > mistakes as your predecessors with the current kd uapi. I thought about it, but I thought it would be overengineering. Can you suggest how best to do this? -- Rgrds, legion