Received: by 10.223.164.202 with SMTP id h10csp657665wrb; Mon, 6 Nov 2017 13:06:40 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q8ecL1Ea8FH/dSVjYLN0JXcY4pViviyuYDMN3Kx4vDulx40nxeWuJ2Tanz67UlzMpeWDRF X-Received: by 10.99.123.88 with SMTP id k24mr16792802pgn.213.1510002400812; Mon, 06 Nov 2017 13:06:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510002400; cv=none; d=google.com; s=arc-20160816; b=unTuPN/+nkm92/bqhXZaTEOsgBHQYeWoqZpxPDlmHXmlqdaatTaupeWfZksS2oyH3c v9E6QWHYk6GG38608Q9RP3Lx74Xu909mnuNId7aVHH5WwA+g0IcRzoy94s4tmv1z3VdL t3EwzRCBFYR0yYRLf7ZqHPM309yJVd9K4EEIHFyViW1m2fwyQmsvBYLt+rdIlt+BwlXK v9uadXaeFvj7uL+FnRc9QCyY3vWMOQvE056dHEcIuHBNK0t664KbupqHSrS+RMweekXr uSwSIBNVMyVFcrdLKoBO5Gtf4A/M4n/8caTcFvT/nxXvhFFqGbupUe1cgIifYfbi3qjD m7vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=wdY6WRuT+0yApARy/24IWI1RYgpB8jOrDR8d/rKBRf4=; b=Xrtrt3M4WYm6FM++736ePT4lzq7XJTJ8F86Zw4Vjzyia1Ej2e8zcCR8EwtGrfmR8VC AbkuKqi+1/Yu4FoOMWW/ctyFLmAtzP0hhnM02lX5xFEHEqbaG9pyAp43qvGNmWLYmwgZ 92+FeUBhBLY/s0uLfaBD6a8SgqsQa+QkPm20Jd6FEywtY+CyUI7EaV90gR7yDNSW9UaH BAHXwkO3RNYlU1j25gUHAlixZmP/D3mbCxsdn/yCvaFzSPQ99JH3pB+FKuy1kwkHBOct h7xAnau9dZBcasqHWRByyPNEA9nvqEKwP+QF4UBQBFAp/urL2CenBp7Wd7thbEvGGjaB tLlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=RNT6hXdx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11si11694062pgp.662.2017.11.06.13.06.27; Mon, 06 Nov 2017 13:06:40 -0800 (PST) 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; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=RNT6hXdx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754185AbdKFVEW (ORCPT + 95 others); Mon, 6 Nov 2017 16:04:22 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:45228 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751924AbdKFVET (ORCPT ); Mon, 6 Nov 2017 16:04:19 -0500 Received: by mail-io0-f195.google.com with SMTP id i38so17203851iod.2 for ; Mon, 06 Nov 2017 13:04:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wdY6WRuT+0yApARy/24IWI1RYgpB8jOrDR8d/rKBRf4=; b=RNT6hXdxK5+U6TfowqRhTRIu/srtqHSCTPYcyCLV1Q/ps4m+wr7Uj8C1fX0WRbmfwv E/C71SLij0517S34BEY7FQvtQeh8/j7QnXyuJRESkfPzlfEbVEseQ57Oh9Bo3NDvfHlt o+Ujk1CDuVGadbaX7ZUXWNntSdMMIF0w2zWW6eCGKStvBLNdw2BPOPpY7itcDJuq8teN VK4qc/B7Z0kySg0PgfpP0ThLkmIyDhxie/LbVdUw/Xg40KKQZAWqMVBjTpwHbSKsv4Lr nFM9u1cAgoEPnp/FZziZgH7vQwsbbgNO9HLlPlFLVHAJxNPLQTMjkoYq4cCp9BPzJTnc mXTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wdY6WRuT+0yApARy/24IWI1RYgpB8jOrDR8d/rKBRf4=; b=WMzyHZgh7N/rLQGwGCYdBBATiHgtMBVbxRP77nb64mB+L9cHu21vqehjLZQeroCK1E JyloeH3O8TBXnqLAAMup8UJcTxT4Xfsh9A586R4f4zLsnHCaMTzWWKVZ2ntjWXyMmi4h NHe6bo7l4Lj/YuDpzMYoeCkPt4+kMPzZbOt6fN1/NRi24IE8ki7snzyk5RBmZtsmxcE6 O1wIsHFLg0cbQ5IpTAj71Lnp1GHvHqn7cPp10raHvJbJom8+HAVoE+2spfgV34E3nZyP rlql5lMk0VlSkEKHRWXcM44G0JHA4Qe0cnrOhgCdDxGE7GDZTw/ALHhep4IhSZKCBBi6 5G3Q== X-Gm-Message-State: AJaThX6/37nagljgaITNrkhCXZhrpgHxD18yGn9R2Q1jHnxjxXMBLxuC Pe8AX9DRR0q9Z2HrAcegbYqJQ4ICjnc= X-Received: by 10.107.147.135 with SMTP id v129mr20864702iod.289.1510002258768; Mon, 06 Nov 2017 13:04:18 -0800 (PST) Received: from nebulus.mtv.corp.google.com ([100.98.120.17]) by smtp.gmail.com with ESMTPSA id i63sm6104666ioi.68.2017.11.06.13.04.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 Nov 2017 13:04:18 -0800 (PST) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Cc: Mark Salyzyn , James Morse , Russell King , Catalin Marinas , Will Deacon , Andy Lutomirski , Dmitry Safonov , John Stultz , Mark Rutland , Laura Abbott , Kees Cook , Ard Biesheuvel , Andy Gross , Kevin Brodsky , Andrew Pinski , Thomas Gleixner , linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 12/12] lib: vdso: do not expose gettimeofday, if no arch supported timer Date: Mon, 6 Nov 2017 13:04:09 -0800 Message-Id: <20171106210413.95388-1-salyzyn@android.com> X-Mailer: git-send-email 2.15.0.403.gc27cc4dac6-goog Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Take an effort to recode the arm64 vdso code from assembler to C previously submitted by Andrew Pinski , rework it for use in both arm and arm64, overlapping any optimizations for each architecture. But instead of landing it in arm64, land the result into lib/vdso and unify both implementations to simplify future maintenance. If ARCH_PROVIDES_TIMER is not defined, do not expose gettimeofday. libc will default directly to syscall. Also ifdef clock_gettime switch cases and stubs if not supported and other unused components. Signed-off-by: Mark Salyzyn Cc: James Morse Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon Cc: Andy Lutomirski Cc: Dmitry Safonov Cc: John Stultz Cc: Mark Rutland Cc: Laura Abbott Cc: Kees Cook Cc: Ard Biesheuvel Cc: Andy Gross Cc: Kevin Brodsky Cc: Andrew Pinski Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org v3: - do not expose gettimeofday if arch does not support user space timer. v4: - update commit message to reflect overall reasoning of patch series. v5: - rebase --- lib/vdso/vgettimeofday.c | 52 +++++++++++++++++++----------------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/lib/vdso/vgettimeofday.c b/lib/vdso/vgettimeofday.c index d64f60010bb2..079955162be8 100644 --- a/lib/vdso/vgettimeofday.c +++ b/lib/vdso/vgettimeofday.c @@ -30,7 +30,9 @@ #include "compiler.h" #include "datapage.h" +#ifdef ARCH_PROVIDES_TIMER DEFINE_FALLBACK(gettimeofday, struct timeval *, tv, struct timezone *, tz) +#endif DEFINE_FALLBACK(clock_gettime, clockid_t, clock, struct timespec *, ts) DEFINE_FALLBACK(clock_getres, clockid_t, clock, struct timespec *, ts) @@ -291,30 +293,6 @@ static notrace int do_boottime(const struct vdso_data *vd, struct timespec *ts) return 0; } -#else /* ARCH_PROVIDES_TIMER */ - -static notrace int do_realtime(const struct vdso_data *vd, struct timespec *ts) -{ - return -1; -} - -static notrace int do_monotonic(const struct vdso_data *vd, struct timespec *ts) -{ - return -1; -} - -static notrace int do_monotonic_raw(const struct vdso_data *vd, - struct timespec *ts) -{ - return -1; -} - -static notrace int do_boottime(const struct vdso_data *vd, - struct timespec *ts) -{ - return -1; -} - #endif /* ARCH_PROVIDES_TIMER */ notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts) @@ -328,6 +306,7 @@ notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts) case CLOCK_MONOTONIC_COARSE: do_monotonic_coarse(vd, ts); break; +#ifdef ARCH_PROVIDES_TIMER case CLOCK_REALTIME: if (do_realtime(vd, ts)) goto fallback; @@ -344,6 +323,7 @@ notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts) if (do_boottime(vd, ts)) goto fallback; break; +#endif default: goto fallback; } @@ -353,6 +333,7 @@ notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts) return clock_gettime_fallback(clock, ts); } +#ifdef ARCH_PROVIDES_TIMER notrace int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz) { const struct vdso_data *vd = __get_datapage(); @@ -374,21 +355,28 @@ notrace int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz) return 0; } +#endif int __vdso_clock_getres(clockid_t clock, struct timespec *res) { long nsec; - if (clock == CLOCK_REALTIME || - clock == CLOCK_BOOTTIME || - clock == CLOCK_MONOTONIC || - clock == CLOCK_MONOTONIC_RAW) - nsec = MONOTONIC_RES_NSEC; - else if (clock == CLOCK_REALTIME_COARSE || - clock == CLOCK_MONOTONIC_COARSE) + switch (clock) { + case CLOCK_REALTIME_COARSE: + case CLOCK_MONOTONIC_COARSE: nsec = LOW_RES_NSEC; - else + break; +#ifdef ARCH_PROVIDES_TIMER + case CLOCK_REALTIME: + case CLOCK_MONOTONIC: + case CLOCK_MONOTONIC_RAW: + case CLOCK_BOOTTIME: + nsec = MONOTONIC_RES_NSEC; + break; +#endif + default: return clock_getres_fallback(clock, res); + } if (likely(res != NULL)) { res->tv_sec = 0; -- 2.15.0.403.gc27cc4dac6-goog From 1584372774571594041@xxx Sat Nov 18 03:27:02 +0000 2017 X-GM-THRID: 1584372774571594041 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread