From: Deepa Dinamani <deepa.kernel@gmail.com>
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 [thread overview]
Message-ID: <20180707054247.19802-6-deepa.kernel@gmail.com> (raw)
In-Reply-To: <20180707054247.19802-1-deepa.kernel@gmail.com>
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 <deepa.kernel@gmail.com>
---
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 <uapi/linux/timex.h>
#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
next prev parent reply other threads:[~2018-07-07 5:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-07 5:42 [PATCH v3 0/7] Introduce struct __kernel_timex Deepa Dinamani
2018-07-07 5:42 ` [PATCH v3 1/7] arm64: Make basic compat_* types always available Deepa Dinamani
2018-07-12 8:20 ` Christoph Hellwig
2018-07-07 5:42 ` [PATCH v3 2/7] sparc: Make thread_info.h available directly Deepa Dinamani
2018-07-07 5:42 ` [PATCH v3 3/7] riscv: Delete asm/compat.h Deepa Dinamani
2018-07-12 8:14 ` Christoph Hellwig
2018-08-03 1:26 ` Palmer Dabbelt
2018-08-03 7:39 ` Christoph Hellwig
2018-08-05 21:29 ` Arnd Bergmann
2018-07-07 5:42 ` [PATCH v3 4/7] timex: prepare compat helpers for y2038 changes Deepa Dinamani
2018-07-07 5:42 ` Deepa Dinamani [this message]
2018-07-11 9:54 ` [PATCH v3 5/7] time: Add struct __kernel_timex Arnd Bergmann
2018-07-12 8:26 ` Christoph Hellwig
2018-07-12 14:53 ` Arnd Bergmann
2018-07-07 5:42 ` [PATCH v3 6/7] timex: use __kernel_timex internally Deepa Dinamani
2018-07-07 14:23 ` Richard Henderson
2018-07-12 8:27 ` Christoph Hellwig
2018-07-07 5:42 ` [PATCH v3 7/7] timex: change syscalls to use struct __kernel_timex Deepa Dinamani
2018-07-12 8:29 ` Christoph Hellwig
2018-07-12 14:40 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180707054247.19802-6-deepa.kernel@gmail.com \
--to=deepa.kernel@gmail.com \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=y2038@lists.linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).