Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp911700imm; Wed, 22 Aug 2018 15:02:55 -0700 (PDT) X-Google-Smtp-Source: AA+uWPykiAm0x4ZrrxzKhblOCNBAGw0fBYRwC95VKV9tyMTCg42y70nHlz8LrEzhkGo5o/3QVLvF X-Received: by 2002:a62:dbc5:: with SMTP id f188-v6mr60419189pfg.182.1534975375526; Wed, 22 Aug 2018 15:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534975375; cv=none; d=google.com; s=arc-20160816; b=XAqEUmxMXgiWy22Ss42SBY/pcH2uaCQPjBBzNHN+04pWU9t3CIdcw0XVTyslbw5jLW z3qiUiTa/kn0UeuhmHAznMgUUAkxf1G5v7GppLwucWhof5YEatW7BBnPmjnceb/vIZb9 8PHqfGIb7IQn5cS9+YJVzs8fOYPfw3uIxsNSb8XHFbYbo4ooySrenIQQ7W27EQnLreH1 Ip5kl8Q9uHfdDydss/iXGFbZG5EyYv6IDD/8UVN8URdjGJNW3DAGptXprOSz6ybnr8kG D1Oh6syBEGk5XBqONHo/IAJSX3mOoPKfU86BsscHjwaaUJA1w1DTVBLFC7kISg56kCN4 gTIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=LsxxHa18mz2oWI6R+30+7J0oupS0pZW9VDBn0Es5VeU=; b=RV4FUdfJ6EuWb4JErmIUgA+sO8WqEU/Z6/IgJIUNOR2WPNax0mIYxG1+SqqCz8UNVG b/Ewd/solJ94jukWbnl/7nf9n2Fb8mrx5gLCodHEj5tFeZIFkdRK5m/4GV0WSae9rG1I Rahd9GfyuL8HbAPeUr1f7sgCoIxFVysVWQ5S5wO9TXzdlo4/adeqc509HcHLgN8Zb2qb FwVMI2ZhIeaIptqJSDUSuEcfHqqG/C9ZS/kQzXL2wpMLxU8m0AJIAbz4ToSAznbPjCnt 3dHr9s0vpxAmQ/fPo7B6yvY7MwwHItLKyFlKdz7JxrEU0xVVlrEFJ3FQvxRWgtfDfVey UHXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d70-v6si2730624pfd.114.2018.08.22.15.02.40; Wed, 22 Aug 2018 15:02:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728044AbeHWB0v (ORCPT + 99 others); Wed, 22 Aug 2018 21:26:51 -0400 Received: from mslow2.mail.gandi.net ([217.70.178.242]:32876 "EHLO mslow2.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727355AbeHWB0v (ORCPT ); Wed, 22 Aug 2018 21:26:51 -0400 Received: from relay1-d.mail.gandi.net (unknown [217.70.183.193]) by mslow2.mail.gandi.net (Postfix) with ESMTP id 8EBE53A5AB2 for ; Wed, 22 Aug 2018 23:43:14 +0200 (CEST) X-Originating-IP: 88.190.179.123 Received: from localhost (unknown [88.190.179.123]) (Authenticated sender: repk@triplefau.lt) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 4D353240004; Wed, 22 Aug 2018 21:43:11 +0000 (UTC) From: Remi Pommarel To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Jiri Slaby , Alexander Viro , Kees Cook , Elie Roudninski , Remi Pommarel Subject: [RFC PATCH 0/4] Add specific vt input's key map Date: Wed, 22 Aug 2018 23:50:31 +0200 Message-Id: X-Mailer: git-send-email 2.18.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patchset adds a way to have a specific keyboard config (i.e. keycode to keysym map) for a vt attached input. Because one can have different keyboards with different layouts on the same VT, it can be useful to be able to associate a different keymap with a different input. In order to do so this patchset introduces three new ioctls: 1) KDGKBIENT Get an input key map's entry. If the input does not have a specific key map the requested entry is fetched from global key map. 2) KDSKBIENT Set an input key map's entry. If the input does not yet have a specific key map, a new one is created with the current global key map content copied in. 3) KDSKBIRST Reset an input key map. The input does not use a specific key map anymore and keycode translations are done with global key map. In order to keep old behavior compatibility and not waste memory, an input uses the global key_maps[] array by default and KDGKBENT/KDSKBENT ioctls still get/set entries in this global key map. The specific key map is only allocated on the first call to KDSKBIENT. A patch for loadkeys is ready to be sent to the ML if this patchset seems sane to you. Here are some questions I had while doing this patchset: - Maybe there is a way, I am not aware of, that can allow one to use different keyboard layout on same VT ? - Is it ok to add new ioctl to old legacy code ? I added those ioctl the old way in order to match the header style. Maybe it is better to use the __IO* macros ? - Should key_down bitmap be really input specific (i.e. PATCH 3/4) ? - I am not quite sure about the meaning of keymap_count. IIUC, it is a counter of used keymap function arrays statically or dynamically allocated. If it is not the case, the modificiation in kc_setent() that decrements keymap_count even if a statically keymap function is removed with "K_NOSUCHMAP" (in PATCH 2/4) may be wrong ? - kbd_detach_conf is a bit clumsy because it tries to copy a shared sparse pointer array without using GFP_ATOMIC. - Is this patchset even a sensible idea ? Remi Pommarel (4): drivers/tty/vt/keyboard.c: refactor getting/setting a keymap entry drivers/tty/vt/keyboard.c: add keyboard config for each vt's input drivers/tty/vt/keyboard.c: Make key_down[] bitmap input dependent drivers/tty/vt: add ioctl to manage input specific keyboard configs drivers/tty/vt/keyboard.c | 531 ++++++++++++++++++++++++++++++-------- drivers/tty/vt/vt_ioctl.c | 9 + fs/compat_ioctl.c | 3 + include/linux/vt_kern.h | 4 + include/uapi/linux/kd.h | 9 + 5 files changed, 452 insertions(+), 104 deletions(-) -- 2.18.0