From patchwork Thu Apr 2 03:34:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 46677 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 56E22216D1 for ; Thu, 2 Apr 2015 03:34:53 +0000 (UTC) Received: by lbfb1 with SMTP id b1sf14471266lbf.2 for ; Wed, 01 Apr 2015 20:34:51 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=bZgXWG2+Zl98GXcw27RMlt404pHrGvL+nYgapQuOEZg=; b=Cj0LT1aGLDF/7FQv0xLyz2cGsJoBX92WrhdWnn5EEM2QUl8T3TymuayYuv1U+3Zobg N+QmUOGp23HLs+850wMjd9vM+7c/brZF/tzl51pJ0iGLbNGRq4TRJYeuJyi4iWfwdGaw mB9Z3PNGd2p8cI5mkbm67TCcdtOK0OMH3wCYXlTYxlxa9QuP26K0By36FGzz/El2aByh 7n2+uYH1Lv227eBG5rLsoGno2BzDuwJ5cCsG5aTgNs2RzEtk5YrB8mle0nqxasCMBF9E QxlLsquDQgR2bVMJ8ZEisKGUuSrgY6EEF9zSB388+MGIDvC1VwgXNu3b18L5BPdjQcYZ 7Plw== X-Gm-Message-State: ALoCoQkKGAg1zk5f9kLI84YmzI/6ZnRam8o99LS/8v7lq5UBmWI9M/ZHeM8KxVg6F4c0UOtQutpN X-Received: by 10.112.14.38 with SMTP id m6mr4387536lbc.12.1427945691782; Wed, 01 Apr 2015 20:34:51 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.100 with SMTP id a4ls155684lah.23.gmail; Wed, 01 Apr 2015 20:34:51 -0700 (PDT) X-Received: by 10.112.50.38 with SMTP id z6mr39391537lbn.122.1427945691483; Wed, 01 Apr 2015 20:34:51 -0700 (PDT) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id df12si3137329lac.57.2015.04.01.20.34.51 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:34:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by lbdc10 with SMTP id c10so50282677lbd.2 for ; Wed, 01 Apr 2015 20:34:51 -0700 (PDT) X-Received: by 10.152.19.199 with SMTP id h7mr39775663lae.32.1427945691019; Wed, 01 Apr 2015 20:34:51 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.57.201 with SMTP id k9csp1063085lbq; Wed, 1 Apr 2015 20:34:50 -0700 (PDT) X-Received: by 10.66.66.230 with SMTP id i6mr82203980pat.108.1427945688969; Wed, 01 Apr 2015 20:34:48 -0700 (PDT) Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com. [209.85.220.42]) by mx.google.com with ESMTPS id ql2si5541115pac.138.2015.04.01.20.34.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 20:34:48 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.42 as permitted sender) client-ip=209.85.220.42; Received: by pactp5 with SMTP id tp5so71150970pac.1 for ; Wed, 01 Apr 2015 20:34:47 -0700 (PDT) X-Received: by 10.68.239.104 with SMTP id vr8mr82858628pbc.96.1427945687568; Wed, 01 Apr 2015 20:34:47 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id da10sm3572603pac.42.2015.04.01.20.34.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 20:34:46 -0700 (PDT) From: John Stultz To: lkml Cc: Xunlei Pang , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , John Stultz Subject: [PATCH 01/21] time: Add y2038 safe read_boot_clock64() Date: Wed, 1 Apr 2015 20:34:21 -0700 Message-Id: <1427945681-29972-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> References: <1427945681-29972-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@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.172 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Xunlei Pang As part of addressing in-kernel y2038 issues, this patch adds read_boot_clock64() and replaces all the call sites of read_boot_clock() with this function. This is a __weak implementation, which simply calls the existing y2038 unsafe read_boot_clock(). This allows architecture specific implementations to be converted independently, and eventually the y2038 unsafe read_boot_clock() can be removed after all its architecture specific implementations have been converted to read_boot_clock64(). Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Suggested-by: Arnd Bergmann Signed-off-by: Xunlei Pang Signed-off-by: John Stultz --- include/linux/timekeeping.h | 1 + kernel/time/timekeeping.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h index 5047b83..18d27a3 100644 --- a/include/linux/timekeeping.h +++ b/include/linux/timekeeping.h @@ -269,6 +269,7 @@ static inline bool has_persistent_clock(void) extern void read_persistent_clock(struct timespec *ts); extern void read_boot_clock(struct timespec *ts); +extern void read_boot_clock64(struct timespec64 *ts); extern int update_persistent_clock(struct timespec now); diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c index c3fcff0..50c4bec 100644 --- a/kernel/time/timekeeping.c +++ b/kernel/time/timekeeping.c @@ -1188,6 +1188,14 @@ void __weak read_boot_clock(struct timespec *ts) ts->tv_nsec = 0; } +void __weak read_boot_clock64(struct timespec64 *ts64) +{ + struct timespec ts; + + read_boot_clock(&ts); + *ts64 = timespec_to_timespec64(ts); +} + /* * timekeeping_init - Initializes the clocksource and common timekeeping values */ @@ -1209,8 +1217,7 @@ void __init timekeeping_init(void) } else if (now.tv_sec || now.tv_nsec) persistent_clock_exist = true; - read_boot_clock(&ts); - boot = timespec_to_timespec64(ts); + read_boot_clock64(&boot); if (!timespec64_valid_strict(&boot)) { pr_warn("WARNING: Boot clock returned invalid value!\n" " Check your CMOS/BIOS settings.\n");