From patchwork Wed Nov 8 15:02:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 118272 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp1906678edm; Wed, 8 Nov 2017 07:04:46 -0800 (PST) X-Google-Smtp-Source: ABhQp+QNVo7fX42rSRErvfZqBXefUldlp9MsLLy6kh6PaLrTCfUnmAsHl9f9QnDJ3qI/zMbZ7Z6n X-Received: by 10.84.212.8 with SMTP id d8mr704198pli.75.1510153486268; Wed, 08 Nov 2017 07:04:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510153486; cv=none; d=google.com; s=arc-20160816; b=0VtvIpGID1nFu/8cPjGH0y5AgA1Z4B4/+u8xuyKmEl/URsAJmI/ArBd0VRS0fA0Xbn 42xy3jbM5ydAu3yHXopH6PwEZzMtLOCN9ff6DO/9WU7HNDJnyGPactlM+zXlRGDLYH3w G2zY/3dfjmS2aY7tsAifdRXYagcC1EKxgLOULB4mEgl2YeqXhWjE0yIs+Egqw3/FCaWN 1Dao5iUCRvnCZwDTBA//Yw6koS78kWwPFCIQswKE1iK/ykNGw2ftn2Ynqrzl9CA1luHy gKCOjuUQnJskhaiXM5WY1eHadII89bR88v1Bgwo+ETUiMcekyn6CfzQIfDzLw4GbOWjY I+FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=V9y2nLAZ3L4TY6MBEde4LC9EmWSN4PwsDxlAXxmanGM=; b=suNRWx+5KmOMZ8aleX7SVmqocMXLXZoGHNrxql/++JpJ4X24of6WK7A1O82HvMU32A eyhgZ+9rYvYPoE2Hj4TydVzk8fbQPTfPu1dXuG8NCiRBmItj7LrKB7hL+kz5WQ3uQ+Op vATuZUWD4qce3dPzvKXSI4BVh25gJveYh//2WLY5MvQMjYeGKXjUnOlcLLvU1k8897bq j1NrX7KmWed2mYlv4aaT0jS70jG3A1DFTutF4ArsIqv7Fd1CMb2UrXIlGaV5eI3ui/eB kCKlF+zynJgH7vVDhvzCGj3MBp4bymBEyEgm2UA8Bl5s4zBkq1mnGwWI02nfa/yV7yOk 5hGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l2si3895848pgp.642.2017.11.08.07.04.45; Wed, 08 Nov 2017 07:04:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752694AbdKHPEo (ORCPT + 24 others); Wed, 8 Nov 2017 10:04:44 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:53205 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751716AbdKHPEk (ORCPT ); Wed, 8 Nov 2017 10:04:40 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0M2oZ4-1f40622JZG-00shxF; Wed, 08 Nov 2017 16:04:32 +0100 From: Arnd Bergmann To: Richard Henderson Cc: Ivan Kokshaysky , Matt Turner , Alexander Viro , y2038@lists.linaro.org, Deepa Dinamani , Ben Hutchings , Arnd Bergmann , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] alpha: osf_sys.c: use timespec64 where appropriate Date: Wed, 8 Nov 2017 16:02:14 +0100 Message-Id: <20171108150339.1013031-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171108150339.1013031-1-arnd@arndb.de> References: <20171108150339.1013031-1-arnd@arndb.de> X-Provags-ID: V03:K0:X5CuRT6FOdBHJFNJ+aY2xdIP1JXDXAp0UNDdE/o8aUn64Jwk4Kd z9LpgEpnWpDUo81Z42yhJ/Q0Mcjd9XTk93mSLfc3letaC+bnXjdaVjBojunYehDqRh0gls1 XsQcLEMomxcI3G/h6rRVrqt9bgTVg3LCC7maeTLly6o9pD46FbF4+WXAoO/yQqugqBv5wRY qu5LRx4Px3qLS1P6GXP7g== X-UI-Out-Filterresults: notjunk:1; V01:K0:nBbPLHGz+qY=:ilw4BYdhPfGOhkD8Gcigq5 tzTPcveogUk1NzyQ+oLjBAiWPUkKVHb12E/byFY/xuCvDm+jthFKajkM/UlPKNmwaU+ZsOThe DKbcgDtS3Q0cX43lqYigi1UZ33kbg8Fa+RY1U/xwJrGamw4zBvFwiiKMrzgwl0letvSwiD0mC GiZgHqbbGL5A0IxhOTFGfqvk6bbSVRUbdnVWyiDSspSUMREZLJBX1e/YZq5MqP8V+b2KQXeQ1 lYNRKgpqQ3hZBhZNi1EgRbYwF5YxPIs2QtcEAKLcExgMqE2vb1Ms0jDSJUSZswS01SjnHpuLz +udn3hxIodzMeKM7nOSjQUDrXL2Z4UPYJbDzg5dZNDzKKwq6gYJWuPw9ITZ6N1R5/LSokh41s w8eu6FxiFPbp5G0+6jO7Klbs8lOhwgpb3mE37/Yq4Hmce7j7jWkeaJI9jxh+v+tBexPVmMPLy TeHuhooalYDCSEQmcXLLMF1ER4qeUsi/+ZTRQoW7972ZGvzZ456j9QkmzVM0fzLgVFZD8izIQ 1lUgFqoFmHxcOVzdlNXXpqObCE2cvKEXMknyj59iiBlH/Lc1yX2nVek+IOv5Jm5zZnPuuNATX MCKmQWoI2ny0B8+pWPZNbqQ//5IUMvh2pLDSIMJx1hDiGcvaXER2wFD2jhfEvo4bTcU5WysTc X8tDjLlnHtkXfvGu92ApT7Z6/cLuWqFy1DZp5DJwKF8NFspGYONJU8NQ00fBxl0gWVt5aX9x9 /hFsEmgfeIaBu2kn5z6AQBBZuadWK6lRZeLCNA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- v2: fix ktime_get_real_ts64()/ktime_get_ts64() typo --- arch/alpha/kernel/osf_sys.c | 68 ++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 34 deletions(-) -- 2.9.0 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 }; static inline long -get_tv32(struct timeval *o, struct timeval32 __user *i) +get_tv32(struct timespec64 *o, struct timeval32 __user *i) { struct timeval32 tv; if (copy_from_user(&tv, i, sizeof(struct timeval32))) return -EFAULT; o->tv_sec = tv.tv_sec; - o->tv_usec = tv.tv_usec; + o->tv_nsec = tv.tv_usec * NSEC_PER_USEC; return 0; } static inline long -put_tv32(struct timeval32 __user *o, struct timeval *i) +put_tv32(struct timeval32 __user *o, struct timespec64 *i) +{ + return copy_to_user(o, &(struct timeval32){ + .tv_sec = i->tv_sec, + .tv_usec = i->tv_nsec / NSEC_PER_USEC}, + sizeof(struct timeval32)); +} + +static inline long +put_tv_to_tv32(struct timeval32 __user *o, struct timeval *i) { return copy_to_user(o, &(struct timeval32){ .tv_sec = i->tv_sec, @@ -1004,9 +1013,10 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv, struct timezone __user *, tz) { if (tv) { - struct timeval ktv; - do_gettimeofday(&ktv); - if (put_tv32(tv, &ktv)) + struct timespec64 kts; + + ktime_get_real_ts64(&kts); + if (put_tv32(tv, &kts)) return -EFAULT; } if (tz) { @@ -1019,22 +1029,19 @@ SYSCALL_DEFINE2(osf_gettimeofday, struct timeval32 __user *, tv, SYSCALL_DEFINE2(osf_settimeofday, struct timeval32 __user *, tv, struct timezone __user *, tz) { - struct timespec64 kts64; - struct timespec kts; + struct timespec64 kts; struct timezone ktz; if (tv) { - if (get_tv32((struct timeval *)&kts, tv)) + if (get_tv32(&kts, tv)) return -EFAULT; - kts.tv_nsec *= 1000; - kts64 = timespec_to_timespec64(kts); } if (tz) { if (copy_from_user(&ktz, tz, sizeof(*tz))) return -EFAULT; } - return do_sys_settimeofday64(tv ? &kts64 : NULL, tz ? &ktz : NULL); + return do_sys_settimeofday64(tv ? &kts : NULL, tz ? &ktz : NULL); } asmlinkage long sys_ni_posix_timers(void); @@ -1083,22 +1090,16 @@ SYSCALL_DEFINE3(osf_setitimer, int, which, struct itimerval32 __user *, in, SYSCALL_DEFINE2(osf_utimes, const char __user *, filename, struct timeval32 __user *, tvs) { - struct timespec tv[2]; + struct timespec64 tv[2]; if (tvs) { - struct timeval ktvs[2]; - if (get_tv32(&ktvs[0], &tvs[0]) || - get_tv32(&ktvs[1], &tvs[1])) + if (get_tv32(&tv[0], &tvs[0]) || + get_tv32(&tv[1], &tvs[1])) return -EFAULT; - if (ktvs[0].tv_usec < 0 || ktvs[0].tv_usec >= 1000000 || - ktvs[1].tv_usec < 0 || ktvs[1].tv_usec >= 1000000) + if (tv[0].tv_nsec < 0 || tv[0].tv_nsec >= 1000000000 || + tv[1].tv_nsec < 0 || tv[1].tv_nsec >= 1000000000) return -EINVAL; - - tv[0].tv_sec = ktvs[0].tv_sec; - tv[0].tv_nsec = 1000 * ktvs[0].tv_usec; - tv[1].tv_sec = ktvs[1].tv_sec; - tv[1].tv_nsec = 1000 * ktvs[1].tv_usec; } return do_utimes(AT_FDCWD, filename, tvs ? tv : NULL, 0); @@ -1107,19 +1108,18 @@ SYSCALL_DEFINE2(osf_utimes, const char __user *, filename, SYSCALL_DEFINE5(osf_select, int, n, fd_set __user *, inp, fd_set __user *, outp, fd_set __user *, exp, struct timeval32 __user *, tvp) { - struct timespec end_time, *to = NULL; + struct timespec64 end_time, *to = NULL; if (tvp) { - struct timeval tv; + struct timespec64 tv; to = &end_time; if (get_tv32(&tv, tvp)) return -EFAULT; - if (tv.tv_sec < 0 || tv.tv_usec < 0) + if (tv.tv_sec < 0 || tv.tv_nsec < 0) return -EINVAL; - if (poll_select_set_timeout(to, tv.tv_sec, - tv.tv_usec * NSEC_PER_USEC)) + if (poll_select_set_timeout(to, tv.tv_sec, tv.tv_nsec)) return -EINVAL; } @@ -1192,9 +1192,9 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options, return -EFAULT; if (!ur) return err; - if (put_tv32(&ur->ru_utime, &r.ru_utime)) + if (put_tv_to_tv32(&ur->ru_utime, &r.ru_utime)) return -EFAULT; - if (put_tv32(&ur->ru_stime, &r.ru_stime)) + if (put_tv_to_tv32(&ur->ru_stime, &r.ru_stime)) return -EFAULT; if (copy_to_user(&ur->ru_maxrss, &r.ru_maxrss, sizeof(struct rusage32) - offsetof(struct rusage32, ru_maxrss))) @@ -1210,18 +1210,18 @@ SYSCALL_DEFINE4(osf_wait4, pid_t, pid, int __user *, ustatus, int, options, SYSCALL_DEFINE2(osf_usleep_thread, struct timeval32 __user *, sleep, struct timeval32 __user *, remain) { - struct timeval tmp; + struct timespec64 tmp; unsigned long ticks; if (get_tv32(&tmp, sleep)) goto fault; - ticks = timeval_to_jiffies(&tmp); + ticks = timespec64_to_jiffies(&tmp); ticks = schedule_timeout_interruptible(ticks); if (remain) { - jiffies_to_timeval(ticks, &tmp); + jiffies_to_timespec64(ticks, &tmp); if (put_tv32(remain, &tmp)) goto fault; } @@ -1280,7 +1280,7 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p) if (copy_to_user(txc_p, &txc, offsetof(struct timex32, time)) || (copy_to_user(&txc_p->tick, &txc.tick, sizeof(struct timex32) - offsetof(struct timex32, tick))) || - (put_tv32(&txc_p->time, &txc.time))) + (put_tv_to_tv32(&txc_p->time, &txc.time))) return -EFAULT; return ret;