From patchwork Mon Jun 18 15:05:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 10472021 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EF0E601D7 for ; Mon, 18 Jun 2018 15:16:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CDC328BA0 for ; Mon, 18 Jun 2018 15:16:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5192A28BC8; Mon, 18 Jun 2018 15:16:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B376D28BA0 for ; Mon, 18 Jun 2018 15:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=H3qcSacZNxX5UNV+BbpvHE2na4ENaVswiftPT4yIF/8=; b=CGtXNTgULBcKDP2kAx5KW4DCAn KYUp37OzPcGSS5fFDu4fzjV0Wz/3k3CB+PgFoNSCm9yBO0sQdmDapiQUx7M6VqnfT5R0DWTDAr95y I8G8M5WDkkLf1CMzvb2/bmTAjtO0iwrmjr2O2T9TG86f2AJXVuYOw0Cr38hDnZOA7dCUd8sERoF6c iH5T/l/nZmvMm+5pPldObnckz9ym+WOMHrUwCUh6NRPzN/9Dim/e//23tcbwF0f9gOgjFFM1kFbLm IR2RQd2Tpsv1lGDZ4mBp80AvsGRyCEyNyb8tmJJrbsMvOdv3k876EFGky4vOrdkEj48FMYYnDK/Xg hB7Se5yA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUvt4-0007Li-4m; Mon, 18 Jun 2018 15:16:10 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fUvlx-0000qg-9O for linux-arm-kernel@lists.infradead.org; Mon, 18 Jun 2018 15:08:51 +0000 Received: by mail-pg0-x243.google.com with SMTP id a14-v6so7665550pgw.10 for ; Mon, 18 Jun 2018 08:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=49j1iPAN3lGCmW9h/UZLYMoEo97FvFLn1KGgxCvlTkw=; b=f0kcZLXUMZcaSZwalkzDlDYwVhULX4TpkaMlTpcw6ftH5C/yiKeJuos33so0GaCgyv pCSsPogMBij8vs8tXZPP7WUjzoBddo4QqaFQLGw8ORxleAt2qYJ/MNYAM0GlnupgSB3v V4gG5dF8MviBO+urLPPW2YoXup7YTqOO04v4qTwpmdgfuof19D8CRkifGvSX8kOSzGIT 1HhHRn1gKitzKkIa+fWPFLYIcJgOhVw07TbpfpoZ5lVCZXhnMA5QrFu7rjuOLpfzjSMM /e6BYtg8UZ6kWVhDzAOxYqAiBe4eSKBA6irjpTSJsijjfNMw8uCkhGFsTW/KNhX+z5vQ gr+A== 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:in-reply-to :references; bh=49j1iPAN3lGCmW9h/UZLYMoEo97FvFLn1KGgxCvlTkw=; b=l6NFnzo3VFXfD7J+BQZ6P6wBG9aHc4+m1W37nrvzeBJ5m45H5FIpsDpcPlNE2vUM7N PRyFMGh/wSPf1poYjt+GB200YwsJ+xXCDbMAMSPZ6m//5g63/Ci93CAm0DLQYuup7bMu yLRd4ZzuH/aJ7U2m23Rined4oHfA31f3gB7dR5h5rfFvTTfWsHyqXPiC23gx+5yZjbfJ d8dvrg9CLJsbCR2ak1mYuBSdCaEawZnjwAu2d9HP1D+096W6X4prxmquL6/oE3gXHAX0 fFLzslHC92Abb+xyCXHXc4smnd9iWLpb7hqG75oAm6OVG9dGEyEjuBy2mIWSRJfT/Cv8 6TIw== X-Gm-Message-State: APt69E2p0h2i+tcsqOB9TLr3tol+qH1vgKjMA04UvEbEE9K6nTJ3lf49 3CsBJln+B/AZXEhVBmWbPAsJjg== X-Google-Smtp-Source: ADUXVKI8MT1ODJlafUnT8XhHSYO0Do0ruWCNEtSvyeIkeuk5qhdcuGX2shKp5Vtq0lOm3Q8UE/V/EQ== X-Received: by 2002:a63:a05d:: with SMTP id u29-v6mr11226843pgn.80.1529334518582; Mon, 18 Jun 2018 08:08:38 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:0:1000:1611:6077:8eec:bc7e:d0f4]) by smtp.gmail.com with ESMTPSA id i7-v6sm54830660pfa.34.2018.06.18.08.08.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 08:08:37 -0700 (PDT) From: Mark Salyzyn To: linux-kernel@vger.kernel.org Subject: RESEND [PATCH v5 12/12] lib: vdso: do not expose gettimeofday, if no arch supported timer Date: Mon, 18 Jun 2018 08:05:58 -0700 Message-Id: <20180618150613.10322-13-salyzyn@android.com> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog In-Reply-To: <20180618150613.10322-1-salyzyn@android.com> References: <20180618150613.10322-1-salyzyn@android.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180618_080849_350776_44BEF9C0 X-CRM114-Status: GOOD ( 19.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Laura Abbott , Kees Cook , Ard Biesheuvel , "Paul E. McKenney" , Catalin Marinas , Kevin Brodsky , Will Deacon , Russell King , Jeremy Linton , Andy Lutomirski , Mark Salyzyn , James Morse , Andrew Pinski , Dmitry Safonov , Andy Gross , John Stultz , Thomas Gleixner , Mark Salyzyn , Ingo Molnar , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Jeremy Linton 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 4c3af7bc6499..54e519c99c4b 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) @@ -292,30 +294,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) @@ -329,6 +307,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; @@ -345,6 +324,7 @@ notrace int __vdso_clock_gettime(clockid_t clock, struct timespec *ts) if (do_boottime(vd, ts)) goto fallback; break; +#endif default: goto fallback; } @@ -354,6 +334,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(); @@ -375,21 +356,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;