Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3061629imu; Mon, 19 Nov 2018 10:03:39 -0800 (PST) X-Google-Smtp-Source: AJdET5e0LxnzZUmpJdb40jJY8HXG6ngUeO3GL94F8tno/VOPady4a77K48NScFCrzoBgoKMtL6Ke X-Received: by 2002:a17:902:868b:: with SMTP id g11-v6mr20412237plo.96.1542650619058; Mon, 19 Nov 2018 10:03:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542650619; cv=none; d=google.com; s=arc-20160816; b=NUxMScW3MWddQ3ybKeoLE6Ji+Q9tqRu0+tclaxmCo5tJgpEh9K8Y3W7NuCeRbwPp2G x1jGe+LCPqU+R70NltHjndZwDCC6M26YTN2XVtK7SOwhhhWHkTWQ0fMF0U3a6XZ+jYzd mHls1DZ8RlwEvkcCq0pX8x07CRP7j4WXryvZB9uuYlzviNfKSzWmN56wwizIEEEVDUTQ JbMi8TXJMrAZI76DGyd4IIbuzsw1aw+1VaxQez+b0KRkbGtXqbgwbSxueA/IlfhXnKU1 W1cE6BJ2OGVbmyDqgTDhPe8Rjn0JgBpGoDDSmOx7KGA6u1YQymGcEUKY2uIHZE0/nRH4 3j8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FbQYJYELw0MqrP3GFZPjGI20keNH+eEEwQBoX23/n64=; b=BMCFBMRfvkAnFNwBYBu99+Hwj9kRmTQDwMJtf98AY3BwUhQd8La/asooF9Ha3dQVC2 11Xng4TTZGCBomfiNJoqnWVy6yfdzZrMQL65vziq/ECkGsHcD9x02YAR0ccqn/lz8v/d uUPAgF3/jSiaNdMm6tJKIXuVxNsnzoFR9V/yBWUFDN8/hwG+0TEGFqnvLOfkV8xVFZwx 4RgwaD7JOzHdMZNFMCgbrMTpg6TFNy5WPmXdu4fBmgr0lOTN0guCAjL2GkI33QtZJpKF ged2bC/xsCmAWMvrFBJKzVMpoDjpwjO5Gtg/qKWWkwx/+1asQK6RJ9O+3iMNFPPILYzu x5DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bRaQRr9+; 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 i5si12843352pgg.279.2018.11.19.10.03.03; Mon, 19 Nov 2018 10:03:39 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=bRaQRr9+; 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 S1731650AbeKTC7c (ORCPT + 99 others); Mon, 19 Nov 2018 21:59:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:59026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730350AbeKTC7c (ORCPT ); Mon, 19 Nov 2018 21:59:32 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 51E972146D; Mon, 19 Nov 2018 16:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645322; bh=+BarRwKgBdNSh3WSeaBQOh5xV7ETk03+4+0ctVw0+9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bRaQRr9+REQuQ2SlUMSObQakUXH1kAU+oJ9Ua0XCssp/LIevBGMVkHu8Q29Uw2IQL OvZWl38SsbXYyPFfg1jFCr2XQmELT/YznVm2ibAhB8u50vVurV3qDrFJ1WxrRIpo0p Y6XoSQ0ZD/z3kJP8vEUtN4/F4sbB/pg69kZ2d9oQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "H. Peter Anvin (Intel)" , Jiri Slaby , Al Viro , Richard Henderson , Ivan Kokshaysky , Matt Turner , Thomas Gleixner , Kate Stewart , Philippe Ombredanne , Eugene Syromiatnikov , linux-alpha@vger.kernel.org, linux-serial@vger.kernel.org, Johan Hovold , Alan Cox Subject: [PATCH 4.19 121/205] arch/alpha, termios: implement BOTHER, IBSHIFT and termios2 Date: Mon, 19 Nov 2018 17:27:08 +0100 Message-Id: <20181119162636.039331082@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: H. Peter Anvin (Intel) commit d0ffb805b729322626639336986bc83fc2e60871 upstream. Alpha has had c_ispeed and c_ospeed, but still set speeds in c_cflags using arbitrary flags. Because BOTHER is not defined, the general Linux code doesn't allow setting arbitrary baud rates, and because CBAUDEX == 0, we can have an array overrun of the baud_rate[] table in drivers/tty/tty_baudrate.c if (c_cflags & CBAUD) == 037. Resolve both problems by #defining BOTHER to 037 on Alpha. However, userspace still needs to know if setting BOTHER is actually safe given legacy kernels (does anyone actually care about that on Alpha anymore?), so enable the TCGETS2/TCSETS*2 ioctls on Alpha, even though they use the same structure. Define struct termios2 just for compatibility; it is the exact same structure as struct termios. In a future patchset, this will be cleaned up so the uapi headers are usable from libc. Signed-off-by: H. Peter Anvin (Intel) Cc: Jiri Slaby Cc: Al Viro Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: Thomas Gleixner Cc: Kate Stewart Cc: Philippe Ombredanne Cc: Eugene Syromiatnikov Cc: Cc: Cc: Johan Hovold Cc: Alan Cox Cc: Signed-off-by: Greg Kroah-Hartman --- arch/alpha/include/asm/termios.h | 8 +++++++- arch/alpha/include/uapi/asm/ioctls.h | 5 +++++ arch/alpha/include/uapi/asm/termbits.h | 17 +++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) --- a/arch/alpha/include/asm/termios.h +++ b/arch/alpha/include/asm/termios.h @@ -73,9 +73,15 @@ }) #define user_termios_to_kernel_termios(k, u) \ - copy_from_user(k, u, sizeof(struct termios)) + copy_from_user(k, u, sizeof(struct termios2)) #define kernel_termios_to_user_termios(u, k) \ + copy_to_user(u, k, sizeof(struct termios2)) + +#define user_termios_to_kernel_termios_1(k, u) \ + copy_from_user(k, u, sizeof(struct termios)) + +#define kernel_termios_to_user_termios_1(u, k) \ copy_to_user(u, k, sizeof(struct termios)) #endif /* _ALPHA_TERMIOS_H */ --- a/arch/alpha/include/uapi/asm/ioctls.h +++ b/arch/alpha/include/uapi/asm/ioctls.h @@ -32,6 +32,11 @@ #define TCXONC _IO('t', 30) #define TCFLSH _IO('t', 31) +#define TCGETS2 _IOR('T', 42, struct termios2) +#define TCSETS2 _IOW('T', 43, struct termios2) +#define TCSETSW2 _IOW('T', 44, struct termios2) +#define TCSETSF2 _IOW('T', 45, struct termios2) + #define TIOCSWINSZ _IOW('t', 103, struct winsize) #define TIOCGWINSZ _IOR('t', 104, struct winsize) #define TIOCSTART _IO('t', 110) /* start output, like ^Q */ --- a/arch/alpha/include/uapi/asm/termbits.h +++ b/arch/alpha/include/uapi/asm/termbits.h @@ -26,6 +26,19 @@ struct termios { speed_t c_ospeed; /* output speed */ }; +/* Alpha has identical termios and termios2 */ + +struct termios2 { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_cc[NCCS]; /* control characters */ + cc_t c_line; /* line discipline (== c_cc[19]) */ + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ +}; + /* Alpha has matching termios and ktermios */ struct ktermios { @@ -152,6 +165,7 @@ struct ktermios { #define B3000000 00034 #define B3500000 00035 #define B4000000 00036 +#define BOTHER 00037 #define CSIZE 00001400 #define CS5 00000000 @@ -169,6 +183,9 @@ struct ktermios { #define CMSPAR 010000000000 /* mark or space (stick) parity */ #define CRTSCTS 020000000000 /* flow control */ +#define CIBAUD 07600000 +#define IBSHIFT 16 + /* c_lflag bits */ #define ISIG 0x00000080 #define ICANON 0x00000100