Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp361494imm; Mon, 1 Oct 2018 11:04:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV60MEqXSQcK6D8+nfld9Sgr5fWB/tXC39cSPs36Sru5IyNshUC/Mh32uHRNNnMm/ZAvzr82n X-Received: by 2002:a63:5021:: with SMTP id e33-v6mr11298430pgb.306.1538417096473; Mon, 01 Oct 2018 11:04:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538417096; cv=none; d=google.com; s=arc-20160816; b=0DcSzxDz/JhGsVsUGRfuF1uYuH50sLDaJa6gWZ2kBcNeRDdHvyLNExUIpgnK7+BF0c uEONLY1aw8gVea4gqy4CeBJVwBwneKmi3hlSc98VRO/c5w8ImkysZs1qQA6PY2BksDrV Ge9Ao1jUcuzKChmbIu/Xwe4a8Up/6OTLcuvcP5ZAs/7RB7UU9D7m6Slhq0h+DTO8xNiz yi82wAYgXazgJ15Q+NmlXTDcq8USIrKLhaBivjRb/QxsGBFrQ6OBqAILsT1v9axoG9i2 lHyPgpThwyIss0yEI04GxhUpaQl1aVXg2PMMycs/uBIYtiaqcXv4JAFPBAZ2y4WaZZF1 dG1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lmc2XUv+P+1oW72zR9jzXh3J8nwxNSWUYNvYRc9H7YM=; b=AeK4A6HWxBhq+F1lcgLjB/I8xIiUNm99hJqaHAaSv3g81qpioPQynG59hnR3EEw/kM 9ZgJXlCY3vvNatBQaHhHjIOzSjrF+Xwflex83aKAQ65Z/ACjvG/YJBdPR6sl7/Vir/54 olybwCojrH9+iKNYjFNR4bLJbc5LHkBdPgCsL8SlOBApPrydI8xFOIO3vmiuvbJktc6J nL/zi6owNWXmHdgC4APvGe0wi4noUiE1jGLOLigl5hdb0AO34C1LCAxLmFnLb8rp8tdN vbgxrsa4GhCfPEhsqo2IhAHzyeen0kfInEtjXDsxebMK7CxP1uVh0OMXBdvn/itci34U K0pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=AsYBu5rK; 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 b13-v6si11983182pgg.89.2018.10.01.11.04.34; Mon, 01 Oct 2018 11:04:56 -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; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=AsYBu5rK; 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 S1726519AbeJBAlp (ORCPT + 99 others); Mon, 1 Oct 2018 20:41:45 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:41242 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725948AbeJBAlo (ORCPT ); Mon, 1 Oct 2018 20:41:44 -0400 Received: by mail-pf1-f194.google.com with SMTP id m77-v6so9785028pfi.8 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=KmdSjRuEVjNFdCJkIioUqWCinN4VFY+DdOlIyDEzY9UcPIkVH3hErYpAiSbiEvPHUx 2WMeC1MqvxTwTk95ouQDTaW0Axzrt7Uich352XR+7nVXtpiY3vE6BQ0bEnbI30qUpAi1 2HjzIZTS5rytw9hwwt4UF5WWvfInJjQBjwt+sjQP5tpRVmSMVI2rG3QCIUTFcg92DwzV OWBWhKVXwtrtte81w2PTGNXMUUzXmYlhvGWzkXswD1pSDz4EmrAjTGwhtDHUU6/4gn3V RmuNZr7UarmpDi+fwtiU6qnxpIrfgLLKzy8fGVkNM+CGzWPENfs7ZEU6a6I24Lu2xpoy xwGg== X-Gm-Message-State: ABuFfohcwYYqqnCT+PpehUjwMBA4Ohf16e8fys3TgQdN9l5zaHyEE9mU DqMxmg5NOQBEGq+0J7xAkOj5YQ6S9p0= 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 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, Jeremy Linton , android-kernel@android.com, Mark Salyzyn , "Paul E. McKenney" , Ingo Molnar 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 Content-Transfer-Encoding: 8bit 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 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; -- 2.19.0.605.g01d371f741-goog