Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1865152ybd; Sun, 23 Jun 2019 18:42:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCU3qZTXUM9xQGMvwnUCJD8tIbe9CPeUT+1uZT361onX0ExLno1Ki7ft/zxa3LHbabgAq6 X-Received: by 2002:a63:1d53:: with SMTP id d19mr30458856pgm.152.1561340534249; Sun, 23 Jun 2019 18:42:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561340534; cv=none; d=google.com; s=arc-20160816; b=lHriDv6Z5l4S74Ja1YbMSJMrlxezPYiG+Bxj4ihmph0NKTTjbi9Vuf1zOktuEvVuKC feXUe+sIL9F0Mgrvvwk6gUpR4AoxQjhMtAu1EpC07uOT+kblNUC6YQ6VlsIsIJEw8tfz 2kQfBIhy0pxukdhZUuQj5CiN6PapNnUAy/dFhHkhJ0ExKGNmMi/ULIF+FtjiOfjyxrxG WE4jySOoyz+E6oX17ue8Pm4u6qaZ6tT18M/nhAT5e2u14YSzWKqZD22cfaAWpsUvXNBD VvgdlorYHYUirfB1Bo47elAQHvYjH/X/7eXL3VUoyhN3qHUPho3tInDAujOloIWF9fVU 5TbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:dkim-signature:dkim-filter; bh=C0loTj/gJM3E6LeqWTO4cZ658sIJrg5v1gEhQqEsWQI=; b=kq/GG9UMvK5yfJRXV+3P53gBH29p0RqKB0g8tJM5CDxOlf49gxISgvhHXqkvTaAKvk cuHIGNGHQsYwwpNoCZtzgGwQgPp4i5Nhbp+P/sXwqRUPik6uQ6wMWUOW+N16OHyrdu45 396an9/blEhuRF3+/A+KOtNYym1658s7JDoMGQ4V0O/AXbF2EehTJWM6xIIJXMD7bcyl DwLHyMfUCAN0fA855bWxfl8ULeQlMasuBSNGax9EZxA12Go5tbfNEf0GsYz2GnmKuJIf 8nLftcp243Y6kAMT/2QUE3hwTfUpkSywpHsuLQ9TF+qLuuY9ku1Jgt+3ce/WLTAsBV6c /RnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=TUKsgWp4; 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=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11si8915515pgl.7.2019.06.23.18.41.58; Sun, 23 Jun 2019 18:42:14 -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=@zytor.com header.s=2019061801 header.b=TUKsgWp4; 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=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726793AbfFXBlY (ORCPT + 99 others); Sun, 23 Jun 2019 21:41:24 -0400 Received: from terminus.zytor.com ([198.137.202.136]:51211 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726566AbfFXBk6 (ORCPT ); Sun, 23 Jun 2019 21:40:58 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5NNu8Q22860229 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sun, 23 Jun 2019 16:56:08 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5NNu8Q22860229 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1561334169; bh=C0loTj/gJM3E6LeqWTO4cZ658sIJrg5v1gEhQqEsWQI=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=TUKsgWp49LtQCbE/1dui0MQq+iOocWjyJTWVBsXgJisRwxGn7zE9Nnn6qFOAXyi5k rbiNh+dSnwDWgspvBOv7i6uYZztGKnOzUyi1ys5DKEvLvb+68otF7kgbij+HVl6zHP CuOWya10OTw6kApxD7dwPk0WX5vtNt3oTgMZ+iBkHfIRCgHHpNwjl9PDSMfQZE2z7K wiPAwVfONIfCffYw1coA2sE2cajlXlOFEV4K9AK2D9ik6w1ylNlO9epzyzHyVqXrFb w0znDjufvVsdrt6tq/JHIY+E/KCW2e5t4wh5urstmmD9vlrqb3pi10qG+CbrUpgg7o alUonE3XYdcRA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5NNu7BY2860226; Sun, 23 Jun 2019 16:56:07 -0700 Date: Sun, 23 Jun 2019 16:56:07 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Vincenzo Frascino Message-ID: Cc: pcc@google.com, linux-kernel@vger.kernel.org, mingo@kernel.org, 0x7f454c46@gmail.com, salyzyn@android.com, andre.przywara@arm.com, vincenzo.frascino@arm.com, shuah@kernel.org, linux@armlinux.org.uk, linux@rasmusvillemoes.dk, paul.burton@mips.com, tglx@linutronix.de, catalin.marinas@arm.com, ralf@linux-mips.org, hpa@zytor.com, daniel.lezcano@linaro.org, sthotton@marvell.com, arnd@arndb.de, will.deacon@arm.com, huw@codeweavers.com Reply-To: hpa@zytor.com, catalin.marinas@arm.com, ralf@linux-mips.org, arnd@arndb.de, sthotton@marvell.com, daniel.lezcano@linaro.org, will.deacon@arm.com, huw@codeweavers.com, paul.burton@mips.com, tglx@linutronix.de, salyzyn@android.com, andre.przywara@arm.com, shuah@kernel.org, vincenzo.frascino@arm.com, linux@armlinux.org.uk, linux@rasmusvillemoes.dk, mingo@kernel.org, pcc@google.com, linux-kernel@vger.kernel.org, 0x7f454c46@gmail.com In-Reply-To: <20190621095252.32307-24-vincenzo.frascino@arm.com> References: <20190621095252.32307-24-vincenzo.frascino@arm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/vdso] x86/vdso: Add clock_getres() entry point Git-Commit-ID: f66501dc53e72079045a6a17e023b41316ede220 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=2.3 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_03_06,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF,FREEMAIL_FORGED_REPLYTO,FREEMAIL_REPLYTO_END_DIGIT autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f66501dc53e72079045a6a17e023b41316ede220 Gitweb: https://git.kernel.org/tip/f66501dc53e72079045a6a17e023b41316ede220 Author: Vincenzo Frascino AuthorDate: Fri, 21 Jun 2019 10:52:50 +0100 Committer: Thomas Gleixner CommitDate: Sat, 22 Jun 2019 21:21:10 +0200 x86/vdso: Add clock_getres() entry point The generic vDSO library provides an implementation of clock_getres() that can be leveraged by each architecture. Add the clock_getres() VDSO entry point on x86. [ tglx: Massaged changelog and cleaned up the function signature formatting ] Signed-off-by: Vincenzo Frascino Signed-off-by: Thomas Gleixner Cc: linux-arch@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Cc: linux-mips@vger.kernel.org Cc: linux-kselftest@vger.kernel.org Cc: Catalin Marinas Cc: Will Deacon Cc: Arnd Bergmann Cc: Russell King Cc: Ralf Baechle Cc: Paul Burton Cc: Daniel Lezcano Cc: Mark Salyzyn Cc: Peter Collingbourne Cc: Shuah Khan Cc: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Rasmus Villemoes Cc: Huw Davies Cc: Shijith Thotton Cc: Andre Przywara Link: https://lkml.kernel.org/r/20190621095252.32307-24-vincenzo.frascino@arm.com --- arch/x86/entry/vdso/vclock_gettime.c | 17 +++++++++++++++++ arch/x86/entry/vdso/vdso.lds.S | 2 ++ arch/x86/entry/vdso/vdso32/vdso32.lds.S | 1 + arch/x86/include/asm/vdso/gettimeofday.h | 31 +++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) diff --git a/arch/x86/entry/vdso/vclock_gettime.c b/arch/x86/entry/vdso/vclock_gettime.c index f01a3f0787ca..1a648b509d46 100644 --- a/arch/x86/entry/vdso/vclock_gettime.c +++ b/arch/x86/entry/vdso/vclock_gettime.c @@ -36,6 +36,7 @@ time_t time(time_t *t) __attribute__((weak, alias("__vdso_time"))); #if defined(CONFIG_X86_64) && !defined(BUILD_VDSO32_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); int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) { @@ -45,9 +46,18 @@ int __vdso_clock_gettime(clockid_t clock, struct __kernel_timespec *ts) int clock_gettime(clockid_t, struct __kernel_timespec *) __attribute__((weak, alias("__vdso_clock_gettime"))); +int __vdso_clock_getres(clockid_t clock, + struct __kernel_timespec *res) +{ + return __cvdso_clock_getres(clock, res); +} +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); int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts) { @@ -57,4 +67,11 @@ 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"))); +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/entry/vdso/vdso.lds.S b/arch/x86/entry/vdso/vdso.lds.S index d3a2dce4cfa9..36b644e16272 100644 --- a/arch/x86/entry/vdso/vdso.lds.S +++ b/arch/x86/entry/vdso/vdso.lds.S @@ -25,6 +25,8 @@ VERSION { __vdso_getcpu; time; __vdso_time; + clock_getres; + __vdso_clock_getres; local: *; }; } diff --git a/arch/x86/entry/vdso/vdso32/vdso32.lds.S b/arch/x86/entry/vdso/vdso32/vdso32.lds.S index 422764a81d32..991b26cc855b 100644 --- a/arch/x86/entry/vdso/vdso32/vdso32.lds.S +++ b/arch/x86/entry/vdso/vdso32/vdso32.lds.S @@ -26,6 +26,7 @@ VERSION __vdso_clock_gettime; __vdso_gettimeofday; __vdso_time; + __vdso_clock_getres; }; LINUX_2.5 { diff --git a/arch/x86/include/asm/vdso/gettimeofday.h b/arch/x86/include/asm/vdso/gettimeofday.h index 0e2650fc191b..f92752d6cbcf 100644 --- a/arch/x86/include/asm/vdso/gettimeofday.h +++ b/arch/x86/include/asm/vdso/gettimeofday.h @@ -24,6 +24,8 @@ #define VDSO_HAS_TIME 1 +#define VDSO_HAS_CLOCK_GETRES 1 + #ifdef CONFIG_PARAVIRT_CLOCK extern u8 pvclock_page[PAGE_SIZE] __attribute__((visibility("hidden"))); @@ -60,6 +62,18 @@ long gettimeofday_fallback(struct __kernel_old_timeval *_tv, return ret; } +static __always_inline +long clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts) +{ + long ret; + + asm ("syscall" : "=a" (ret), "=m" (*_ts) : + "0" (__NR_clock_getres), "D" (_clkid), "S" (_ts) : + "rcx", "r11"); + + return ret; +} + #else static __always_inline @@ -97,6 +111,23 @@ long gettimeofday_fallback(struct __kernel_old_timeval *_tv, return ret; } +static __always_inline long +clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts) +{ + long ret; + + asm ( + "mov %%ebx, %%edx \n" + "mov %[clock], %%ebx \n" + "call __kernel_vsyscall \n" + "mov %%edx, %%ebx \n" + : "=a" (ret), "=m" (*_ts) + : "0" (__NR_clock_getres_time64), [clock] "g" (_clkid), "c" (_ts) + : "edx"); + + return ret; +} + #endif #ifdef CONFIG_PARAVIRT_CLOCK