From patchwork Fri Jan 18 16:18:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 156005 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3442186jaa; Fri, 18 Jan 2019 08:22:26 -0800 (PST) X-Google-Smtp-Source: ALg8bN7DSp5ZhGDtwXczWZF4rFCVWjZcntLU7e5XK5VLXUwu8vUbcyG+1Y+Tj9cpiPGJKWeHBhgT X-Received: by 2002:a63:2b82:: with SMTP id r124mr3370894pgr.300.1547828546403; Fri, 18 Jan 2019 08:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547828546; cv=none; d=google.com; s=arc-20160816; b=o8W4GTPFkAwWsb4pbTZ/TqFhg3FmAP3kv2l2wvRm/Kdk5aPCCzzQTb0o2sDLiLV1Sw /WpfqItvJv5dLxTP8wXDI3uE1EIm2uv1tj+H4bTX7KEeRxxZ6b45XBDFokWE9Va2BSHA oDgWjVa9DTcRaCtn/m/w0Mxa4LLuuFq15Y8QaKo4pM+5GMt2LLaIAwv11bAcGUYlNwlt FRRov9b32CPynW7K9rPw0SBnGrGuSv3zQX3aFH0YTsb1MN9nfQ8FSWIrv9DQkbgHYtcm c4QLItqcL3TJXbzzUtFb9/H7ZYGaXqmPMpCHXFlI5YYKssA+mVxr66xP8S+R7QKe9mqr hwKg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4h+Shb9Z/ZOxdmzBCIT/8qnnSq99nhBxYGcffz37bQ4=; b=LfsbkR90qVmXjLmbIcAPFDn7ycQNPOqzrHj41DnxaILh8w44j8HSF3FT/5okkKomro ryT8q8tvLU0ZNpSeCCyo+njuf7HiI6Ma2C/loKLSic9O4MaC9YQNP8IF2TQ+g0wlNWkd ylFmIPZHo16j0SQ5uJOe5XQip0dAvNqP3MKgSKcIOAMf4dYOsIZKc9MhyMlUg041esBj A0J46IPPdXUInoMOsNzIjJnBQMype6YxcJnz/KP7oeQHLmneQtZPEOetKrRkl2XOW9vh pFa+hhwIXUcVKv2CYnLQe/cSFH6jEHDDja+TpUSbg9u5PoLMj++knzikwY/8PU25LMOX fX7g== 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 n1si5265253pgh.172.2019.01.18.08.22.26; Fri, 18 Jan 2019 08:22:26 -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; 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 S1728690AbfARQVJ (ORCPT + 13 others); Fri, 18 Jan 2019 11:21:09 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:42723 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728537AbfARQVF (ORCPT ); Fri, 18 Jan 2019 11:21:05 -0500 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1Myb8N-1h9Ji41bDh-00ywxC; Fri, 18 Jan 2019 17:19:41 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Cc: Arnd Bergmann , mattst88@gmail.com, linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, tony.luck@intel.com, fenghua.yu@intel.com, geert@linux-m68k.org, monstr@monstr.eu, paul.burton@mips.com, deller@gmx.de, benh@kernel.crashing.org, mpe@ellerman.id.au, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, dalias@libc.org, davem@davemloft.net, luto@kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, jcmvbkbc@gmail.com, akpm@linux-foundation.org, deepa.kernel@gmail.com, ebiederm@xmission.com, firoz.khan@linaro.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 19/29] time: Add struct __kernel_timex Date: Fri, 18 Jan 2019 17:18:25 +0100 Message-Id: <20190118161835.2259170-20-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190118161835.2259170-1-arnd@arndb.de> References: <20190118161835.2259170-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:av64eTYsi2K0oecdlvrPbJkEidlMY8tIQkQX919n78kQTRWxVDT AEO8Y1y0Gg3kMOTk7Ytz+hp122eH4GS/wmnGxvETpi223F8qYnKQ5nHdS9Db1csvd53Shzx NsB3jwfJVeKLCMpEtzJ6rD0oxXHOu/EqsAk4NKBNiImSlEYGKZSuJcfe8UblsPBnSmc+GR8 WjMe1ho0oEOGsrwgXNtMg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:1hYSy+tZSH0=:5MA+iWLUpC5oXcNconNQ8j Ha3SPI7O9WdlwMkb2MLkqWfbCouGe+Lt3EWXTQC8VcJkAcJmGQprODj1L5AwjxA7QBIX0l287 hSIYef20L0Sx76Su2oO2rz4SlHNr8iucfcjG5lzh4KEt2qm+zcdZnF4lMjn/iyDEaMngH02NP aMuxlSiDSYj+kd/1uMeO12PVHR8inMl6nW80j18TsM0YePrL/xR9W67q0hDYqDVzO/svOozCO Muov7u6fz/mtCWb/W8jOPbsFQlBbJrHW8FpFgp0Eim6bK95wmNYXEqJ6lIQaBKVtcWohU4QaI oAmlZzsQu3VN661SoknqSebKedd4P2s8XQg3m9Tdk/HpC7bsAgCqPzOVo0k+1GF0g0UmB9Pwa d3JAWYihAGsSkA2pvxV/8M9EdrzNFxXh1vhnRffAUnK0Ht2XY3vNNU834R4V+uIMMUgv9S6Yn MQGMaurb5y/dMgLwgPCP8AaMIBkMy0eUEV50OfO/QqhpHOapftHLZr0PojO80+mUsvvI0NcIH Tb7SHPu0k5v2Hd/XYUPlfgy/qxwTq0tMXeF2KkSxFWSRfyvCenMI3e0mpL8eJ53/yez4SoLki VSzMicuhR/1b0lZGVP1y4fIYryobb2t7Rp1LjBBasGZnEbPt+/L4UjRzrY9mrcdwYwOLc2qEI PnVrlLIBbRw9m+Jp4c9ojeTK9xU/WcMx+uPqWzetzPJgMvWs1Cd2UIOcu+HOq0yDwqjfR6hNB Ep40C93Uv3BC80y3PvS0VSbnt84oV2o98gfJGQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Deepa Dinamani struct timex uses struct timeval internally. struct timeval is not y2038 safe. Introduce a new UAPI type struct __kernel_timex that is y2038 safe. struct __kernel_timex uses a timeval type that is similar to struct __kernel_timespec which preserves the same structure size across 32 bit and 64 bit ABIs. struct __kernel_timex also restructures other members of the structure to make the structure the same on 64 bit and 32 bit architectures. Note that struct __kernel_timex is the same as struct timex on a 64 bit architecture. The above solution is similar to other new y2038 syscalls that are being introduced: both 32 bit and 64 bit ABIs have a common entry, and the compat entry supports the old 32 bit syscall interface. Alternatives considered were: 1. Add new time type to struct timex that makes use of padded bits. This time type could be based on the struct __kernel_timespec. modes will use a flag to notify which time structure should be used internally. This needs some application level changes on both 64 bit and 32 bit architectures. Although 64 bit machines could continue to use the older timeval structure without any changes. 2. Add a new u8 type to struct timex that makes use of padded bits. This can be used to save higher order tv_sec bits. modes will use a flag to notify presence of such a type. This will need some application level changes on 32 bit architectures. 3. Add a new compat_timex structure that differs in only the size of the time type; keep rest of struct timex the same. This requires extra syscalls to manage all 3 cases on 64 bit architectures. This will not need any application level changes but will add more complexity from kernel side. Signed-off-by: Deepa Dinamani --- include/linux/timex.h | 7 +++++++ include/uapi/linux/timex.h | 41 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) -- 2.20.0 diff --git a/include/linux/timex.h b/include/linux/timex.h index 39c25dbebfe8..7f40e9e42ecc 100644 --- a/include/linux/timex.h +++ b/include/linux/timex.h @@ -53,6 +53,13 @@ #ifndef _LINUX_TIMEX_H #define _LINUX_TIMEX_H +/* CONFIG_64BIT_TIME enables new 64 bit time_t syscalls in the compat path + * and 32-bit emulation. + */ +#ifndef CONFIG_64BIT_TIME +#define __kernel_timex timex +#endif + #include #define ADJ_ADJTIME 0x8000 /* switch between adjtime/adjtimex modes */ diff --git a/include/uapi/linux/timex.h b/include/uapi/linux/timex.h index 92685d826444..a1c6b73016a5 100644 --- a/include/uapi/linux/timex.h +++ b/include/uapi/linux/timex.h @@ -92,6 +92,47 @@ struct timex { int :32; int :32; int :32; }; +struct __kernel_timex_timeval { + __kernel_time64_t tv_sec; + long long tv_usec; +}; + +#ifndef __kernel_timex +struct __kernel_timex { + unsigned int modes; /* mode selector */ + int :32; /* pad */ + long long offset; /* time offset (usec) */ + long long freq; /* frequency offset (scaled ppm) */ + long long maxerror;/* maximum error (usec) */ + long long esterror;/* estimated error (usec) */ + int status; /* clock command/status */ + int :32; /* pad */ + long long constant;/* pll time constant */ + long long precision;/* clock precision (usec) (read only) */ + long long tolerance;/* clock frequency tolerance (ppm) + * (read only) + */ + struct __kernel_timex_timeval time; /* (read only, except for ADJ_SETOFFSET) */ + long long tick; /* (modified) usecs between clock ticks */ + + long long ppsfreq;/* pps frequency (scaled ppm) (ro) */ + long long jitter; /* pps jitter (us) (ro) */ + int shift; /* interval duration (s) (shift) (ro) */ + int :32; /* pad */ + long long stabil; /* pps stability (scaled ppm) (ro) */ + long long jitcnt; /* jitter limit exceeded (ro) */ + long long calcnt; /* calibration intervals (ro) */ + long long errcnt; /* calibration errors (ro) */ + long long stbcnt; /* stability limit exceeded (ro) */ + + int tai; /* TAI offset (ro) */ + + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; int :32; + int :32; int :32; int :32; +}; +#endif + /* * Mode codes (timex.mode) */