Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Dummy stubs used when CONFIG_POSIX_TIMERS=n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Created by:  Nicolas Pitre, July 2016
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright:   (C) 2016 Linaro Limited
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/ktime.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/timekeeping.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/posix-timers.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/time_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) /* Architectures may override SYS_NI and COMPAT_SYS_NI */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <asm/syscall_wrapper.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) asmlinkage long sys_ni_posix_timers(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	pr_err_once("process %d (%s) attempted a POSIX timer syscall "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 		    "while CONFIG_POSIX_TIMERS is not set\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		    current->pid, current->comm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	return -ENOSYS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #ifndef SYS_NI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #define SYS_NI(name)  SYSCALL_ALIAS(sys_##name, sys_ni_posix_timers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #ifndef COMPAT_SYS_NI
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define COMPAT_SYS_NI(name)  SYSCALL_ALIAS(compat_sys_##name, sys_ni_posix_timers)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) SYS_NI(timer_create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) SYS_NI(timer_gettime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) SYS_NI(timer_getoverrun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) SYS_NI(timer_settime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) SYS_NI(timer_delete);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) SYS_NI(clock_adjtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) SYS_NI(getitimer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) SYS_NI(setitimer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) SYS_NI(clock_adjtime32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) #ifdef __ARCH_WANT_SYS_ALARM
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) SYS_NI(alarm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)  * We preserve minimal support for CLOCK_REALTIME and CLOCK_MONOTONIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * as it is easy to remain compatible with little code. CLOCK_BOOTTIME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * is also included for convenience as at least systemd uses it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		const struct __kernel_timespec __user *, tp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	struct timespec64 new_tp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	if (which_clock != CLOCK_REALTIME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (get_timespec64(&new_tp, tp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	return do_sys_settimeofday64(&new_tp, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) int do_clock_gettime(clockid_t which_clock, struct timespec64 *tp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	switch (which_clock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	case CLOCK_REALTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		ktime_get_real_ts64(tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	case CLOCK_MONOTONIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		ktime_get_ts64(tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		timens_add_monotonic(tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	case CLOCK_BOOTTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		ktime_get_boottime_ts64(tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		timens_add_boottime(tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		struct __kernel_timespec __user *, tp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	struct timespec64 kernel_tp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	ret = do_clock_gettime(which_clock, &kernel_tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	if (put_timespec64(&kernel_tp, tp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) SYSCALL_DEFINE2(clock_getres, const clockid_t, which_clock, struct __kernel_timespec __user *, tp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	struct timespec64 rtn_tp = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		.tv_sec = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		.tv_nsec = hrtimer_resolution,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	switch (which_clock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	case CLOCK_REALTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	case CLOCK_MONOTONIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	case CLOCK_BOOTTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		if (put_timespec64(&rtn_tp, tp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) SYSCALL_DEFINE4(clock_nanosleep, const clockid_t, which_clock, int, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		const struct __kernel_timespec __user *, rqtp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		struct __kernel_timespec __user *, rmtp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	struct timespec64 t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	ktime_t texp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	switch (which_clock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	case CLOCK_REALTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	case CLOCK_MONOTONIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	case CLOCK_BOOTTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (get_timespec64(&t, rqtp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	if (!timespec64_valid(&t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	if (flags & TIMER_ABSTIME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		rmtp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	current->restart_block.nanosleep.type = rmtp ? TT_NATIVE : TT_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	current->restart_block.nanosleep.rmtp = rmtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	texp = timespec64_to_ktime(t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	if (flags & TIMER_ABSTIME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		texp = timens_ktime_to_host(which_clock, texp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	return hrtimer_nanosleep(texp, flags & TIMER_ABSTIME ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 				 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 				 which_clock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) COMPAT_SYS_NI(timer_create);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) #if defined(CONFIG_COMPAT) || defined(CONFIG_ALPHA)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) COMPAT_SYS_NI(getitimer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) COMPAT_SYS_NI(setitimer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) #ifdef CONFIG_COMPAT_32BIT_TIME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) SYS_NI(timer_settime32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) SYS_NI(timer_gettime32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) SYSCALL_DEFINE2(clock_settime32, const clockid_t, which_clock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		struct old_timespec32 __user *, tp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	struct timespec64 new_tp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	if (which_clock != CLOCK_REALTIME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	if (get_old_timespec32(&new_tp, tp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	return do_sys_settimeofday64(&new_tp, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) SYSCALL_DEFINE2(clock_gettime32, clockid_t, which_clock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		struct old_timespec32 __user *, tp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct timespec64 kernel_tp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	ret = do_clock_gettime(which_clock, &kernel_tp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	if (put_old_timespec32(&kernel_tp, tp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) SYSCALL_DEFINE2(clock_getres_time32, clockid_t, which_clock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		struct old_timespec32 __user *, tp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	struct timespec64 rtn_tp = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		.tv_sec = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		.tv_nsec = hrtimer_resolution,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	switch (which_clock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	case CLOCK_REALTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	case CLOCK_MONOTONIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	case CLOCK_BOOTTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		if (put_old_timespec32(&rtn_tp, tp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) SYSCALL_DEFINE4(clock_nanosleep_time32, clockid_t, which_clock, int, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		struct old_timespec32 __user *, rqtp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		struct old_timespec32 __user *, rmtp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	struct timespec64 t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	ktime_t texp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	switch (which_clock) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	case CLOCK_REALTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	case CLOCK_MONOTONIC:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	case CLOCK_BOOTTIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	if (get_old_timespec32(&t, rqtp))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	if (!timespec64_valid(&t))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	if (flags & TIMER_ABSTIME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 		rmtp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	current->restart_block.nanosleep.type = rmtp ? TT_COMPAT : TT_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	current->restart_block.nanosleep.compat_rmtp = rmtp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	texp = timespec64_to_ktime(t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	if (flags & TIMER_ABSTIME)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		texp = timens_ktime_to_host(which_clock, texp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	return hrtimer_nanosleep(texp, flags & TIMER_ABSTIME ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 				 HRTIMER_MODE_ABS : HRTIMER_MODE_REL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 				 which_clock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) #endif