Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3038805imu; Mon, 19 Nov 2018 09:42:28 -0800 (PST) X-Google-Smtp-Source: AJdET5figOqhfLGfaZc3N05ZLLtOiz2Mn2vphTP/qXmW052xaFKIaAB9vdqeRTzS4VrtMAd8MACv X-Received: by 2002:a65:47ca:: with SMTP id f10mr21515143pgs.166.1542649348162; Mon, 19 Nov 2018 09:42:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542649348; cv=none; d=google.com; s=arc-20160816; b=tIRoRTHPpCqLJBGFVnMf/VDBlXf7FsdDfphK9PDZ3lFaUbjRoCGTbr27JcGxuBApdu jb4nzZQjF9/bhiaBhttKq+0nPBVXXg395Iq3Zf5z5zabKO2p4cKeexbzPSDjoFpcZtfb jnXmvNHDup6/GKX0OPHqsFJK8RjDaEQiNHQyZst4oQzdV+LLDeO4NaI4Y6k5PLi6WkDV WfXGzP8HPexBbGQbMd96I8lCgQiOIrGMTcjCLOqeliGngpQ5TQ5vTmxz6fwkNicZlm0O O6xjivIAp3PHd2uMF1ysf+7PRxIB4KysJWgz0BOFEwuk+XCk0uIaAqZZTV3TGPbupwpP w12g== 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=cEt+a+IrtcCRymnVr5lacm9nGQw64qVLqejJguYbIrc=; b=fdYphWsPVGvivNflAV3KJ3+KqzGTBEOHHtFKPQwWlWKCGELQflDhlifuANKhVYM3PA CBQ+hITR6uytLyiBtd+W1+SV+7kJnvVG2HQlZ4VCm4p9rgPITcT21+j+SnA3iiqvWYN8 uWZ84EutkZCLK9TZVr1g5vWbk7LeuB0V7W5e2d2stXewrCj948BcVpWnZXVlKMbyehLw QP6wT+j4W5gMqn98XriJI/KDWYjMUsGp+Aj4J6Lo5s0hg67SW/n4oAMzbg6V8JHAHKla OSzReN9M4ZJdxHr9fo7vM0zhnB/+jpbJ6FgjT6u2XcsHyPFDqG93ahd/8G1/GchVoCZ6 vtLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nM+dYoU8; 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 g22si29263918pfj.222.2018.11.19.09.42.13; Mon, 19 Nov 2018 09:42:28 -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=nM+dYoU8; 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 S2389819AbeKTDNz (ORCPT + 99 others); Mon, 19 Nov 2018 22:13:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:50948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389242AbeKTDNx (ORCPT ); Mon, 19 Nov 2018 22:13:53 -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 2FA132145D; Mon, 19 Nov 2018 16:49:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646180; bh=FXqR0JNaLJX7M0Qlwvh1Z+6n70vkeZ6ztM0lczBoMSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nM+dYoU8DcxJtg/W1jY7F3oxNUmvj1i8kPMnF3wM0W9ZR3uuOCd+memRoe/UdJILZ oUVWKPaQK03ACo71ZUtBFVJri+ulItixiBEHnoAIeq/T0tf6ogf6oFMjr2/Of9HAET mBLpFwLCn2PiFGxwOMJUhZ3i5TVB9IptcwQqRpic= 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.14 066/124] arch/alpha, termios: implement BOTHER, IBSHIFT and termios2 Date: Mon, 19 Nov 2018 17:28:40 +0100 Message-Id: <20181119162626.148740463@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162612.951907286@linuxfoundation.org> References: <20181119162612.951907286@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.14-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 { @@ -148,6 +161,7 @@ struct ktermios { #define B3000000 00034 #define B3500000 00035 #define B4000000 00036 +#define BOTHER 00037 #define CSIZE 00001400 #define CS5 00000000 @@ -165,6 +179,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