]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
y2038: make do_gettimeofday() and get_seconds() inline
authorArnd Bergmann <arnd@arndb.de>
Tue, 14 Aug 2018 13:18:20 +0000 (15:18 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 26 Nov 2019 12:16:58 +0000 (13:16 +0100)
BugLink: https://bugs.launchpad.net/bugs/1853915
[ Upstream commit 33e26418193f58d1895f2f968e1953b1caf8deb7 ]

get_seconds() and do_gettimeofday() are only used by a few modules now any
more (waiting for the respective patches to get accepted), and they are
among the last holdouts of code that is not y2038 safe in the core kernel.

Move the implementation into the timekeeping32.h header to clean up
the core kernel and isolate the old interfaces further.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
include/linux/timekeeping32.h
kernel/time/time.c
kernel/time/timekeeping.c

index af4114d5dc1751235fe99fbd70b79ae5cca73ccd..acb45675b4214e7602911b0db3845bdd65ddd73f 100644 (file)
@@ -6,8 +6,19 @@
  * over time so we can remove the file here.
  */
 
-extern void do_gettimeofday(struct timeval *tv);
-unsigned long get_seconds(void);
+static inline void do_gettimeofday(struct timeval *tv)
+{
+       struct timespec64 now;
+
+       ktime_get_real_ts64(&now);
+       tv->tv_sec = now.tv_sec;
+       tv->tv_usec = now.tv_nsec/1000;
+}
+
+static inline unsigned long get_seconds(void)
+{
+       return ktime_get_real_seconds();
+}
 
 /* does not take xtime_lock */
 struct timespec __current_kernel_time(void);
index a2f3b80927d05b63ab97211ed54450a787828464..c5e5bab1e9fe180f3491c4ae0a8a7b7ebaee2955 100644 (file)
@@ -146,9 +146,11 @@ SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
                struct timezone __user *, tz)
 {
        if (likely(tv != NULL)) {
-               struct timeval ktv;
-               do_gettimeofday(&ktv);
-               if (copy_to_user(tv, &ktv, sizeof(ktv)))
+               struct timespec64 ts;
+
+               ktime_get_real_ts64(&ts);
+               if (put_user(ts.tv_sec, &tv->tv_sec) ||
+                   put_user(ts.tv_nsec / 1000, &tv->tv_usec))
                        return -EFAULT;
        }
        if (unlikely(tz != NULL)) {
@@ -229,10 +231,11 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
                       struct timezone __user *, tz)
 {
        if (tv) {
-               struct timeval ktv;
+               struct timespec64 ts;
 
-               do_gettimeofday(&ktv);
-               if (compat_put_timeval(&ktv, tv))
+               ktime_get_real_ts64(&ts);
+               if (put_user(ts.tv_sec, &tv->tv_sec) ||
+                   put_user(ts.tv_nsec / 1000, &tv->tv_usec))
                        return -EFAULT;
        }
        if (tz) {
index b1644c4437e130fc8cff2d97641c601f0d598e12..d78558f9273a0c76f7d74037b52babf52106ec28 100644 (file)
@@ -1202,22 +1202,6 @@ int get_device_system_crosststamp(int (*get_time_fn)
 }
 EXPORT_SYMBOL_GPL(get_device_system_crosststamp);
 
-/**
- * do_gettimeofday - Returns the time of day in a timeval
- * @tv:                pointer to the timeval to be set
- *
- * NOTE: Users should be converted to using getnstimeofday()
- */
-void do_gettimeofday(struct timeval *tv)
-{
-       struct timespec64 now;
-
-       getnstimeofday64(&now);
-       tv->tv_sec = now.tv_sec;
-       tv->tv_usec = now.tv_nsec/1000;
-}
-EXPORT_SYMBOL(do_gettimeofday);
-
 /**
  * do_settimeofday64 - Sets the time of day.
  * @ts:     pointer to the timespec64 variable containing the new time
@@ -2174,14 +2158,6 @@ void getboottime64(struct timespec64 *ts)
 }
 EXPORT_SYMBOL_GPL(getboottime64);
 
-unsigned long get_seconds(void)
-{
-       struct timekeeper *tk = &tk_core.timekeeper;
-
-       return tk->xtime_sec;
-}
-EXPORT_SYMBOL(get_seconds);
-
 struct timespec __current_kernel_time(void)
 {
        struct timekeeper *tk = &tk_core.timekeeper;