From patchwork Thu Feb 28 11:58:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10832843 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 1098C15AC for ; Thu, 28 Feb 2019 11:59:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EED0D2E443 for ; Thu, 28 Feb 2019 11:59:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1A662E47F; Thu, 28 Feb 2019 11:59:40 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 9C70B2E443 for ; Thu, 28 Feb 2019 11:59:39 +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=Akm1SJfWOvH5BTlUU5clwGgP7FFHSoTVdJlqjfWpTwo=; b=jxfFxEmbeneflT Vr/Ev7yYdjPJIXjPNoZgTutwTf4ib1JYWxg9yGZyLLF/551OfQ5Dll/3agJsX/Sm29/zmPs1B+Vvw RW98rbJ7v7Ug9Pxe1xFCoJEZJRcIRBeteRukgV79nz4ZzyllosLJzhzBZtiFd1s/7dFZJ/aol6AdP cpJ/THpnJFqAnODpucBHzh8JDJdnmAW4O2XJaBtaGROG7vxe/9vKeIa7RG8BqGbGOhvKj7ZBo59iz jhoBEo1g/4p2Trt2i2hWmcrK4iFLvxeMEzbg6B+WWCQSC6cEt9z6cIdy2oO0XvzQ+bcfhawyps4Wo ty5FUOALtlbCNz9r4WJg==; 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 1gzKLi-0008Lr-SK; Thu, 28 Feb 2019 11:59:38 +0000 Received: from mout.kundenserver.de ([217.72.192.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzKLR-00086c-JS for linux-arm-kernel@lists.infradead.org; Thu, 28 Feb 2019 11:59:24 +0000 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1M2wbS-1h0Pjh17CG-003MtD; Thu, 28 Feb 2019 12:59:05 +0100 From: Arnd Bergmann To: Vincenzo Frascino Subject: [PATCH 1/2] vdso: use fixed-size time types Date: Thu, 28 Feb 2019 12:58:54 +0100 Message-Id: <20190228115855.610027-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: References: MIME-Version: 1.0 X-Provags-ID: V03:K1:8lSERYlJxx3bsPrNFdPA7jWxQa1iQqVuMG6j8zvtrgNVb1+sDEh OASp6JeneJL3uGX+gtBjGCoHI5gsiEaVn0dFGhsBIHsXEL/nSdGXoX46UT779kzYzXz4WGg BoKvGfFnU+4xs3NLz4Ko7NliEM+rz1/ZJFs2q8dqyZINVtY7GAVC2EkXhIFDR8XGOuPTE0+ 8EbbLG9eLW5zp05inOYHw== X-UI-Out-Filterresults: notjunk:1;V03:K0:YkDY29BeDUk=:QAOJ5lRhIXpcGWgYbwuX+h sbeJtYzNRTXG/U/bwAL/7UXPg9jLO+YovXjthjo9kvSm3P57SQBWSMOSNmLclbSbngBpbHA4R CAurnXITguUVKY6Al5gpP/hexMWjCPFTt+23ZBzvOwAyAcFYsxzs8eWhgD5NEgRpZmENf0oLb ItwZ5mZFf9EWHYz4iY5za0qjHsPTBnOsQv6rVfZ80UBSlssJUTQPR6zVu4hX/p11DqClzuHF0 nJC/6SAsN+dF93kp1V8yNoycPsr/PoY81zTdJ+aPbRfLS7wDxXHMO+aoo8djM2ePEdazSxEn4 mTC0M87d4f5OZwxYKw78r+qLKcah3l5n39kyxKsH7dP6U71D396p+IPqL3UxOEcGv8aPNJD4T WqhZEq9Z91RbrRKvXIqgvrTY21Z6KRBsFOnCrsTJq84XnJtDVP1XOZ5sXZoiKb7jkQOSldf68 zzMdfRx9BeFhmLEU77D1ZBoFOVu+KHp5do4+8qEYheNxJryBNOc142F6JAhQdrnO/r/GReZJU mSp45seVl2LxNG5AJ8mbTlYHn1SuS3tHK0bDlDVZl9UF3kYbTarAJ5iPro4XDhgyM9QTKFb5q E3RYnrBGiBjk83sN6d9r7GxylV7SdyuevuOqZSqU9RajK05hD3TJhrp3AKGqCm486BY2VDlE3 vdUM2M5+P3ZBHDXdTX12xFRUi0oBw5Y/yGG8xX/6inRYQKs+4zny1KIMThI/ZJtAfgBNzn3ov 1UMH50JTGRLFoRl3s6HAdmj15DLOqVEbDT0q8Q== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190228_035922_092362_ACA10394 X-CRM114-Status: GOOD ( 15.02 ) 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: linux-arch@vger.kernel.org, Shuah Khan , Arnd Bergmann , Catalin Marinas , Daniel Lezcano , Will Deacon , Russell King , Ralf Baechle , Mark Salyzyn , Paul Burton , Dmitry Safonov <0x7f454c46@gmail.com>, Rasmus Villemoes , Thomas Gleixner , Peter Collingbourne , linux-arm-kernel@lists.infradead.org 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 Hi Vincento, I've implemented now what I tried to explain earlier. This moves the implementation of clock_gettime() and clock_getres() over to 64-bit __kernel_timespec, with a conversion in the end for architectures that actually use the 32-bit calls. The vdso/types.h file is now obsolete, but we do need to duplicate a few functions on mips32 and x86-32. It may be possible to fold those into the generic lib/vdso/gettimeofday.c file as another step. If there are no objections, please fold these changes into your series. Signed-off-by: Arnd Bergmann --- arch/arm/include/asm/vdso/gettimeofday.h | 16 +++--- arch/arm/vdso/vgettimeofday.c | 10 ++-- .../include/asm/vdso/compat_gettimeofday.h | 16 +++--- arch/arm64/include/asm/vdso/gettimeofday.h | 12 ++-- arch/arm64/kernel/vdso/vgettimeofday.c | 6 +- arch/arm64/kernel/vdso32/vgettimeofday.c | 14 +++-- arch/mips/include/asm/vdso/gettimeofday.h | 22 ++++--- arch/mips/vdso/vgettimeofday.c | 28 ++++++++- arch/x86/entry/vdso/vclock_gettime.c | 57 +++++++++++++------ arch/x86/include/asm/vdso/gettimeofday.h | 16 +++--- include/vdso/datapage.h | 1 - include/vdso/types.h | 39 ------------- lib/vdso/gettimeofday.c | 48 +++++++++++----- 13 files changed, 164 insertions(+), 121 deletions(-) delete mode 100644 include/vdso/types.h diff --git a/arch/arm/include/asm/vdso/gettimeofday.h b/arch/arm/include/asm/vdso/gettimeofday.h index e7aeda0b255f..112df50920b0 100644 --- a/arch/arm/include/asm/vdso/gettimeofday.h +++ b/arch/arm/include/asm/vdso/gettimeofday.h @@ -14,11 +14,11 @@ extern struct vdso_data *__get_datapage(void); static __always_inline notrace int gettimeofday_fallback( - struct __vdso_timeval *_tv, + struct __kernel_old_timeval *_tv, struct timezone *_tz) { register struct timezone *tz asm("r1") = _tz; - register struct __vdso_timeval *tv asm("r0") = _tv; + register struct __kernel_old_timeval *tv asm("r0") = _tv; register long ret asm ("r0"); register long nr asm("r7") = __NR_gettimeofday; @@ -33,12 +33,12 @@ static __always_inline notrace int gettimeofday_fallback( static __always_inline notrace long clock_gettime_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { - register struct __vdso_timespec *ts asm("r1") = _ts; + register struct __kernel_timespec *ts asm("r1") = _ts; register clockid_t clkid asm("r0") = _clkid; register long ret asm ("r0"); - register long nr asm("r7") = __NR_clock_gettime; + register long nr asm("r7") = __NR_clock_gettime64; asm volatile( " swi #0\n" @@ -51,12 +51,12 @@ static __always_inline notrace long clock_gettime_fallback( static __always_inline notrace int clock_getres_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { - register struct __vdso_timespec *ts asm("r1") = _ts; + register struct __kernel_timespec *ts asm("r1") = _ts; register clockid_t clkid asm("r0") = _clkid; register long ret asm ("r0"); - register long nr asm("r7") = __NR_clock_getres; + register long nr asm("r7") = __NR_clock_getres_time64; asm volatile( " swi #0\n" diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c index b470a8ed35a7..b4607a5ecf31 100644 --- a/arch/arm/vdso/vgettimeofday.c +++ b/arch/arm/vdso/vgettimeofday.c @@ -9,21 +9,21 @@ #include notrace int __vdso_clock_gettime(clockid_t clock, - struct __vdso_timespec *ts) + struct old_timespec32 *ts) { - return __cvdso_clock_gettime(clock, ts); + return __cvdso_clock_gettime32(clock, ts); } -notrace int __vdso_gettimeofday(struct __vdso_timeval *tv, +notrace int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); } notrace int __vdso_clock_getres(clockid_t clock_id, - struct __vdso_timespec *res) + struct old_timespec32 *res) { - return __cvdso_clock_getres(clock_id, res); + return __cvdso_clock_getres_time32(clock_id, res); } /* Avoid unresolved references emitted by GCC */ diff --git a/arch/arm64/include/asm/vdso/compat_gettimeofday.h b/arch/arm64/include/asm/vdso/compat_gettimeofday.h index 888c70c24f71..b41d8f01a20c 100644 --- a/arch/arm64/include/asm/vdso/compat_gettimeofday.h +++ b/arch/arm64/include/asm/vdso/compat_gettimeofday.h @@ -24,11 +24,11 @@ extern struct vdso_data _vdso_data __attribute__((visibility("hidden"))); static __always_inline notrace int gettimeofday_fallback( - struct __vdso_timeval *_tv, + struct __kernel_old_timeval *_tv, struct timezone *_tz) { register struct timezone *tz asm("r1") = _tz; - register struct __vdso_timeval *tv asm("r0") = _tv; + register struct __kernel_old_timeval *tv asm("r0") = _tv; register long ret asm ("r0"); register long nr asm("r7") = __NR_compat_gettimeofday; @@ -43,12 +43,12 @@ static __always_inline notrace int gettimeofday_fallback( static __always_inline notrace long clock_gettime_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { - register struct __vdso_timespec *ts asm("r1") = _ts; + register struct __kernel_timespec *ts asm("r1") = _ts; register clockid_t clkid asm("r0") = _clkid; register long ret asm ("r0"); - register long nr asm("r7") = __NR_compat_clock_gettime; + register long nr asm("r7") = __NR_compat_clock_gettime64; asm volatile( " swi #0\n" @@ -61,12 +61,12 @@ static __always_inline notrace long clock_gettime_fallback( static __always_inline notrace int clock_getres_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { - register struct __vdso_timespec *ts asm("r1") = _ts; + register struct __kernel_timespec *ts asm("r1") = _ts; register clockid_t clkid asm("r0") = _clkid; register long ret asm ("r0"); - register long nr asm("r7") = __NR_compat_clock_getres; + register long nr asm("r7") = __NR_compat_clock_getres_time64; /* The checks below are required for ABI consistency with arm */ if ((_clkid >= MAX_CLOCKS) || (_ts == NULL)) diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/include/asm/vdso/gettimeofday.h index 0aff6362533f..126fc6f4f7cf 100644 --- a/arch/arm64/include/asm/vdso/gettimeofday.h +++ b/arch/arm64/include/asm/vdso/gettimeofday.h @@ -13,11 +13,11 @@ extern struct vdso_data _vdso_data; static __always_inline notrace int gettimeofday_fallback( - struct __vdso_timeval *_tv, + struct __kernel_old_timeval *_tv, struct timezone *_tz) { register struct timezone *tz asm("x1") = _tz; - register struct __vdso_timeval *tv asm("x0") = _tv; + register struct __kernel_old_timeval *tv asm("x0") = _tv; register long ret asm ("x0"); register long nr asm("x8") = __NR_gettimeofday; @@ -32,9 +32,9 @@ static __always_inline notrace int gettimeofday_fallback( static __always_inline notrace long clock_gettime_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { - register struct __vdso_timespec *ts asm("x1") = _ts; + register struct __kernel_timespec *ts asm("x1") = _ts; register clockid_t clkid asm("x0") = _clkid; register long ret asm ("x0"); register long nr asm("x8") = __NR_clock_gettime; @@ -50,9 +50,9 @@ static __always_inline notrace long clock_gettime_fallback( static __always_inline notrace int clock_getres_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { - register struct __vdso_timespec *ts asm("x1") = _ts; + register struct __kernel_timespec *ts asm("x1") = _ts; register clockid_t clkid asm("x0") = _clkid; register long ret asm ("x0"); register long nr asm("x8") = __NR_clock_getres; diff --git a/arch/arm64/kernel/vdso/vgettimeofday.c b/arch/arm64/kernel/vdso/vgettimeofday.c index 160e68196339..bbc83b6e2b1a 100644 --- a/arch/arm64/kernel/vdso/vgettimeofday.c +++ b/arch/arm64/kernel/vdso/vgettimeofday.c @@ -9,19 +9,19 @@ #include notrace int __kernel_clock_gettime(clockid_t clock, - struct __vdso_timespec *ts) + struct __kernel_timespec *ts) { return __cvdso_clock_gettime(clock, ts); } -notrace int __kernel_gettimeofday(struct __vdso_timeval *tv, +notrace int __kernel_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); } notrace int __kernel_clock_getres(clockid_t clock_id, - struct __vdso_timespec *res) + struct __kernel_timespec *res) { return __cvdso_clock_getres(clock_id, res); } diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c index b470a8ed35a7..6762f800a8ea 100644 --- a/arch/arm64/kernel/vdso32/vgettimeofday.c +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c @@ -9,21 +9,27 @@ #include notrace int __vdso_clock_gettime(clockid_t clock, - struct __vdso_timespec *ts) + struct old_timespec32 *ts) +{ + return __cvdso_clock_gettime32(clock, ts); +} + +notrace int __vdso_clock_gettime64(clockid_t clock, + struct __kernel_timespec *ts) { return __cvdso_clock_gettime(clock, ts); } -notrace int __vdso_gettimeofday(struct __vdso_timeval *tv, +notrace int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); } notrace int __vdso_clock_getres(clockid_t clock_id, - struct __vdso_timespec *res) + struct old_timespec32 *res) { - return __cvdso_clock_getres(clock_id, res); + return __cvdso_clock_getres_time32(clock_id, res); } /* Avoid unresolved references emitted by GCC */ diff --git a/arch/mips/include/asm/vdso/gettimeofday.h b/arch/mips/include/asm/vdso/gettimeofday.h index b275392f6b1b..ed6dafda5fc2 100644 --- a/arch/mips/include/asm/vdso/gettimeofday.h +++ b/arch/mips/include/asm/vdso/gettimeofday.h @@ -25,11 +25,11 @@ #ifdef CONFIG_MIPS_CLOCK_VSYSCALL static __always_inline notrace long gettimeofday_fallback( - struct __vdso_timeval *_tv, + struct __kernel_old_timeval *_tv, struct timezone *_tz) { register struct timezone *tz asm("a1") = _tz; - register struct __vdso_timeval *tv asm("a0") = _tv; + register struct __kernel_old_timeval *tv asm("a0") = _tv; register long ret asm("v0"); register long nr asm("v0") = __NR_gettimeofday; register long error asm("a3"); @@ -47,7 +47,7 @@ static __always_inline notrace long gettimeofday_fallback( #else static __always_inline notrace long gettimeofday_fallback( - struct __vdso_timeval *_tv, + struct __kernel_old_timeval *_tv, struct timezone *_tz) { return -1; @@ -57,12 +57,16 @@ static __always_inline notrace long gettimeofday_fallback( static __always_inline notrace long clock_gettime_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { - register struct __vdso_timespec *ts asm("a1") = _ts; + register struct __kernel_timespec *ts asm("a1") = _ts; register clockid_t clkid asm("a0") = _clkid; register long ret asm("v0"); +#if _MIPS_SIM == _MIPS_SIM_ABI64 register long nr asm("v0") = __NR_clock_gettime; +#else + register long nr asm("v0") = __NR_clock_gettime64 +#endif register long error asm("a3"); asm volatile( @@ -77,12 +81,16 @@ static __always_inline notrace long clock_gettime_fallback( static __always_inline notrace int clock_getres_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { - register struct __vdso_timespec *ts asm("a1") = _ts; + register struct __kernel_timespec *ts asm("a1") = _ts; register clockid_t clkid asm("a0") = _clkid; register long ret asm("v0"); +#if _MIPS_SIM == _MIPS_SIM_ABI64 register long nr asm("v0") = __NR_clock_getres; +#else + register long nr asm("v0") = __NR_clock_getres64 +#endif register long error asm("a3"); asm volatile( diff --git a/arch/mips/vdso/vgettimeofday.c b/arch/mips/vdso/vgettimeofday.c index 8da361d919f0..7a3320faa29a 100644 --- a/arch/mips/vdso/vgettimeofday.c +++ b/arch/mips/vdso/vgettimeofday.c @@ -8,21 +8,43 @@ #include #include +#if _MIPS_SIM != _MIPS_SIM_ABI64 notrace int __vdso_clock_gettime(clockid_t clock, - struct __vdso_timespec *ts) + struct old_timespec32 *ts) +{ + return __cvdso_clock_gettime32(clock, ts); +} + +notrace int __vdso_gettimeofday(struct __kernel_old_timeval *tv, + struct timezone *tz) +{ + return __cvdso_gettimeofday_time32(tv, tz); +} + +notrace int __vdso_clock_getres(clockid_t clock_id, + struct old_timespec32 *res) +{ + return __cvdso_clock_getres_time32(clock_id, res); +} + +#else + +notrace int __vdso_clock_gettime(clockid_t clock, + struct __kernel_timespec *ts) { return __cvdso_clock_gettime(clock, ts); } -notrace int __vdso_gettimeofday(struct __vdso_timeval *tv, +notrace int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); } notrace int __vdso_clock_getres(clockid_t clock_id, - struct __vdso_timespec *res) + struct __kernel_timespec *res) { return __cvdso_clock_getres(clock_id, res); } +#endif diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c index 6ff8cabf4c3e..c9512c114ac1 100644 --- a/arch/x86/entry/vdso/vclock_gettime.c +++ b/arch/x86/entry/vdso/vclock_gettime.c @@ -12,25 +12,14 @@ #include "../../../../lib/vdso/gettimeofday.c" -extern int __vdso_clock_gettime(clockid_t clock, struct __vdso_timespec *ts); -extern int __vdso_gettimeofday(struct __vdso_timeval *tv, struct timezone *tz); +extern int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz); extern time_t __vdso_time(time_t *t); -extern int __vdso_clock_getres(clockid_t clock, struct __vdso_timespec *res); - -notrace int __vdso_clock_gettime(clockid_t clock, struct __vdso_timespec *ts) -{ - return __cvdso_clock_gettime(clock, ts); -} - -int clock_gettime(clockid_t, struct __vdso_timespec *) - __attribute__((weak, alias("__vdso_clock_gettime"))); - -notrace int __vdso_gettimeofday(struct __vdso_timeval *tv, +notrace int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { return __cvdso_gettimeofday(tv, tz); } -int gettimeofday(struct __vdso_timeval *, struct timezone *) +int gettimeofday(struct __kernel_old_timeval *, struct timezone *) __attribute__((weak, alias("__vdso_gettimeofday"))); notrace time_t __vdso_time(time_t *t) @@ -40,10 +29,46 @@ notrace time_t __vdso_time(time_t *t) time_t time(time_t *t) __attribute__((weak, alias("__vdso_time"))); + +#ifdef __x86_64__ +/* both 64-bit and x32 use these */ +extern int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts); +extern int __vdso_clock_getres(clockid_t clock, struct __kernel_timespec *res); + +notrace int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) +{ + return __cvdso_clock_gettime(clock, ts); +} + +int clock_gettime(clockid_t, struct __kernel_timespec *) + __attribute__((weak, alias("__vdso_clock_gettime"))); + notrace int __vdso_clock_getres(clockid_t clock, - struct __vdso_timespec *res) + struct __kernel_timespec *res) { return __cvdso_clock_getres(clock, res); } -int clock_getres(clockid_t, struct __vdso_timespec *) +int clock_getres(clockid_t, struct __kernel_timespec *) + __attribute__((weak, alias("__vdso_clock_getres"))); + +#else +/* i386 only */ +extern int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts); +extern int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res); + +notrace int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) +{ + return __cvdso_clock_gettime32(clock, ts); +} + +int clock_gettime(clockid_t, struct old_timespec32 *) + __attribute__((weak, alias("__vdso_clock_gettime"))); + +notrace int __vdso_clock_getres(clockid_t clock, + struct old_timespec32 *res) +{ + return __cvdso_clock_getres_time32(clock, res); +} +int clock_getres(clockid_t, struct old_timespec32 *) __attribute__((weak, alias("__vdso_clock_getres"))); +#endif diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h index 1a86fdc1e400..510a0ebd5748 100644 --- a/arch/x86/include/asm/vdso/gettimeofday.h +++ b/arch/x86/include/asm/vdso/gettimeofday.h @@ -38,7 +38,7 @@ extern u8 hvclock_page static __always_inline notrace long clock_gettime_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { long ret; asm ("syscall" : "=a" (ret), "=m" (*_ts) : @@ -48,7 +48,7 @@ static __always_inline notrace long clock_gettime_fallback( } static __always_inline notrace long gettimeofday_fallback( - struct __vdso_timeval *_tv, + struct __kernel_old_timeval *_tv, struct timezone *_tz) { long ret; @@ -59,7 +59,7 @@ static __always_inline notrace long gettimeofday_fallback( static __always_inline notrace long clock_getres_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { long ret; asm ("syscall" : "=a" (ret), "=m" (*_ts) : @@ -72,7 +72,7 @@ static __always_inline notrace long clock_getres_fallback( static __always_inline notrace long clock_gettime_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { long ret; @@ -82,13 +82,13 @@ static __always_inline notrace long clock_gettime_fallback( "call __kernel_vsyscall \n" "mov %%edx, %%ebx \n" : "=a" (ret), "=m" (*_ts) - : "0" (__NR_clock_gettime), [clock] "g" (_clkid), "c" (_ts) + : "0" (__NR_clock_gettime64), [clock] "g" (_clkid), "c" (_ts) : "edx"); return ret; } static __always_inline notrace long gettimeofday_fallback( - struct __vdso_timeval *_tv, + struct __kernel_old_timeval *_tv, struct timezone *_tz) { long ret; @@ -105,7 +105,7 @@ static __always_inline notrace long gettimeofday_fallback( static __always_inline notrace long clock_getres_fallback( clockid_t _clkid, - struct __vdso_timespec *_ts) + struct __kernel_timespec *_ts) { long ret; @@ -115,7 +115,7 @@ static __always_inline notrace long clock_getres_fallback( "call __kernel_vsyscall \n" "mov %%edx, %%ebx \n" : "=a" (ret), "=m" (*_ts) - : "0" (__NR_clock_getres), [clock] "g" (_clkid), "c" (_ts) + : "0" (__NR_clock_getres_time64), [clock] "g" (_clkid), "c" (_ts) : "edx"); return ret; } diff --git a/include/vdso/datapage.h b/include/vdso/datapage.h index ff332fcba73c..da346ad02b03 100644 --- a/include/vdso/datapage.h +++ b/include/vdso/datapage.h @@ -9,7 +9,6 @@ #include #include #include -#include #define VDSO_BASES (CLOCK_TAI + 1) #define VDSO_HRES (BIT(CLOCK_REALTIME) | \ diff --git a/include/vdso/types.h b/include/vdso/types.h deleted file mode 100644 index f456a0a6a2e1..000000000000 --- a/include/vdso/types.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __VDSO_TYPES_H -#define __VDSO_TYPES_H - -#ifdef __KERNEL__ - -#ifndef __ASSEMBLY__ - -#include -#include - -/* - * The definitions below are required to overcome the limitations - * of time_t on 32 bit architectures, which overflows in 2038. - * The new code should use the replacements based on time64_t and - * timespec64. - * - * The abstraction below will be updated once the migration to - * time64_t is complete. - */ -#ifdef CONFIG_GENERIC_VDSO_32 -#define __vdso_timespec old_timespec32 -#define __vdso_timeval old_timeval32 -#else -#ifdef ENABLE_COMPAT_VDSO -#define __vdso_timespec old_timespec32 -#define __vdso_timeval old_timeval32 -#else -#define __vdso_timespec __kernel_timespec -#define __vdso_timeval __kernel_old_timeval -#endif /* CONFIG_COMPAT_VDSO */ -#endif /* CONFIG_GENERIC_VDSO_32 */ - - -#endif /* !__ASSEMBLY__ */ - -#endif /* __KERNEL__ */ - -#endif /* __VDSO_TYPES_H */ diff --git a/lib/vdso/gettimeofday.c b/lib/vdso/gettimeofday.c index 466d0c68fa80..f10e3703abaa 100644 --- a/lib/vdso/gettimeofday.c +++ b/lib/vdso/gettimeofday.c @@ -28,7 +28,7 @@ static notrace int do_hres(const struct vdso_data *vd, clockid_t clk, - struct __vdso_timespec *ts) + struct __kernel_timespec *ts) { const struct vdso_timestamp *vdso_ts = &vd->basetime[clk]; u64 cycles, last, sec, ns; @@ -63,7 +63,7 @@ static notrace int do_hres(const struct vdso_data *vd, static notrace void do_coarse(const struct vdso_data *vd, clockid_t clk, - struct __vdso_timespec *ts) + struct __kernel_timespec *ts) { const struct vdso_timestamp *vdso_ts = &vd->basetime[clk]; u32 seq; @@ -75,8 +75,8 @@ static notrace void do_coarse(const struct vdso_data *vd, } while (unlikely(vdso_read_retry(vd, seq))); } -static notrace int __cvdso_clock_gettime(clockid_t clock, - struct __vdso_timespec *ts) +static notrace __maybe_unused int +__cvdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) { const struct vdso_data *vd = __arch_get_vdso_data(); u32 msk; @@ -100,19 +100,31 @@ static notrace int __cvdso_clock_gettime(clockid_t clock, return clock_gettime_fallback(clock, ts); } -static notrace int __cvdso_gettimeofday(struct __vdso_timeval *tv, - struct timezone *tz) +static notrace __maybe_unused int +__cvdso_clock_gettime32(clockid_t clock, struct old_timespec32 *res) +{ + struct __kernel_timespec ts; + int ret = __cvdso_clock_gettime(clock, &ts); + + res->tv_sec = ts.tv_sec; + res->tv_nsec = ts.tv_nsec; + + return ret; +} + +static notrace __maybe_unused int +__cvdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { const struct vdso_data *vd = __arch_get_vdso_data(); if (likely(tv != NULL)) { - struct __vdso_timespec ts; + struct __kernel_timespec ts; if (do_hres(vd, CLOCK_REALTIME, &ts)) return gettimeofday_fallback(tv, tz); tv->tv_sec = ts.tv_sec; - tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC; + tv->tv_usec = (u32)ts.tv_nsec / NSEC_PER_USEC; } if (unlikely(tz != NULL)) { @@ -123,8 +135,7 @@ static notrace int __cvdso_gettimeofday(struct __vdso_timeval *tv, return 0; } -#ifdef VDSO_HAS_TIME -static notrace time_t __cvdso_time(time_t *time) +static notrace __maybe_unused time_t __cvdso_time(time_t *time) { const struct vdso_data *vd = __arch_get_vdso_data(); time_t t = READ_ONCE(vd->basetime[CLOCK_REALTIME].sec); @@ -134,10 +145,9 @@ static notrace time_t __cvdso_time(time_t *time) return t; } -#endif /* VDSO_HAS_TIME */ -static notrace int __cvdso_clock_getres(clockid_t clock, - struct __vdso_timespec *res) +static notrace __maybe_unused +int __cvdso_clock_getres(clockid_t clock, struct __kernel_timespec *res) { u64 sec, ns; u32 msk; @@ -177,3 +187,15 @@ static notrace int __cvdso_clock_getres(clockid_t clock, fallback: return clock_getres_fallback(clock, res); } + +static notrace __maybe_unused int +__cvdso_clock_getres_time32(clockid_t clock, struct old_timespec32 *res) +{ + struct __kernel_timespec ts; + int ret = __cvdso_clock_getres(clock, &ts); + + res->tv_sec = ts.tv_sec; + res->tv_nsec = ts.tv_nsec; + + return ret; +} From patchwork Thu Feb 28 11:58:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10832841 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 7F750139A for ; Thu, 28 Feb 2019 11:59:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A6B82E436 for ; Thu, 28 Feb 2019 11:59:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D8762E454; Thu, 28 Feb 2019 11:59:28 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 DD91E2E436 for ; Thu, 28 Feb 2019 11:59:27 +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=YJl2dPgFsfnXcw+Ze5j7ldtbR2mfuD+StolelEc8B/I=; b=XNCNJAaoDrK3LR IqqG9lNYIDcglW3gAWXp8P5qQ1G+vF7V16jsMt/cd9s8bAuRYQy/TawpZQHowe3jB12++BLHIoyd7 uHvbS6cSOI2HVM1cp7i9yiI3dAF4dlNzbxVRcq5BXP6SHIgipZng8zzvK4WdME0fmMa4XCLDAwhg2 LR1ynqSW9yGDfb66GBYbo4HydwNgWyPqWF945vJuQC9ops56erW6Htl0PMp9ioZE19WTS8u1el/sz uivNEbd80aNLFwXJtDOwFeCGWCTOp8tEkJndOMQwO9oGnXy22AUYO7O7mqprejGpH5EfPsMHPcnE0 OQtRkkWw5i8PVvQQINTw==; 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 1gzKLT-00087A-UC; Thu, 28 Feb 2019 11:59:23 +0000 Received: from mout.kundenserver.de ([217.72.192.74]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gzKLR-00086d-Ak for linux-arm-kernel@lists.infradead.org; Thu, 28 Feb 2019 11:59:23 +0000 Received: from wuerfel.lan ([109.192.41.194]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1M42X0-1gzKLC2pgO-00056B; Thu, 28 Feb 2019 12:59:06 +0100 From: Arnd Bergmann To: Vincenzo Frascino Subject: [PATCH 2/2] vdso: add clock_gettime64 Date: Thu, 28 Feb 2019 12:58:55 +0100 Message-Id: <20190228115855.610027-2-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190228115855.610027-1-arnd@arndb.de> References: <20190228115855.610027-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:SODFCYswHdUPOd4RbT8zmOnLgULPc2Qu7XHVUJWnotjvQjFSjpn asssOkx4NpKIKUG9PPKzzV3kVwiTMOsh4T56ABH8hr7jPxphUw5k2FdkIs8hrM0GurZWWn8 2I/NL1MVDAiUYYJAwIRfkLLi0heLyBDBWqKlYU9OPbWKpSkrTYZV7nhJZmLlAC177qIGZeh UMFR8tlKJSgxg3wZidWHA== X-UI-Out-Filterresults: notjunk:1;V03:K0:CE7etOE00ck=:SiX7yXLB666aXjRAFEQqDB QVrOv4HRuktfkqz/nT13hNcRoTfRUKsnjJjVWcqFWuPH8PrqNTyO7sBMqn3gjxqQE2iAgCSmD W80TGugwPEJH2Z4vFvDuu5mLIWnWVxCjIGCHwR3pAn8bcxmCNaIIjtqpHR5GRtqJAZIRTUELJ fzl20JlROprqcf2fEdCPKa+J1axymngwR21VPlCZFJmg0LGQayvIc8ihnUC0KcznP3WFjmYmV dfvQHArh+HtOD4HOeR0IawAi/9fIbfnMdjZKxEugs5sBDBhpErExp3f5TVPlTLPtl7uw/rY6X zjXxEPziTjWL7TZLFX2rVlNpac2rjU+ncU/RdJ2NHvPZ+9TQdHuRwr+V2od1LXAynCz8oHoaN 1/wKqNsY+1apjW/w4q+0lMe7imXo6aufPfJL/bDmc2zJFuhyjB9s7wuPyV9Mt2j5eQc7y+l7R efUdnhnFWMIpKD+nHFgqeA14YPhLawT3O4wLuOH1MwHH/eMIW1yZ3DrNVh/nnJrrG7ywMPPMZ 2zIzySP+QyZQ1kfe9QVSTB/mWl8na9WyNE0Yd1890JANnit4f9dlba+sWcigEAEZcfNuYj6rf 3YQQG6C7naxElCuj75h+i5MnRiDPoBpva1GaD6iwvboJuwd33wBX59zhYlbGOQPxSE+8llLqk B97wNJQlsVHLdPXpL1zbbPmp4AdfdyjEuBWKYEiPCQYiQaBHdIkC01Rx2UPT8FpgT/ehe0ueW MP6GxQ6YZddQIMx3cpJd2Z7s4VI9EhUeVCezWw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190228_035921_672934_6C89864C X-CRM114-Status: GOOD ( 10.80 ) 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: linux-arch@vger.kernel.org, Shuah Khan , Arnd Bergmann , Catalin Marinas , Daniel Lezcano , Will Deacon , Russell King , Ralf Baechle , Mark Salyzyn , Paul Burton , Dmitry Safonov <0x7f454c46@gmail.com>, Rasmus Villemoes , Thomas Gleixner , Peter Collingbourne , linux-arm-kernel@lists.infradead.org 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 Adding a clock_gettime64() vdso call on all32-bit machines is now trivial. Signed-off-by: Arnd Bergmann --- arch/arm/vdso/vdso.lds.S | 1 + arch/arm/vdso/vgettimeofday.c | 6 ++++++ arch/arm64/kernel/vdso32/vdso.lds.S | 1 + arch/mips/vdso/vdso.lds.S | 3 +++ arch/mips/vdso/vgettimeofday.c | 6 ++++++ arch/x86/entry/vdso/vclock_gettime.c | 6 ++++++ arch/x86/entry/vdso/vdso32/vdso32.lds.S | 1 + 7 files changed, 24 insertions(+) diff --git a/arch/arm/vdso/vdso.lds.S b/arch/arm/vdso/vdso.lds.S index 1d81e8c3acf6..05581140fd12 100644 --- a/arch/arm/vdso/vdso.lds.S +++ b/arch/arm/vdso/vdso.lds.S @@ -83,6 +83,7 @@ VERSION __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; + __vdso_clock_gettime64; local: *; }; } diff --git a/arch/arm/vdso/vgettimeofday.c b/arch/arm/vdso/vgettimeofday.c index b4607a5ecf31..6762f800a8ea 100644 --- a/arch/arm/vdso/vgettimeofday.c +++ b/arch/arm/vdso/vgettimeofday.c @@ -14,6 +14,12 @@ notrace int __vdso_clock_gettime(clockid_t clock, return __cvdso_clock_gettime32(clock, ts); } +notrace int __vdso_clock_gettime64(clockid_t clock, + struct __kernel_timespec *ts) +{ + return __cvdso_clock_gettime(clock, ts); +} + notrace int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz) { diff --git a/arch/arm64/kernel/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S index 4fd3093ea78c..a3944927eaeb 100644 --- a/arch/arm64/kernel/vdso32/vdso.lds.S +++ b/arch/arm64/kernel/vdso32/vdso.lds.S @@ -68,6 +68,7 @@ VERSION __kernel_sigreturn_thumb; __kernel_rt_sigreturn_arm; __kernel_rt_sigreturn_thumb; + __vdso_clock_gettime64; local: *; }; } diff --git a/arch/mips/vdso/vdso.lds.S b/arch/mips/vdso/vdso.lds.S index 90b2c2785e32..659fe0c3750a 100644 --- a/arch/mips/vdso/vdso.lds.S +++ b/arch/mips/vdso/vdso.lds.S @@ -100,6 +100,9 @@ VERSION __vdso_clock_gettime; __vdso_gettimeofday; __vdso_clock_getres; +#if _MIPS_SIM != _MIPS_SIM_ABI64 + __vdso_clock_gettime64; +#endif #endif local: *; }; diff --git a/arch/mips/vdso/vgettimeofday.c b/arch/mips/vdso/vgettimeofday.c index 7a3320faa29a..0b4fea088f89 100644 --- a/arch/mips/vdso/vgettimeofday.c +++ b/arch/mips/vdso/vgettimeofday.c @@ -27,6 +27,12 @@ notrace int __vdso_clock_getres(clockid_t clock_id, return __cvdso_clock_getres_time32(clock_id, res); } +notrace int __vdso_clock_gettime_time64(clockid_t clock, + struct __kernel_timespec *ts) +{ + return __cvdso_clock_gettime(clock, ts); +} + #else notrace int __vdso_clock_gettime(clockid_t clock, diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c index c9512c114ac1..0a7d4bdeadc9 100644 --- a/arch/x86/entry/vdso/vclock_gettime.c +++ b/arch/x86/entry/vdso/vclock_gettime.c @@ -54,6 +54,7 @@ int clock_getres(clockid_t, struct __kernel_timespec *) #else /* i386 only */ extern int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts); +extern int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts); extern int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res); notrace int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) @@ -64,6 +65,11 @@ notrace int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) int clock_gettime(clockid_t, struct old_timespec32 *) __attribute__((weak, alias("__vdso_clock_gettime"))); +notrace int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts) +{ + return __cvdso_clock_gettime(clock, ts); +} + notrace int __vdso_clock_getres(clockid_t clock, struct old_timespec32 *res) { diff --git a/arch/x86/entry/vdso/vdso32/vdso32.lds.S b/arch/x86/entry/vdso/vdso32/vdso32.lds.S index 991b26cc855b..c7720995ab1a 100644 --- a/arch/x86/entry/vdso/vdso32/vdso32.lds.S +++ b/arch/x86/entry/vdso/vdso32/vdso32.lds.S @@ -27,6 +27,7 @@ VERSION __vdso_gettimeofday; __vdso_time; __vdso_clock_getres; + __vdso_clock_gettime64; }; LINUX_2.5 {