Commit b5793b0d92c9 ("posix-timers: Make compat syscalls depend on CONFIG_COMPAT_32BIT_TIME") added support for building the nanosleep compat system call on 32-bit architectures, but missed one change in nanosleep_copyout(), which would trigger a BUG() as soon as we switch any architecture over to use it.
This makes sure the TT_COMPAT handler is available when we need it.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- kernel/time/hrtimer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 055a4a728c00..3e93c54bd3a1 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1659,7 +1659,7 @@ EXPORT_SYMBOL_GPL(hrtimer_init_sleeper); int nanosleep_copyout(struct restart_block *restart, struct timespec64 *ts) { switch(restart->nanosleep.type) { -#ifdef CONFIG_COMPAT +#ifdef CONFIG_COMPAT_32BIT_TIME case TT_COMPAT: if (compat_put_timespec64(ts, restart->nanosleep.compat_rmtp)) return -EFAULT;
Both get_seconds() and do_gettimeofday() are deprecated. Let's change the time() implementation to use the replacement function instead.
Obviously the system call will still overflow in 2038, but this gets us closer to removing the old helper functions.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- kernel/time/time.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/kernel/time/time.c b/kernel/time/time.c index 8e4f3fd2f84b..90867ece5c09 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -63,7 +63,7 @@ EXPORT_SYMBOL(sys_tz); */ SYSCALL_DEFINE1(time, time_t __user *, tloc) { - time_t i = get_seconds(); + time_t i = (time_t)ktime_get_real_seconds();
if (tloc) { if (put_user(i,tloc)) @@ -106,11 +106,9 @@ SYSCALL_DEFINE1(stime, time_t __user *, tptr) /* compat_time_t is a 32 bit "long" and needs to get converted. */ COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc) { - struct timeval tv; compat_time_t i;
- do_gettimeofday(&tv); - i = tv.tv_sec; + i = (compat_time_t)ktime_get_real_seconds();
if (tloc) { if (put_user(i,tloc))
The two do the same, this moves all users to the newer name for consistency.
Signed-off-by: Arnd Bergmann arnd@arndb.de --- kernel/time/ntp.c | 6 +++--- kernel/time/timekeeping.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index a09ded765f6c..10a79053e82f 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -502,7 +502,7 @@ static void sched_sync_hw_clock(struct timespec64 now, { struct timespec64 next;
- getnstimeofday64(&next); + ktime_get_real_ts64(&next); if (!fail) next.tv_sec = 659; else { @@ -537,7 +537,7 @@ static void sync_rtc_clock(void) if (!IS_ENABLED(CONFIG_RTC_SYSTOHC)) return;
- getnstimeofday64(&now); + ktime_get_real_ts64(&now);
adjust = now; if (persistent_clock_is_local) @@ -591,7 +591,7 @@ static bool sync_cmos_clock(void) * Architectures are strongly encouraged to use rtclib and not * implement this legacy API. */ - getnstimeofday64(&now); + ktime_get_real_ts64(&now); if (rtc_tv_nsec_ok(-1 * target_nsec, &adjust, &now)) { if (persistent_clock_is_local) adjust.tv_sec -= (sys_tz.tz_minuteswest * 60); diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index 4786df904c22..77c436a0070b 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -2310,7 +2310,7 @@ int do_adjtimex(struct timex *txc) return ret; }
- getnstimeofday64(&ts); + ktime_get_real_ts64(&ts);
raw_spin_lock_irqsave(&timekeeper_lock, flags); write_seqcount_begin(&tk_core.seq);