Merge branch 'cpufreq/arm/linux-next' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / kernel / time / posix-stubs.c
index 20c65a7..fcb3b21 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/ktime.h>
 #include <linux/timekeeping.h>
 #include <linux/posix-timers.h>
+#include <linux/time_namespace.h>
 #include <linux/compat.h>
 
 #ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
@@ -77,9 +78,11 @@ int do_clock_gettime(clockid_t which_clock, struct timespec64 *tp)
                break;
        case CLOCK_MONOTONIC:
                ktime_get_ts64(tp);
+               timens_add_monotonic(tp);
                break;
        case CLOCK_BOOTTIME:
                ktime_get_boottime_ts64(tp);
+               timens_add_boottime(tp);
                break;
        default:
                return -EINVAL;
@@ -126,6 +129,7 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
                struct __kernel_timespec __user *, rmtp)
 {
        struct timespec64 t;
+       ktime_t texp;
 
        switch (which_clock) {
        case CLOCK_REALTIME:
@@ -144,7 +148,10 @@ SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
                rmtp = NULL;
        current->restart_block.nanosleep.type = rmtp ? TT_NATIVE : TT_NONE;
        current->restart_block.nanosleep.rmtp = rmtp;
-       return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
+       texp = timespec64_to_ktime(t);
+       if (flags & TIMER_ABSTIME)
+               texp = timens_ktime_to_host(which_clock, texp);
+       return hrtimer_nanosleep(texp, flags & TIMER_ABSTIME ?
                                 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
                                 which_clock);
 }
@@ -215,6 +222,7 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,
                struct old_timespec32 __user *, rmtp)
 {
        struct timespec64 t;
+       ktime_t texp;
 
        switch (which_clock) {
        case CLOCK_REALTIME:
@@ -233,7 +241,10 @@ SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,
                rmtp = NULL;
        current->restart_block.nanosleep.type = rmtp ? TT_COMPAT : TT_NONE;
        current->restart_block.nanosleep.compat_rmtp = rmtp;
-       return hrtimer_nanosleep(&t, flags & TIMER_ABSTIME ?
+       texp = timespec64_to_ktime(t);
+       if (flags & TIMER_ABSTIME)
+               texp = timens_ktime_to_host(which_clock, texp);
+       return hrtimer_nanosleep(texp, flags & TIMER_ABSTIME ?
                                 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
                                 which_clock);
 }