From patchwork Mon Jun 29 14:23:25 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: 50416 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7B1A3218E4 for ; Mon, 29 Jun 2015 14:27:21 +0000 (UTC) Received: by laer2 with SMTP id r2sf46237275lae.3 for ; Mon, 29 Jun 2015 07:27:20 -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=a1zsvd6gTw3bWX6xbCtqqsuuhomyWSzvURHGosXSs1U=; b=U7m2L/RiaszSGsVbqsT3ZfZZ+tcFk/tSbx1sr5fohE/5yYJIUh5PfiiyvjhehYGL78 dWgN9pefRLe+0E8pnTSLOgT6DXMsuCiNuEojrpXUrraesn8PuHfdWXsvzFgHm+oEEv/W woUwek2DkPaaETzTPSp63hi4FNuwZgc29q0s75mnhB/y5hDIX0XlFvIHhxXVbCUUB8z0 z7Rvdq8GAe9O5cQrO+Gp4Vn1wH1THzgUbb1KiuumOc3OJg5LUy5QFYdre9ih/3p0p5BC /9WL1yOF1R4YlS36TXZAgUU8P1WxFeYi3kjFO91P1UacGThUAsDPh44XfJsfbq6T8c+J TRnw== X-Gm-Message-State: ALoCoQl6yDyDZmimjCAF9GPZw2bwtmmQ/KdvGIJk6l1Ik+yb+s26pghKJPa3HZ+FYFFL6InTwYNV X-Received: by 10.112.219.200 with SMTP id pq8mr11076473lbc.7.1435588040467; Mon, 29 Jun 2015 07:27:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.73 with SMTP id y9ls648307lay.18.gmail; Mon, 29 Jun 2015 07:27:20 -0700 (PDT) X-Received: by 10.152.20.138 with SMTP id n10mr14301869lae.115.1435588040288; Mon, 29 Jun 2015 07:27:20 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id ia4si2986163lbb.61.2015.06.29.07.27.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jun 2015 07:27:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by laar3 with SMTP id r3so65709391laa.0 for ; Mon, 29 Jun 2015 07:27:20 -0700 (PDT) X-Received: by 10.112.234.200 with SMTP id ug8mr14272037lbc.117.1435588040177; Mon, 29 Jun 2015 07:27:20 -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 hn6csp1744022lbb; Mon, 29 Jun 2015 07:27:18 -0700 (PDT) X-Received: by 10.66.157.136 with SMTP id wm8mr17981555pab.117.1435588038225; Mon, 29 Jun 2015 07:27:18 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qr9si63682447pbc.92.2015.06.29.07.27.17; Mon, 29 Jun 2015 07:27:18 -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 S1753639AbbF2O1P (ORCPT + 30 others); Mon, 29 Jun 2015 10:27:15 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:36349 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752685AbbF2O02 (ORCPT ); Mon, 29 Jun 2015 10:26:28 -0400 Received: by paceq1 with SMTP id eq1so105870897pac.3 for ; Mon, 29 Jun 2015 07:26:26 -0700 (PDT) X-Received: by 10.70.59.41 with SMTP id w9mr9825546pdq.5.1435587986690; Mon, 29 Jun 2015 07:26:26 -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.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 29 Jun 2015 07:26:26 -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 2/4] time64: add timeval64 helper for compat syscalls Date: Mon, 29 Jun 2015 22:23:25 +0800 Message-Id: <1435587807-10008-3-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.48 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 __kernel_compat_timeval in uapi in order to use it in ioctl command because compat_timeval is invisible in uapi. Meanwhile We could avoid to define it by using the __s32 array in ioctl command definition. I am sure which one is the better way. Any suggestion or input is welcome. This patch also define compat_get_timeval64, compat_put_timeval64 for converting between compat_timeval and timeval64. Signed-off-by: Bamvor Zhang Jian --- include/linux/compat.h | 3 +++ include/uapi/linux/time.h | 6 ++++++ kernel/compat.c | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/include/linux/compat.h b/include/linux/compat.h index ab25814..14569a7 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -154,6 +154,9 @@ extern int compat_get_timespec(struct timespec *, const void __user *); extern int compat_put_timespec(const struct timespec *, void __user *); extern int compat_get_timeval(struct timeval *, const void __user *); extern int compat_put_timeval(const struct timeval *, void __user *); +struct timeval64; +extern int compat_get_timeval64(struct timeval64 *tv, const struct compat_timeval __user *ctv); +extern int compat_put_timeval64(const struct timeval64 *tv, struct compat_timeval __user *ctv); /* * This function convert a timespec if necessary and returns a *user diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h index 2ca6a31..9f6093e 100644 --- a/include/uapi/linux/time.h +++ b/include/uapi/linux/time.h @@ -76,4 +76,10 @@ struct __kernel_timeval { }; #endif +typedef __s32 __kernel_time32_t; +struct __kernel_compat_timeval { + __kernel_time32_t tv_sec; + __s32 tv_usec; +}; + #endif /* _UAPI_LINUX_TIME_H */ diff --git a/kernel/compat.c b/kernel/compat.c index 333d364..ebe45b4 100644 --- a/kernel/compat.c +++ b/kernel/compat.c @@ -172,6 +172,23 @@ int compat_put_timeval(const struct timeval *tv, void __user *utv) } EXPORT_SYMBOL_GPL(compat_put_timeval); +int compat_get_timeval64(struct timeval64 *tv, const struct compat_timeval __user *ctv) +{ + return (!access_ok(VERIFY_READ, ctv, sizeof(*ctv)) || + __get_user(tv->tv_sec, &ctv->tv_sec) || + __get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; +} +EXPORT_SYMBOL_GPL(compat_get_timeval64); + +/* TODO: is it ok that just put to user without implicit cast? */ +int compat_put_timeval64(const struct timeval64 *tv, struct compat_timeval *ctv) +{ + return (!access_ok(VERIFY_WRITE, ctv, sizeof(*ctv)) || + __put_user(tv->tv_sec, &ctv->tv_sec) || + __put_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; +} +EXPORT_SYMBOL_GPL(compat_put_timeval64); + int compat_get_timespec(struct timespec *ts, const void __user *uts) { if (COMPAT_USE_64BIT_TIME)