Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp378645imm; Fri, 6 Jul 2018 22:47:40 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeqWYGS+nVuFzKyNeh7ar7EyBTQcA2iZO3bhliKCfk27jsLU3jE/0WEkoW6esjF5GLPdI3L X-Received: by 2002:a63:d518:: with SMTP id c24-v6mr5630741pgg.357.1530942460834; Fri, 06 Jul 2018 22:47:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530942460; cv=none; d=google.com; s=arc-20160816; b=d95YPv9C0VbUatR52B1ZvDetLD4tyldKy+UP0we5jN4D+DkLNf4nQ+x1aj/Aicg4jF xkXaUpaE7hZpbhz130Wdo5oJX+rcmoGuGq7FJqID5mcnYUhLUoEncrVqU4zA0tbWA8TT qNePiKdKgO9y2q3ZVAR1ybR2TBNWWGv+mfnkAjNs/NBMyVOIfZs3OeUqYpGXx13NMOYl +BqzuliwpYCWLQx21vzo+8HnU7JiHo8ogouZwuGlsd+6dDfr/dC4cDYFlVM7V+99tR87 wg1nWngtzbXbr88aFW1HGrxZzOp78YSz8yeSHz4fwOzEDk+qkEyKWefpNOi1GqkTuqP1 GhCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=tFIdsJQgboLo0N40IqaBS2E2+uZyn96KVbZd+cjUIV0=; b=Dgi5RGu+4g5MpoAHePhewrn2X1TlJMyAdzQxHVc2fVkcG3kDeEXdltYyPFUosHuKRf tuyYKS/TRMh+wqAue9e87gEOPvr76TlZoh+WJV5wO3NGhTA5zuIu7n6dmIQm8CLmWHet kwX3ALtEGA/Dj1qBl3i2yqiv7AuUcYDlr6g8/uJHleFfDqoXAwp4DHA3hagM3yWBcwqS IMutUX+U2meZRw+KSWguEp07Zt1V/iNGR2OqYU5YvHZs51R1hFQaguPpeKzTbnr7X7OE YaBzz++lL+8gTqkrMJyBKkRBJMjTJop9CeP4oMyVgtaRsMipMlWo9vG/HLIFTN6jb0rY OgjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eW04J2Ui; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h3-v6si10162110plk.47.2018.07.06.22.47.26; Fri, 06 Jul 2018 22:47:40 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eW04J2Ui; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753862AbeGGFoi (ORCPT + 99 others); Sat, 7 Jul 2018 01:44:38 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:39728 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753609AbeGGFnw (ORCPT ); Sat, 7 Jul 2018 01:43:52 -0400 Received: by mail-pl0-f67.google.com with SMTP id s24-v6so3749619plq.6 for ; Fri, 06 Jul 2018 22:43:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tFIdsJQgboLo0N40IqaBS2E2+uZyn96KVbZd+cjUIV0=; b=eW04J2Ui+9YaseS3qXrfHtZXbH5C1Av5MsydS4a2iEixogxHiIW8Kg3HGMHkPJ0rk6 HhJiFboJDBTWz6aHGLvRtlTC/7nyT20HX6mL9QePEkVQH5rbg2cZx0ZdKtbgqndrFPic D8NzpOTj/rszRI7DsoDek0DGf8VUh82VPQLKCvGtPUgnsx5/+xw/z2u/f/PAGTX/Eap4 B0VY5ckPzOrtH8IUb5/oPur3w8R8UxDh35U1NX9mHHqW8aHe5mH0f/JY9a/KVayZiRK1 2gHC8wr5sskGpQkSMhxEXsQxNG9OTJtctNlgtwZl1570ky51TClOfBZNDYZl+ug0a28I aJfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tFIdsJQgboLo0N40IqaBS2E2+uZyn96KVbZd+cjUIV0=; b=J+LcTpthXDY598FEfCLLTZUOYITHcasm41MhHTAa3bWC5JbU0Qm+A3ufgLsbHFYxkv /I1RwaSAG8271engD65BMUQghUoLEo0Bw5hdbTfV3LvpFZoGVYOgPNsgQPUWAxlrAwro 2QAsWddaaeXmfv4BYX7OBCx70YyVD6MA+nr7ysMot9dwRac5QYq7ean4ZzjRuNmDAHnF g9LvUqxfwJD3H5GnIZJGoqJFdzfkOzN2CjPY1bn1PXmKXK20GvIHSQoB3860FcVKoNRV lFFyUlb7t7ixEjAmO6anDmHi6EPYsiSSLFg5jsKIfyGMtEtEoJgb1NkoJBCD+oeedW4Q r7RA== X-Gm-Message-State: APt69E0fz16VhJy09+gPjaoYlZtpPvLgYcM64phILqdlbaolXL8w9WzP veduDIUwDxmYJX0SaGRXCIc= X-Received: by 2002:a17:902:8347:: with SMTP id z7-v6mr12972374pln.290.1530942232327; Fri, 06 Jul 2018 22:43:52 -0700 (PDT) Received: from deepa-ubuntu.lan (c-67-170-212-194.hsd1.ca.comcast.net. [67.170.212.194]) by smtp.gmail.com with ESMTPSA id t192-v6sm16505083pgc.74.2018.07.06.22.43.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Jul 2018 22:43:51 -0700 (PDT) From: Deepa Dinamani To: tglx@linutronix.de, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, y2038@lists.linaro.org Subject: [PATCH v3 5/7] time: Add struct __kernel_timex Date: Fri, 6 Jul 2018 22:42:45 -0700 Message-Id: <20180707054247.19802-6-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180707054247.19802-1-deepa.kernel@gmail.com> References: <20180707054247.19802-1-deepa.kernel@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) 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) */ -- 2.17.1