From patchwork Mon Jun 29 14:23:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bamvor Zhang Jian X-Patchwork-Id: 50413 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AF0D7218E4 for ; Mon, 29 Jun 2015 14:26:39 +0000 (UTC) Received: by lagh6 with SMTP id h6sf46241769lag.0 for ; Mon, 29 Jun 2015 07:26:38 -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=wWf7/ZRZu+ciLq7cnM7tGImmjHj5GSWZIzFRIyluIWA=; b=KotfaLyJ5OLXkE65R5vWqRQbrotk7JPHt9OIuI8fk93MWnJnviN0UfUPoqhPBqKdDc T1rUgxNIgSd4S7WmK1IOgUB2hqhjBCloICDmVngUJq1iQAVp0cbdLSX2khe8daW5pCp5 kyPXjJd3rO42bCjk9/WA7ZdP1ubjsjIkpGIaVEdqZG98qDtYsvIWDmD9p0FwikbyGXFg x0NA2buM8Pt3kfp1OxvEKI4po/BbuX7vin8F4hcBGGYUkpT/ag9GyqccBFSAsO5C821j Do6KQRnzem/EjTI/KAJHDQSXwH2FNHwB9JSQVX6QJtCIfpfAm6zw1Y7p3IfOX9xQg8dz JaQg== X-Gm-Message-State: ALoCoQkqXrlU9OjplcLxdx++I4FgL+1ixZQHRzkoF5bcZKUTHdLqb8ju8wjHdfdFtDzaARcXPbqI X-Received: by 10.180.97.9 with SMTP id dw9mr8791434wib.2.1435587998101; Mon, 29 Jun 2015 07:26:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.7 with SMTP id m7ls782893laj.70.gmail; Mon, 29 Jun 2015 07:26:37 -0700 (PDT) X-Received: by 10.112.143.130 with SMTP id se2mr14389209lbb.65.1435587997896; Mon, 29 Jun 2015 07:26:37 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id p5si9679563lap.109.2015.06.29.07.26.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jun 2015 07:26:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by lagc2 with SMTP id c2so12038685lag.3 for ; Mon, 29 Jun 2015 07:26:37 -0700 (PDT) X-Received: by 10.152.26.163 with SMTP id m3mr14424417lag.86.1435587997432; Mon, 29 Jun 2015 07:26:37 -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.108.230 with SMTP id hn6csp1743588lbb; Mon, 29 Jun 2015 07:26:36 -0700 (PDT) X-Received: by 10.70.100.168 with SMTP id ez8mr32238776pdb.129.1435587995568; Mon, 29 Jun 2015 07:26:35 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dv2si64578981pbc.200.2015.06.29.07.26.34; Mon, 29 Jun 2015 07:26:35 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753236AbbF2O0c (ORCPT + 30 others); Mon, 29 Jun 2015 10:26:32 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:34685 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751850AbbF2O0U (ORCPT ); Mon, 29 Jun 2015 10:26:20 -0400 Received: by pdbep18 with SMTP id ep18so96014646pdb.1 for ; Mon, 29 Jun 2015 07:26:19 -0700 (PDT) X-Received: by 10.68.226.166 with SMTP id rt6mr535810pbc.2.1435587979318; Mon, 29 Jun 2015 07:26:19 -0700 (PDT) Received: from linux-j170.site.site ([69.85.92.49]) by mx.google.com with ESMTPSA id i10sm42520177pdr.78.2015.06.29.07.26.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Jun 2015 07:26:18 -0700 (PDT) From: Bamvor Zhang Jian To: arnd@arndb.de, john.stultz@linaro.org, tglx@linutronix.de Cc: y2039@lists.linaro.org, linux-kernel@vger.kernel.org, bamvor.zhangjian@linaro.org Subject: [RFC PATCH v2 1/4] y2038: add 64bit time_t support in timeval for 32bit architecture Date: Mon, 29 Jun 2015 22:23:24 +0800 Message-Id: <1435587807-10008-2-git-send-email-bamvor.zhangjian@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435587807-10008-1-git-send-email-bamvor.zhangjian@linaro.org> References: <1435587807-10008-1-git-send-email-bamvor.zhangjian@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: bamvor.zhangjian@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.42 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: , Add timeval64 structure and copy_(from)|(to)_user functions. Add __kernel_timeval for syscalls. This changes follow the similar way in the followings commit: 361a3bf time64: Add time64.h header and define struct timespec64 49cd6f8 time: More core infrastructure for timespec64 ca2c9c5 y2038: introduce struct __kernel_timespec[1]. [1] http://git.kernel.org/cgit/linux/kernel/git/arnd/playground.git/commit/?h=y2038-syscalls&id=9005d4f4a44fc56bd0a1fe7c08e8e3f13eb75de7 Signed-off-by: Bamvor Zhang Jian --- include/linux/time64.h | 20 ++++++++++++++++++-- include/uapi/linux/time.h | 10 ++++++++++ kernel/time/time.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/include/linux/time64.h b/include/linux/time64.h index 77b5df2..2ca4f85 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -1,24 +1,35 @@ #ifndef _LINUX_TIME64_H #define _LINUX_TIME64_H -#include -#include typedef __s64 time64_t; +#ifndef CONFIG_COMPAT_TIME +# define __kernel_timeval timeval +#endif + /* * This wants to go into uapi/linux/time.h once we agreed about the * userspace interfaces. */ #if __BITS_PER_LONG == 64 # define timespec64 timespec +# define timeval64 timeval #else struct timespec64 { time64_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds */ }; + +struct timeval64 { + time64_t tv_sec; /* seconds */ + __kernel_suseconds_t tv_usec; /* microseconds */ +}; #endif +#include +#include + /* Parameters used to convert the timespec values: */ #define MSEC_PER_SEC 1000L #define USEC_PER_MSEC 1000L @@ -189,4 +200,9 @@ static __always_inline void timespec64_add_ns(struct timespec64 *a, u64 ns) #endif +extern int get_timeval64(struct timeval64 *tv, + const struct __kernel_timeval __user *utv); +extern int put_timeval64(const struct timeval64 *tv, + struct __kernel_timeval __user *utv); + #endif /* _LINUX_TIME64_H */ diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h index e75e1b6..2ca6a31 100644 --- a/include/uapi/linux/time.h +++ b/include/uapi/linux/time.h @@ -66,4 +66,14 @@ struct itimerval { */ #define TIMER_ABSTIME 0x01 +/* types based on 64-bit time_t */ +#ifndef __kernel_timeval +typedef __s64 __kernel_time64_t; + +struct __kernel_timeval { + __kernel_time64_t tv_sec; + __s64 tv_usec; +}; +#endif + #endif /* _UAPI_LINUX_TIME_H */ diff --git a/kernel/time/time.c b/kernel/time/time.c index 85d5bb1..adf0455 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -759,3 +760,38 @@ struct timespec timespec_add_safe(const struct timespec lhs, return res; } + +int get_timeval64(struct timeval64 *tv, + const struct __kernel_timeval __user *utv) +{ + struct __kernel_timeval ktv; + int ret; + + ret = copy_from_user(&ktv, utv, sizeof(ktv)); + if (ret) + return -EFAULT; + + tv->tv_sec = ktv.tv_sec; + if (!IS_ENABLED(CONFIG_64BIT) +#ifdef CONFIG_COMPAT + || is_compat_task() +#endif + ) + ktv.tv_usec &= 0xfffffffful; + tv->tv_usec = ktv.tv_usec; + + return 0; +} +EXPORT_SYMBOL_GPL(get_timeval64); + +int put_timeval64(const struct timeval64 *tv, + struct __kernel_timeval __user *utv) +{ + struct __kernel_timeval ktv = { + .tv_sec = tv->tv_sec, + .tv_usec = tv->tv_usec + }; + return copy_to_user(utv, &utv, sizeof(ktv)) ? -EFAULT : 0; +} +EXPORT_SYMBOL_GPL(put_timeval64); +