From patchwork Mon Oct 1 17:58:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salyzyn X-Patchwork-Id: 10622529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2DBC415A6 for ; Mon, 1 Oct 2018 18:11:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A39525D9E for ; Mon, 1 Oct 2018 18:11:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B1982843C; Mon, 1 Oct 2018 18:11:48 +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,RCVD_IN_DNSWL_NONE autolearn=ham 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 5418B25D9E for ; Mon, 1 Oct 2018 18:11:47 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=ZS+LN1N+xayMunB1z59hA3EU809ZWuvzzyjfUtweU5s=; b=nKoamWe8kQ10Dx ngjDoWsKggx1vsOoVtw/NmcG5XtEEsQ51Zsw6eTlOwQvRdEOyN3SSRqOvNvDN3OI+lOMgbmiRXQfp bhVLwLg9cE9oSlN7Kuod6IKYkqvtlchBx2t4FNXgxOWW6QYGoPO87QECgsTCTHXF2i/c1CLfhZJWr Cc9od/BzXVXFgU6nuplcy9Mkw2Lccld43nRh0hosJKHQxsFeWRuS/dOTyYHlfQU5khmkwjo+2Frr0 hf9UBGDetvx5mMWPllFrlg03kS/T38dS34lt6XmuCg3sD8lz9tsNIYYTJmoYVUXA+QrdX3c1oztd/ DFj1nClWbhfmgJhGWPeQ==; 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 1g72fW-0005E6-Pb; Mon, 01 Oct 2018 18:11:42 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g72X3-0007nH-Hq for linux-arm-kernel@lists.infradead.org; Mon, 01 Oct 2018 18:04:33 +0000 Received: by mail-pf1-x444.google.com with SMTP id d4-v6so9817310pfn.0 for ; Mon, 01 Oct 2018 11:02:47 -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 :mime-version:content-transfer-encoding; bh=lmc2XUv+P+1oW72zR9jzXh3J8nwxNSWUYNvYRc9H7YM=; b=AsYBu5rK4tBFneEGirRjn94Wl+QfMspE/iNaTm0mIuNKeR7+GbU77IyCGjcsycnW9P wfZVs71nuUyiriMxX8LGyflJMF4NehoE/daOAnLt4opapb8Yo/gQ9OyjBJR4c+ZhF9po 7V0BxtW7i//q6X3HPe08zDJxB+tu8e/utP/UturaWa3QCUxgCfiKhBF0YLSw2EZQHken gMxnfPfDr+ubnPXYIHfnGpe/FckqIgVadPVzxE8fe74aHSBvDgUlDA+2+9TqNrjWNNrT tCEysIdUq3LdFierSUO9efPQ6SGdco5QAsdD5G+l30z1cI18BnskS16N5ino6XixcHXn LWkQ== 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:mime-version:content-transfer-encoding; bh=lmc2XUv+P+1oW72zR9jzXh3J8nwxNSWUYNvYRc9H7YM=; b=sUPi3Wfysu1nv0Zp3V7O3uAqKbF8jYeAS7ce5df7JHvXgrZA2lBFBDm7fi5oOMcEXM 7BsMDqFl6Qbx9IMoMKj6z6hzwyEyPkDAkGe7KyyzVts/hseB8Yf5rW6M1y2ZT9JyvrpL c5xUmEk7RQDRIg0OsPTRNT6bKa3yr0WJSuA/69OqrEvppvev7Dw0vbMY8r5F6h7xfOwB GS+Jxpj6KsapTqaC1AZ9RJ0KflrpozgnQaFQZ/RdPau3oLIWhkuGQ85YZzZ2TBA5817k SIZeqS2iUqUnf2GUPOll53q55QSaHfz19zi29i46fuAEP+PVQB8QF3koURwsWUATnnB9 Hsrg== X-Gm-Message-State: ABuFfohTEW+MxyttKDZ6BSyYs2seIXlwqnjiCdsWnphL7IF5jvR9sJtP DmIbDpJOF1OB9bqBC8RjwemLXg== X-Google-Smtp-Source: ACcGV607qp09x0eTHqM1eLgMXGYQ5Wi4CUra6lnRryJJ2F8LfRP/h3UtJ9y2KzXieXhQgMwiSUH2Zg== X-Received: by 2002:a65:47cb:: with SMTP id f11-v6mr11405197pgs.166.1538416966352; Mon, 01 Oct 2018 11:02:46 -0700 (PDT) Received: from nebulus.mtv.corp.google.com ([2620:0:1000:1612:b4fb:6752:f21f:3502]) by smtp.gmail.com with ESMTPSA id d186-v6sm24469261pfg.173.2018.10.01.11.02.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 11:02:45 -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, 1 Oct 2018 10:58:32 -0700 Message-Id: <20181001175845.168430-13-salyzyn@android.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog In-Reply-To: <20181001175845.168430-1-salyzyn@android.com> References: <20181001175845.168430-1-salyzyn@android.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181001_110257_762099_2BF630FE X-CRM114-Status: GOOD ( 19.64 ) 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 , Catalin Marinas , Will Deacon , Mark Salyzyn , Ingo Molnar , Russell King , Andy Gross , Laura Abbott , Mark Salyzyn , Kees Cook , Kevin Brodsky , John Stultz , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, "Paul E. McKenney" , Ard Biesheuvel , Dmitry Safonov , android-kernel@android.com, Jeremy Linton , Andy Lutomirski , James Morse , Andrew Pinski 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 Tested-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 Cc: android-kernel@android.com 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;