From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752483AbdGFAAw (ORCPT ); Wed, 5 Jul 2017 20:00:52 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:15136 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751896AbdGFAAv (ORCPT ); Wed, 5 Jul 2017 20:00:51 -0400 Date: Thu, 6 Jul 2017 01:00:34 +0100 From: "Maciej W. Rozycki" To: Aleksandar Markovic CC: , Goran Ferenc , Miodrag Dinic , Aleksandar Markovic , Douglas Leung , James Hogan , , Paul Burton , Petar Jovanovic , Raghu Gandham , Ralf Baechle Subject: Re: [PATCH v2 2/4] MIPS: VDSO: Add implementation of clock_gettime() fallback In-Reply-To: <1498665337-28845-3-git-send-email-aleksandar.markovic@rt-rk.com> Message-ID: References: <1498665337-28845-1-git-send-email-aleksandar.markovic@rt-rk.com> <1498665337-28845-3-git-send-email-aleksandar.markovic@rt-rk.com> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [10.20.78.94] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Jun 2017, Aleksandar Markovic wrote: > diff --git a/arch/mips/vdso/gettimeofday.c b/arch/mips/vdso/gettimeofday.c > index fd7d433..5f63375 100644 > --- a/arch/mips/vdso/gettimeofday.c > +++ b/arch/mips/vdso/gettimeofday.c > @@ -20,6 +20,24 @@ > #include > #include > > +static __always_inline long clock_gettime_fallback(clockid_t _clkid, > + struct timespec *_ts) > +{ > + register struct timespec *ts asm("a1") = _ts; > + register clockid_t clkid asm("a0") = _clkid; > + register long ret asm("v0"); > + register long nr asm("v0") = __NR_clock_gettime; > + register long error asm("a3"); > + > + asm volatile( > + " syscall\n" > + : "=r" (ret), "=r" (error) > + : "r" (clkid), "r" (ts), "r" (nr) > + : "memory"); > + > + return error ? -ret : ret; > +} Hmm, are you sure it is safe nowadays WRT the syscall restart convention to leave out the instruction explicitly loading the syscall number that would normally immediately precede SYSCALL (and would have to forcibly use the 32-bit encoding in the microMIPS case)? Maciej From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailapp01.imgtec.com ([195.59.15.196]:59964 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S23993879AbdGFAAzWovkG (ORCPT ); Thu, 6 Jul 2017 02:00:55 +0200 Date: Thu, 6 Jul 2017 01:00:34 +0100 From: "Maciej W. Rozycki" Subject: Re: [PATCH v2 2/4] MIPS: VDSO: Add implementation of clock_gettime() fallback In-Reply-To: <1498665337-28845-3-git-send-email-aleksandar.markovic@rt-rk.com> Message-ID: References: <1498665337-28845-1-git-send-email-aleksandar.markovic@rt-rk.com> <1498665337-28845-3-git-send-email-aleksandar.markovic@rt-rk.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Return-Path: Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-subscribe: List-owner: List-post: List-archive: To: Aleksandar Markovic Cc: linux-mips@linux-mips.org, Goran Ferenc , Miodrag Dinic , Aleksandar Markovic , Douglas Leung , James Hogan , linux-kernel@vger.kernel.org, Paul Burton , Petar Jovanovic , Raghu Gandham , Ralf Baechle Message-ID: <20170706000034.bJ2COaZFyHYlbYb4erw1J7IkZb4GTHajU-S2FQecGfs@z> On Wed, 28 Jun 2017, Aleksandar Markovic wrote: > diff --git a/arch/mips/vdso/gettimeofday.c b/arch/mips/vdso/gettimeofday.c > index fd7d433..5f63375 100644 > --- a/arch/mips/vdso/gettimeofday.c > +++ b/arch/mips/vdso/gettimeofday.c > @@ -20,6 +20,24 @@ > #include > #include > > +static __always_inline long clock_gettime_fallback(clockid_t _clkid, > + struct timespec *_ts) > +{ > + register struct timespec *ts asm("a1") = _ts; > + register clockid_t clkid asm("a0") = _clkid; > + register long ret asm("v0"); > + register long nr asm("v0") = __NR_clock_gettime; > + register long error asm("a3"); > + > + asm volatile( > + " syscall\n" > + : "=r" (ret), "=r" (error) > + : "r" (clkid), "r" (ts), "r" (nr) > + : "memory"); > + > + return error ? -ret : ret; > +} Hmm, are you sure it is safe nowadays WRT the syscall restart convention to leave out the instruction explicitly loading the syscall number that would normally immediately precede SYSCALL (and would have to forcibly use the 32-bit encoding in the microMIPS case)? Maciej