Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1985120lqz; Tue, 2 Apr 2024 04:03:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU62KlPFEq6wWoToliScyNSMYY7qSI9KRX8m0q+P9hH/3WfCeJgQ4DJ7hzx4MrUeIGz7q3V0YN6xn0Lht91GAhdGTokSIGNtalzbpsgaA== X-Google-Smtp-Source: AGHT+IF5vPfr07Wko/nOiSv2xAlUUTS5bu1Fr+RdKGw1iKnesiprDtvHq4dBhvtMYUP0Znj1Nw3e X-Received: by 2002:a05:620a:262a:b0:78a:a157:c5b8 with SMTP id z42-20020a05620a262a00b0078aa157c5b8mr24851054qko.31.1712055831664; Tue, 02 Apr 2024 04:03:51 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w4-20020a05620a094400b0078d33565cb3si361822qkw.154.2024.04.02.04.03.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 04:03:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127816-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=fail (body hash mismatch); spf=pass (google.com: domain of linux-kernel+bounces-127816-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127816-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4B7D41C2353E for ; Tue, 2 Apr 2024 11:03:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8312F79B87; Tue, 2 Apr 2024 11:02:26 +0000 (UTC) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8EB377F1B; Tue, 2 Apr 2024 11:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712055745; cv=none; b=MdSis70d6eUMDI5PIW6dAox/LPTK9bfJFMMNk0q8PBj9Iiam+8qYG1t8/wZanOl85ppv8br04fxAYbius39iqBWMOuGC5JXmTvnUjyKTWYqAM/P1I0c038N2gg5nDz7XSdALk5ieArmLfMSxHYQYGTXxfN1U2izKWjxL7sjJXnU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712055745; c=relaxed/simple; bh=syS53TaP5xr+RBfcVafSpph7BiRYEvMuSuViwqVPUAs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ERiuDWOnlBtrKRKePtfgeOpbc4H7CEia+36S+39DFYS9iW/UQIHbL9UgZ70v4hD5i7MPwMUuH4LnJMI7l5jXq7vEwa+XSea2BcE1ly0JDWVBZcqy6E+QD9VikYin5u52N/4Mjg5hqg/y5xs/EhYkFV1qyAQJv9h727XhRzxnhr4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-415584360c0so18263695e9.1; Tue, 02 Apr 2024 04:02:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712055742; x=1712660542; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Io4rbOkovnV2rRCmQ11vxGTzUj5kuj9+rol3bt/mr48=; b=Yy+9wn+yqvUIKvWiMi6F4wShKEDhgHZntROLVlyS4nf1OZHScaLNQgtuHyTQc224u0 fRaDZXadSTLQzCXXDOuaLiVNWjMl3fg2mWfzRduT6wAeTP9FAVIKTdGl+X6eNj9pVsyQ LP1vSh28tJr587FCZhRHWdLGKpJxL0n4tdqdrtEaWWc9uEim4t4NnXtaQThU+PKIdpMr qOIH1Ja2+70xcOy1UllgUNUGCcJA45B/J/j1h5R4+RU0XZ9rQ8N0mHKFHcyN403EEBfQ WX9fpE/pLhoFat1y2hQJ2wQIveUEImj5MHYM734+Z9Y/JSyvjKQJO8C0AbcOhRqiav5D AuRw== X-Forwarded-Encrypted: i=1; AJvYcCX7WdiXDZVnuJsHW4zah8bYEb0XyVoKzq087hDuFnGDgj1SXddiLrkHq3R2zlT0Y+4dJnLKaTr0byJcBQsei2Q+m8ZI4sFaiHsUCSGLcq9GUeX/ifEIA9VQVpfqlCZNvyxyNHBW2xw1PkqUhFt08rfIn1iblQazc5bKTUU71jRCqI0mXOw= X-Gm-Message-State: AOJu0YwMHAzpSzxkXUt32+3Ar37Mk/Y+pIeOdcz4esAHfJTAMyfCuDP5 AF8krJcTB4xE8XEYkKtWpd9SiXCgJbEISaKIMjGXubgZmQ2wz/9Y/XwHfrZvm1U= X-Received: by 2002:a05:6000:1562:b0:343:39ef:53b0 with SMTP id 2-20020a056000156200b0034339ef53b0mr9835351wrz.24.1712055742012; Tue, 02 Apr 2024 04:02:22 -0700 (PDT) Received: from ?IPV6:2a0b:e7c0:0:107::aaaa:69? ([2a0b:e7c0:0:107::aaaa:69]) by smtp.gmail.com with ESMTPSA id dn2-20020a0560000c0200b0033e25c39ac3sm13889079wrb.80.2024.04.02.04.02.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Apr 2024 04:02:21 -0700 (PDT) Message-ID: <74ca50e0-61b1-4d4c-85dd-a5d920548c04@kernel.org> Date: Tue, 2 Apr 2024 13:02:20 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RESEND PATCH v3 1/2] VT: Add KDFONTINFO ioctl To: Alexey Gladkov , Greg Kroah-Hartman Cc: LKML , kbd@lists.linux.dev, linux-api@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-serial@vger.kernel.org, Helge Deller References: Content-Language: en-US From: Jiri Slaby Autocrypt: addr=jirislaby@kernel.org; keydata= xsFNBE6S54YBEACzzjLwDUbU5elY4GTg/NdotjA0jyyJtYI86wdKraekbNE0bC4zV+ryvH4j rrcDwGs6tFVrAHvdHeIdI07s1iIx5R/ndcHwt4fvI8CL5PzPmn5J+h0WERR5rFprRh6axhOk rSD5CwQl19fm4AJCS6A9GJtOoiLpWn2/IbogPc71jQVrupZYYx51rAaHZ0D2KYK/uhfc6neJ i0WqPlbtIlIrpvWxckucNu6ZwXjFY0f3qIRg3Vqh5QxPkojGsq9tXVFVLEkSVz6FoqCHrUTx wr+aw6qqQVgvT/McQtsI0S66uIkQjzPUrgAEtWUv76rM4ekqL9stHyvTGw0Fjsualwb0Gwdx ReTZzMgheAyoy/umIOKrSEpWouVoBt5FFSZUyjuDdlPPYyPav+hpI6ggmCTld3u2hyiHji2H cDpcLM2LMhlHBipu80s9anNeZhCANDhbC5E+NZmuwgzHBcan8WC7xsPXPaiZSIm7TKaVoOcL 9tE5aN3jQmIlrT7ZUX52Ff/hSdx/JKDP3Y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ILm330mkR4g W6nEgZVyIyTq3ekOuruftWL99qpP5zi+eNrMmLRQx9iecDNgFr342R9bTDlb1TLuRb+/tJ98 f/bIWIr0cqQmqQ33FgRhrG1+Xml6UXyJ2jExmlO8JljuOGeXYh6ZkIEyzqzffzBLXZCujlYQ DFXpyMNVJ2ZwPmX2mWEoYuaBU0JN7wM+/zWgOf2zRwhEuD3A2cO2PxoiIfyUEfB9SSmffaK/ S4xXoB6wvGENZ85Hg37C7WDNdaAt6Xh2uQIly5grkgvWppkNy4ZHxE+jeNsU7tg= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 > 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? > + 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. > +#define KD_FONT_INFO_FLAG_LOW_SIZE (1U << 0) /* 256 */ > +#define KD_FONT_INFO_FLAG_HIGH_SIZE (1U << 1) /* 512 */ _BITUL() > +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. > +}; thanks, -- js suse labs