From patchwork Thu Oct 30 11:15:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "pang.xunlei" X-Patchwork-Id: 39820 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 91B99202FE for ; Thu, 30 Oct 2014 11:17:36 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id k14sf2783070wgh.7 for ; Thu, 30 Oct 2014 04:17:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=EGE9OT2PL0lDOvpOyEvuarkWkK/AGFZn0iGMDLRbK8M=; b=HNz0DdCyeOuBlv7JXBCsVtZ/HKYvhQVyUISjBMD/0o1niUQ6lbTm+264Q1zolZsjDJ Q4uUa8bw6165bv5NWP2BYfctwtGYUNYybUvvTEZFcfM58TMzkXRlK3QU5dotwwsPOAB4 NcvtibBcR7afFj6yO1UmacPr05ykHUqjHv7vI5KO9UFWu129bYk8XxHtr2K7r64jmlqu JfP1h1pIbelYs1XCf6Y2WjqtrZWzUenKsJI7/iLpJsUefiTqsfZj7syscUL6BUaIE1UX xYT5rhK2y4sI2ZQ1tJe30wj0JBl9xVSf9EhVOAgfpYRB+s8ua1P9uD7hyxt2AWjBF/lV TdlA== X-Gm-Message-State: ALoCoQm/4uCNnYaGA/TKwaXLc0LkY056TIVbbt6+YdUi62InuG1ju4ATUYZqrn9XCiLEWkVzKrkz X-Received: by 10.180.74.130 with SMTP id t2mr2886333wiv.4.1414667855837; Thu, 30 Oct 2014 04:17:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.9 with SMTP id o9ls266750lao.97.gmail; Thu, 30 Oct 2014 04:17:35 -0700 (PDT) X-Received: by 10.152.36.33 with SMTP id n1mr9896486laj.95.1414667855619; Thu, 30 Oct 2014 04:17:35 -0700 (PDT) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id f1si11580060lam.8.2014.10.30.04.17.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Oct 2014 04:17:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gm9so4224617lab.18 for ; Thu, 30 Oct 2014 04:17:35 -0700 (PDT) X-Received: by 10.112.130.41 with SMTP id ob9mr17770546lbb.74.1414667855512; Thu, 30 Oct 2014 04:17:35 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp22377lbz; Thu, 30 Oct 2014 04:17:34 -0700 (PDT) X-Received: by 10.66.218.42 with SMTP id pd10mr1498198pac.151.1414667852855; Thu, 30 Oct 2014 04:17:32 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wg5si6275496pab.219.2014.10.30.04.17.32 for ; Thu, 30 Oct 2014 04:17:32 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759383AbaJ3LRX (ORCPT + 26 others); Thu, 30 Oct 2014 07:17:23 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:44786 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759367AbaJ3LRQ (ORCPT ); Thu, 30 Oct 2014 07:17:16 -0400 Received: by mail-pa0-f51.google.com with SMTP id kq14so5268029pab.38 for ; Thu, 30 Oct 2014 04:17:15 -0700 (PDT) X-Received: by 10.68.110.161 with SMTP id ib1mr16346953pbb.109.1414667835738; Thu, 30 Oct 2014 04:17:15 -0700 (PDT) Received: from wangdeqiang.com ([210.21.227.66]) by mx.google.com with ESMTPSA id i10sm6874826pdr.21.2014.10.30.04.17.10 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 30 Oct 2014 04:17:15 -0700 (PDT) From: "pang.xunlei" To: linux-kernel@vger.kernel.org Cc: rtc-linux@googlegroups.com, xen-devel@lists.xenproject.org, John Stultz , Thomas Gleixner , Alessandro Zummo , Stefano Stabellini , "pang.xunlei" Subject: [RFC PATCH v2 05/11] time: Convert all users of do_settimeofday() to use do_settimeofday64() Date: Thu, 30 Oct 2014 19:15:39 +0800 Message-Id: <1414667745-7703-6-git-send-email-pang.xunlei@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1414667745-7703-1-git-send-email-pang.xunlei@linaro.org> References: <1414667745-7703-1-git-send-email-pang.xunlei@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: pang.xunlei@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , As part of addressing 2038 saftey for in-kernel uses, this patch converts all users of do_settimeofday() to use do_settimeofday64(). This patch also converts rtc_tm_to_time() to rtc_tm_to_time64(), rtc_time_to_tm() to rtc_time_to_tm64() when needed. Additionally, changes time64_t definition in time64.h to avoid warnings. Signed-off-by: pang.xunlei --- arch/x86/xen/time.c | 9 +++++++-- drivers/hv/hv_util.c | 6 +++--- drivers/rtc/hctosys.c | 10 +++++----- drivers/staging/android/alarm-dev.c | 7 +++++-- include/linux/time64.h | 4 ++-- kernel/compat.c | 5 ++++- kernel/time/time.c | 13 ++++++++++--- 7 files changed, 36 insertions(+), 18 deletions(-) diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index f473d26..16fce39 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c @@ -486,6 +486,7 @@ static void __init xen_time_init(void) { int cpu = smp_processor_id(); struct timespec tp; + struct timespec64 tp64; clocksource_register_hz(&xen_clocksource, NSEC_PER_SEC); @@ -496,9 +497,13 @@ static void __init xen_time_init(void) xen_clockevent = &xen_vcpuop_clockevent; } - /* Set initial system time with full resolution */ + /* + * Set initial system time with full resolution + * TODO: [2038 safety] xen_read_wallclock() uses timespec64 + */ xen_read_wallclock(&tp); - do_settimeofday(&tp); + tp64 = timespec_to_timespec64(tp); + do_settimeofday64(&tp64); setup_force_cpu_cap(X86_FEATURE_TSC); diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index 3b9c9ef..c91167e 100644 --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c @@ -166,12 +166,12 @@ static void shutdown_onchannelcallback(void *context) static inline void do_adj_guesttime(u64 hosttime) { s64 host_tns; - struct timespec host_ts; + struct timespec64 host_ts; host_tns = (hosttime - WLTIMEDELTA) * 100; - host_ts = ns_to_timespec(host_tns); + host_ts = ns_to_timespec64(host_tns); - do_settimeofday(&host_ts); + do_settimeofday64(&host_ts); } /* diff --git a/drivers/rtc/hctosys.c b/drivers/rtc/hctosys.c index 4aa60d7..239400a 100644 --- a/drivers/rtc/hctosys.c +++ b/drivers/rtc/hctosys.c @@ -26,7 +26,7 @@ static int __init rtc_hctosys(void) { int err = -ENODEV; struct rtc_time tm; - struct timespec tv = { + struct timespec64 tv = { .tv_nsec = NSEC_PER_SEC >> 1, }; struct rtc_device *rtc = rtc_class_open(CONFIG_RTC_HCTOSYS_DEVICE); @@ -52,16 +52,16 @@ static int __init rtc_hctosys(void) goto err_invalid; } - rtc_tm_to_time(&tm, &tv.tv_sec); + rtc_tm_to_time64(&tm, &tv.tv_sec); - err = do_settimeofday(&tv); + err = do_settimeofday64(&tv); dev_info(rtc->dev.parent, "setting system clock to " - "%d-%02d-%02d %02d:%02d:%02d UTC (%u)\n", + "%d-%02d-%02d %02d:%02d:%02d UTC (%llu)\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, - (unsigned int) tv.tv_sec); + (unsigned long long) tv.tv_sec); err_invalid: err_read: diff --git a/drivers/staging/android/alarm-dev.c b/drivers/staging/android/alarm-dev.c index ff4b3e8..01017ff 100644 --- a/drivers/staging/android/alarm-dev.c +++ b/drivers/staging/android/alarm-dev.c @@ -152,16 +152,19 @@ static int alarm_wait(void) return rv; } +/* TODO: [2038 safety] alarm_set_rtc() uses timespec64 */ static int alarm_set_rtc(struct timespec *ts) { + struct timespec ts64; struct rtc_time new_rtc_tm; struct rtc_device *rtc_dev; unsigned long flags; int rv = 0; - rtc_time_to_tm(ts->tv_sec, &new_rtc_tm); + ts64 = timespec_to_timespec64(*ts); + rtc_time_to_tm64(ts64.tv_sec, &new_rtc_tm); rtc_dev = alarmtimer_get_rtcdev(); - rv = do_settimeofday(ts); + rv = do_settimeofday64(&ts64); if (rv < 0) return rv; if (rtc_dev) diff --git a/include/linux/time64.h b/include/linux/time64.h index a383147..2f0cde4 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -3,15 +3,15 @@ #include -typedef __s64 time64_t; - /* * This wants to go into uapi/linux/time.h once we agreed about the * userspace interfaces. */ #if __BITS_PER_LONG == 64 +typedef __kernel_time_t time64_t; # define timespec64 timespec #else +typedef __s64 time64_t; struct timespec64 { time64_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ diff --git a/kernel/compat.c b/kernel/compat.c index ebb3c36..29d3234 100644 --- a/kernel/compat.c +++ b/kernel/compat.c @@ -1047,6 +1047,7 @@ COMPAT_SYSCALL_DEFINE1(time, compat_time_t __user *, tloc) COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr) { struct timespec tv; + struct timespec64 tv64; int err; if (get_user(tv.tv_sec, tptr)) @@ -1054,11 +1055,13 @@ COMPAT_SYSCALL_DEFINE1(stime, compat_time_t __user *, tptr) tv.tv_nsec = 0; + /* TODO: [2038 safety] security_settime() uses timespec64 */ err = security_settime(&tv, NULL); if (err) return err; - do_settimeofday(&tv); + tv64 = timespec_to_timespec64(tv); + do_settimeofday64(&tv64); return 0; } diff --git a/kernel/time/time.c b/kernel/time/time.c index f44efdb..5074b9b 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -82,6 +82,7 @@ SYSCALL_DEFINE1(time, time_t __user *, tloc) SYSCALL_DEFINE1(stime, time_t __user *, tptr) { struct timespec tv; + struct timespec64 tv64; int err; if (get_user(tv.tv_sec, tptr)) @@ -93,7 +94,8 @@ SYSCALL_DEFINE1(stime, time_t __user *, tptr) if (err) return err; - do_settimeofday(&tv); + tv64 = timespec_to_timespec64(tv); + do_settimeofday64(&tv64); return 0; } @@ -162,6 +164,7 @@ static inline void warp_clock(void) int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz) { + struct timespec64 tv64; static int firsttime = 1; int error = 0; @@ -181,8 +184,12 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz) warp_clock(); } } - if (tv) - return do_settimeofday(tv); + + if (tv) { + tv64 = timespec_to_timespec64(*tv); + return do_settimeofday64(&tv64); + } + return 0; }