Commit 2c620ff9 authored by Deepa Dinamani's avatar Deepa Dinamani Committed by Arnd Bergmann

time: Add struct __kernel_timex

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: default avatarDeepa Dinamani <deepa.kernel@gmail.com>
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 4d5f007e
......@@ -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 */
......
......@@ -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)
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment