Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp764346imm; Mon, 2 Jul 2018 22:47:39 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL3BUH8f0dVHBSkXYKBJ94HZUhIZvR15BHfrdGsN9pvFlATtJ6nQWuTOLcb2SzxTxoYhkvV X-Received: by 2002:a65:5307:: with SMTP id m7-v6mr24932740pgq.431.1530596859682; Mon, 02 Jul 2018 22:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530596859; cv=none; d=google.com; s=arc-20160816; b=Wy9Y5YFWoh5iFBKEmy3a8agUB0qO2LcmloQ7X4M9yHBoLeTrSSSYqlxyP5PPL94oqD fCXJalQAzxzOZAsL7ULiQiWcUunj9wkIxtll+yV7p4mzVXG1S/gbeEPjd/ss9gpLy24S WBEaKsi377Eb4DPCHtW8uPS/xS1Ng2GHBsYIlgQZArTSVLb3vw/HypRW4/XEhV2y4Ars OSi88gwqDtRGsdMvD63xHIY8xg+bfHEOOc8BHkJkEN0bQrh9t+7k7nulM76VtB078o/a b+JARlRo1lHGkgaY5IjcdbvwBVbK3G7/kP0tNhnL6FN3gBx88sbWJBrAPf+W/UYOFbtQ ivxQ== 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=nIWvVfHqRy0dBrN01Gh22a2lbdfRbYufFK52/YN2sk3DRXkoWl9QnzceEbNtT0qX2J vtrYXRsgIUYanhlvjlbm9iDHoebziqmp/SRKxzA3i+McLnvi3ergq/JQJjKSyzeSrhaW KJkZKnEAIKcwy1cuR5m5tJpThJHl0TIhyJIDYeHqAvz4wkD08/IymE6QluNsD2nhjeFy 9/V0j9PC9TS5zNujdICH8eacBPZBDm5Mv/5nExhV9ryAqbUBeb97hel8GOnM1LRA1hQg 5bh2sqdTjSvcVAzIjcLbdCFb6smNMVvwxtUkIpRjJ3uXipSfAIYP9nSRnW3JbR6Tjm+1 I4oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ijLU5U80; 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 l81-v6si333519pfa.368.2018.07.02.22.47.25; Mon, 02 Jul 2018 22:47:39 -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=ijLU5U80; 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 S933040AbeGCFpb (ORCPT + 99 others); Tue, 3 Jul 2018 01:45:31 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:32865 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933001AbeGCFpZ (ORCPT ); Tue, 3 Jul 2018 01:45:25 -0400 Received: by mail-pl0-f66.google.com with SMTP id 6-v6so464875plb.0 for ; Mon, 02 Jul 2018 22:45:25 -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=ijLU5U80GxFB8wtrlIKuUpRxhf0k83Xi7ab24EAUQyxarqOKZk5UuQYwfNnGdE3Xsn A8YJBzXCdcIJLShRBqaBVhBaj3cAee4VL273/NQDOa4X2nIe4OCrPRWiifv/Pg1hJdKO TCIvyVyYfd58qoQkTtAMxoLAdsnag8N2hSCtnP/4mq7XOzE7gi6MY7YuXMTcXgeTlq50 ETyehUCfvy6ofZL7bKgxgkEnd+dNkntOrgt6+8oD+Jx+ADzpR3+6lX+aBcdHeGIKm2yu Iff+8j3HxcYJMbw3vZD5AtCuxHNV9Z7Ou0QRb3XUQgzVf/BDqUFq69W6Z6DulPiP0kb8 W23w== 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=qiRdx0jPkyiqMamsfznc3yoUAgvSQ72nPhyXWtTsDw86z8DSV0Hf19Z5tyWitCScIR X0RLXSM29c2mN93ON7JMnFtR/Cc9zKJH40be62QeDu7HGhGYOwjqW8ow0j7CJ0WMi/zB hwsPJY1K9ZNslMTc1S24KzRkxOkNMePsTyyziWygYlWZZpTIwz/bTK3YVBxlIzZEv4vq FMA7j3xP49YtJA/8JvUB6Mr+C2Pe4SCX65PLA8CHzMiu04smLONGu1jlcPeG0Em2mCRO Gb6gk26fpBbBCeAvF1fKhoeR7MQXx0LijIEN8FmuKQBVLy3lnaNqN0ciVTGglIuBLHOs RWaA== X-Gm-Message-State: APt69E0R8bWrhMUNRUtOUcGD4wobZtcbW0JkJs5t++cTIMHqpsTuhknR LIIkd5+jxvtQxwsZbwDgGYo= X-Received: by 2002:a17:902:758e:: with SMTP id j14-v6mr28046946pll.160.1530596725308; Mon, 02 Jul 2018 22:45:25 -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 h75-v6sm784780pfh.86.2018.07.02.22.45.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 22:45:24 -0700 (PDT) From: Deepa Dinamani To: tglx@linutronix.de, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, y2038@lists.linaro.org Subject: [PATCH 4/6] time: Add struct __kernel_timex Date: Mon, 2 Jul 2018 22:44:20 -0700 Message-Id: <20180703054422.12089-5-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703054422.12089-1-deepa.kernel@gmail.com> References: <20180703054422.12089-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