From patchwork Mon Jun 1 11:55:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 49303 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 6491C218FC for ; Mon, 1 Jun 2015 11:55:43 +0000 (UTC) Received: by labc7 with SMTP id c7sf4510428lab.1 for ; Mon, 01 Jun 2015 04:55:42 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=gTAfb5Rw7QN8F0sYRqGR+c/juBVTUDEX+wMSKMxSa0Y=; b=WJorDt7Hybc1kOjR3B1IffMrtJHk8jfKK3cDqXyz+abSiZtMJjtQAcpsD1oPN90nS7 9osZ6g9Gbu1G3H6aRtClE7M100sOtemYuVRarxZxQ2erf+glFbHVjqIVoPFe+4QIDpB6 oU5IY4HNd9sR0O0lBcFKpIVqO24E0/va4flgAv3Xe3KLGWTONr/IU9EG61fZ6PrHgGyH uetefNY1ykAFStos+9EJw+ChBBS4Wlo+HUzfNolLGf5EWKu3Nu/jf41APyu57inMZKTS MmZlxHj2etOCVoXqrGg7+5Ha1seEIQrGJ72Tkt7weEv7mD5Ays97RRE6GVRTxaDK+G4h Il4w== X-Gm-Message-State: ALoCoQkOXnBY6mVxR2frKSXLLadiE3Hz8jnE2T7Ep5y5qC3AotlsGi0O2ypOPmyhnmUjedxE8l+M X-Received: by 10.180.90.106 with SMTP id bv10mr11340307wib.6.1433159742257; Mon, 01 Jun 2015 04:55:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.5.35 with SMTP id cj3ls115682lad.7.gmail; Mon, 01 Jun 2015 04:55:42 -0700 (PDT) X-Received: by 10.152.22.4 with SMTP id z4mr20916867lae.14.1433159742069; Mon, 01 Jun 2015 04:55:42 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id dz10si1956212lac.88.2015.06.01.04.55.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Jun 2015 04:55:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbcue7 with SMTP id ue7so82657834lbc.0 for ; Mon, 01 Jun 2015 04:55:41 -0700 (PDT) X-Received: by 10.152.21.136 with SMTP id v8mr20682630lae.19.1433159741793; Mon, 01 Jun 2015 04:55:41 -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 hn6csp2257618lbb; Mon, 1 Jun 2015 04:55:40 -0700 (PDT) X-Received: by 10.66.155.36 with SMTP id vt4mr39602835pab.32.1433159739962; Mon, 01 Jun 2015 04:55:39 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yt2si20922232pbc.122.2015.06.01.04.55.38; Mon, 01 Jun 2015 04:55:39 -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 S1752582AbbFALzd (ORCPT + 28 others); Mon, 1 Jun 2015 07:55:33 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:36242 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751800AbbFALzW (ORCPT ); Mon, 1 Jun 2015 07:55:22 -0400 Received: by pacux9 with SMTP id ux9so67529347pac.3 for ; Mon, 01 Jun 2015 04:55:22 -0700 (PDT) X-Received: by 10.66.66.197 with SMTP id h5mr40629870pat.29.1433159722164; Mon, 01 Jun 2015 04:55:22 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by mx.google.com with ESMTPSA id rd7sm14307271pdb.64.2015.06.01.04.55.19 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 01 Jun 2015 04:55:21 -0700 (PDT) From: Baolin Wang To: tglx@linutronix.de Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, baolin.wang@linaro.org, y2038@lists.linaro.org Subject: [PATCH v4 06/25] time/posix-timers:Introduce {get, put}_timespec and {get, put}_itimerspec Date: Mon, 1 Jun 2015 19:55:08 +0800 Message-Id: <1433159708-4780-1-git-send-email-baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 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: baolin.wang@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.217.180 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: , These are new helper functions that convert between a user timespec/ itimerspec and a kernel timespec64/itimerspec64 structure. These macros can change the types underneath from both ends and it will work efficiently on both 32-bit and 64-bit that can avoid the CONFIG_64BIT macro in syscall functions, and also it can make the syscall functions more simple. Signed-off-by: Baolin Wang --- kernel/time/posix-timers.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 31ea01f..96efe1d 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -147,6 +147,35 @@ static struct k_itimer *__lock_timer(timer_t timer_id, unsigned long *flags); __timr; \ }) +#define __get_timespec(kts, uts) \ + (__get_user((kts)->tv_sec, &(uts)->tv_sec) || \ + __get_user((kts)->tv_nsec, &(uts)->tv_nsec)) + +#define __put_timespec(kts, uts) \ + (__put_user((kts)->tv_sec, &(uts)->tv_sec) || \ + __put_user((kts)->tv_nsec, &(uts)->tv_nsec)) + +#define get_timespec(kts, uts) \ + ((access_ok(VERIFY_READ, (uts), sizeof(*(uts))) || \ + __get_timespec((kts), (uts))) ? \ + -EFAULT : 0) + +#define put_timespec(kts, uts) \ + ((access_ok(VERIFY_WRITE, (uts), sizeof(*(uts))) || \ + __put_timespec((kts), (uts))) ? \ + -EFAULT : 0) + +#define get_itimerspec(kit, uit) \ + ((access_ok(VERIFY_READ, (uit), sizeof(*(uit))) || \ + __get_timespec(&(kit)->it_interval, &(uit)->it_interval) || \ + __get_timespec(&(kit)->it_value, &(uit)->it_value))) + +#define put_itimerspec(kit, uit) \ + ((access_ok(VERIFY_WRITE, (uit), sizeof(*(uit))) || \ + __put_timespec(&(kit)->it_interval, &(uit)->it_interval) || \ + __put_timespec(&(kit)->it_value, &(uit)->it_value)) ? \ + -EFAULT : 0) + static int hash(struct signal_struct *sig, unsigned int nr) { return hash_32(hash32_ptr(sig) ^ nr, HASH_BITS(posix_timers_hashtable));