aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-11-08 10:02:14 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2018-01-25 19:34:31 -0500
commitce4c253573ad184603e0fa77876ba155b0cde46d (patch)
treea909ebbd2d6d3eccc990c836a478d9e82c7b5e2d
parent47669fb6b5951d0e09fc99719653e0ac92b50b99 (diff)
alpha: osf_sys.c: use timespec64 where appropriate
Some of the syscall helper functions (do_utimes, poll_select_set_timeout, core_sys_select) have changed over the past year or two to use 'timespec64' pointers rather than 'timespec'. This was fine on alpha, since 64-bit architectures treat the two as the same type. However, I'd like to change that behavior and make 'timespec64' a proper type of its own even on 64-bit architectures, and that will introduce harmless type mismatch warnings here. Also, I'm trying to kill off the do_gettimeofday() helper in favor of ktime_get() and related interfaces throughout the kernel. This changes the get_tv32/put_tv32 helper functions to also take a timespec64 argument rather than timeval, which allows us to simplify some of the syscall helpers a bit and avoid the type warnings. For the moment, wait4 and adjtimex are still better off with the old behavior, so I'm adding a special put_tv_to_tv32() helper for those. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--arch/alpha/kernel/osf_sys.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 75a5c35a2067..fa1a392ca9a2 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -950,18 +950,27 @@ struct itimerval32
950}; 950};
951 951
952static inline long 952static inline long
953get_tv32(struct timeval *o, struct timeval32 __user *i) 953get_tv32(struct timespec64 *o, struct timeval32 __user *i)
954{ 954{
955 struct timeval32 tv; 955 struct timeval32 tv;
956 if (copy_from_user(&tv, i, sizeof(struct timeval32))) 956 if (copy_from_user(&tv, i, sizeof(struct timeval32)))
957 return -EFAULT; 957 return -EFAULT;
958 o->tv_sec = tv.tv_sec; 958 o->tv_sec = tv.tv_sec;
959 o->tv_usec = tv.tv_usec; 959 o->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
960 return 0; 960 return 0;
961} 961}
962 962
963static inline long 963static inline long
964put_tv32(struct timeval32 __user *o, struct timeval *i) 964put_tv32(struct timeval32 __user *o, struct timespec64 *i)
965{
966 return copy_to_user(o, &(struct timeval32){
967 .tv_sec = i->tv_sec,
968 .tv_usec = i->tv_nsec / NSEC_PER_USEC},
969 sizeof(struct timeval32));
970}
971
972static inline long
973put_tv_to_tv32(struct timeval32 __user *o, struct timeval *i)
965{ 974{
966 return copy_to_user(o, &(struct timeval32){ 975 return copy_to_user(o, &(struct timeval32){
967 .tv_sec = i->tv_sec, 976 .tv_sec = i->tv_sec,
@@ -1004,9 +1013,10 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
1004 struct timezone __user *, tz) 1013 struct timezone __user *, tz)
1005{ 1014{
1006 if (tv) { 1015 if (tv) {
1007 struct timeval ktv; 1016 struct timespec64 kts;
1008 do_gettimeofday(&ktv); 1017
1009 if (put_tv32(tv, &ktv)) 1018 ktime_get_real_ts64(&kts);
1019 if (put_tv32(tv, &kts))
1010 return -EFAULT; 1020 return -EFAULT;
1011 } 1021 }
1012 if (tz) { 1022 if (tz) {
@@ -1019,22 +1029,19 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv,
1019SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv, 1029SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv,
1020 struct timezone __user *, tz) 1030 struct timezone __user *, tz)
1021{ 1031{
1022 struct timespec64 kts64; 1032 struct timespec64 kts;
1023 struct timespec kts;
1024 struct timezone ktz; 1033 struct timezone ktz;
1025 1034
1026 if (tv) { 1035 if (tv) {
1027 if (get_tv32((struct timeval *)&kts, tv)) 1036 if (get_tv32(&kts, tv))
1028 return -EFAULT; 1037 return -EFAULT;
1029 kts.tv_nsec *= 1000;
1030 kts64 = timespec_to_timespec64(kts);
1031 } 1038 }
1032 if (tz) { 1039 if (tz) {
1033 if (copy_from_user(&ktz, tz, sizeof(*tz))) 1040 if (copy_from_user(&ktz, tz, sizeof(*tz)))
1034 return -EFAULT; 1041 return -EFAULT;
1035 } 1042 }
1036 1043
1037 return do_sys_settimeofday64(tv ? &kts64 : NULL, tz ? &ktz : NULL); 1044 return do_sys_settimeofday64(tv ? &kts : NULL, tz ? &ktz : NULL);
1038} 1045}
1039 1046
1040asmlinkage long sys_ni_posix_timers(void); 1047asmlinkage long sys_ni_posix_timers(void);
@@ -1083,22 +1090,16 @@ SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in,
1083SYSCALL_DEFINE2(osf_utimes, const char __user *, filename, 1090SYSCALL_DEFINE2(osf_utimes, const char __user *, filename,
1084 struct timeval32 __user *, tvs) 1091 struct timeval32 __user *, tvs)
1085{ 1092{
1086 struct timespec tv[2]; 1093 struct timespec64 tv[2];
1087 1094
1088 if (tvs) { 1095 if (tvs) {
1089 struct timeval ktvs[2]; 1096 if (get_tv32(&tv[0], &tvs[0]) ||
1090 if (get_tv32(&ktvs[0], &tvs[0]) || 1097 get_tv32(&tv[1], &tvs[1]))
1091 get_tv32(&ktvs[1], &tvs[1]))
1092 return -EFAULT; 1098 return -EFAULT;
1093 1099
1094 if (ktvs[0].tv_usec < 0 || ktvs[0].tv_usec >= 1000000 || 1100 if (tv[0].tv_nsec < 0 || tv[0].tv_nsec >= 1000000000 ||
1095 ktvs[1].tv_usec < 0 || ktvs[1].tv_usec >= 1000000) 1101 tv[1].tv_nsec < 0 || tv[1].tv_nsec >= 1000000000)
1096 return -EINVAL; 1102 return -EINVAL;
1097
1098 tv[0].tv_sec = ktvs[0].tv_sec;
1099 tv[0].tv_nsec = 1000 * ktvs[0].tv_usec;
1100 tv[1].tv_sec = ktvs[1].tv_sec;
1101 tv[1].tv_nsec = 1000 * ktvs[1].tv_usec;
1102 } 1103 }
1103 1104
1104 return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0); 1105 return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0);
@@ -1107,19 +1108,18 @@ SYSCALL_DEFINE2(osf_utimes, const char __user *, filename,
1107SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp, 1108SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp,
1108 fd_set __user *, exp, struct timeval32 __user *, tvp) 1109 fd_set __user *, exp, struct timeval32 __user *, tvp)
1109{ 1110{
1110 struct timespec end_time, *to = NULL; 1111 struct timespec64 end_time, *to = NULL;
1111 if (tvp) { 1112 if (tvp) {
1112 struct timeval tv; 1113 struct timespec64 tv;
1113 to = &end_time; 1114 to = &end_time;
1114 1115
1115 if (get_tv32(&tv, tvp)) 1116 if (get_tv32(&tv, tvp))
1116 return -EFAULT; 1117 return -EFAULT;
1117 1118
1118 if (tv.tv_sec < 0 || tv.tv_usec < 0) 1119 if (tv.tv_sec < 0 || tv.tv_nsec < 0)
1119 return -EINVAL; 1120 return -EINVAL;
1120 1121
1121 if (poll_select_set_timeout(to, tv.tv_sec, 1122 if (poll_select_set_timeout(to, tv.tv_sec, tv.tv_nsec))
1122 tv.tv_usec * NSEC_PER_USEC))
1123 return -EINVAL; 1123 return -EINVAL;
1124 1124
1125 } 1125 }
@@ -1192,9 +1192,9 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
1192 return -EFAULT; 1192 return -EFAULT;
1193 if (!ur) 1193 if (!ur)
1194 return err; 1194 return err;
1195 if (put_tv32(&ur->ru_utime, &r.ru_utime)) 1195 if (put_tv_to_tv32(&ur->ru_utime, &r.ru_utime))
1196 return -EFAULT; 1196 return -EFAULT;
1197 if (put_tv32(&ur->ru_stime, &r.ru_stime)) 1197 if (put_tv_to_tv32(&ur->ru_stime, &r.ru_stime))
1198 return -EFAULT; 1198 return -EFAULT;
1199 if (copy_to_user(&ur->ru_maxrss, &r.ru_maxrss, 1199 if (copy_to_user(&ur->ru_maxrss, &r.ru_maxrss,
1200 sizeof(struct rusage32) - offsetof(struct rusage32, ru_maxrss))) 1200 sizeof(struct rusage32) - offsetof(struct rusage32, ru_maxrss)))
@@ -1210,18 +1210,18 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options,
1210SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep, 1210SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep,
1211 struct timeval32 __user *, remain) 1211 struct timeval32 __user *, remain)
1212{ 1212{
1213 struct timeval tmp; 1213 struct timespec64 tmp;
1214 unsigned long ticks; 1214 unsigned long ticks;
1215 1215
1216 if (get_tv32(&tmp, sleep)) 1216 if (get_tv32(&tmp, sleep))
1217 goto fault; 1217 goto fault;
1218 1218
1219 ticks = timeval_to_jiffies(&tmp); 1219 ticks = timespec64_to_jiffies(&tmp);
1220 1220
1221 ticks = schedule_timeout_interruptible(ticks); 1221 ticks = schedule_timeout_interruptible(ticks);
1222 1222
1223 if (remain) { 1223 if (remain) {
1224 jiffies_to_timeval(ticks, &tmp); 1224 jiffies_to_timespec64(ticks, &tmp);
1225 if (put_tv32(remain, &tmp)) 1225 if (put_tv32(remain, &tmp))
1226 goto fault; 1226 goto fault;
1227 } 1227 }
@@ -1280,7 +1280,7 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
1280 if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) || 1280 if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) ||
1281 (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) - 1281 (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) -
1282 offsetof(struct timex32, tick))) || 1282 offsetof(struct timex32, tick))) ||
1283 (put_tv32(&txc_p->time, &txc.time))) 1283 (put_tv_to_tv32(&txc_p->time, &txc.time)))
1284 return -EFAULT; 1284 return -EFAULT;
1285 1285
1286 return ret; 1286 return ret;