From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Gleixner Subject: Re: [PATCH v2 06/28] kernel: Define gettimeofday vdso common code Date: Wed, 13 Feb 2019 20:35:32 +0100 (CET) Message-ID: References: <20181129170530.37789-1-vincenzo.frascino@arm.com> <20181129170530.37789-7-vincenzo.frascino@arm.com> <20181207175321.GA11430@edgewater-inn.cambridge.arm.com> <20190208173539.GD24375@fuggles.cambridge.arm.com> <20190213170413.GE6346@brain-police> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190213170413.GE6346@brain-police> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: Will Deacon Cc: linux-arch@vger.kernel.org, Arnd Bergmann , marc.zyngier@arm.com, Catalin Marinas , Daniel Lezcano , Russell King , Ralf Baechle , Mark Salyzyn , Paul Burton , Vincenzo Frascino , Peter Collingbourne , linux-arm-kernel@lists.infradead.org List-Id: linux-arch.vger.kernel.org On Wed, 13 Feb 2019, Will Deacon wrote: > On Fri, Feb 08, 2019 at 08:30:25PM +0100, Thomas Gleixner wrote: > > > > How is the in kernel ktime_get() correctness guaranteed then? > > Luck. > > I think we'll have to introduce a dummy dependent stack read into our > counter accessor so that it's ordered by the smp_rmb(). Example diff > below, which I'll roll into a proper patch series later on. Yikes. > static inline u64 arch_counter_get_cntpct(void) > { > + u64 cnt, tmp; > + > isb(); > - return arch_timer_reg_read_stable(cntpct_el0); > + cnt = arch_timer_reg_read_stable(cntpct_el0); > + > + /* > + * This insanity brought to you by speculative, out-of-order system > + * register reads, sequence locks and Thomas Gleixner. ROTFL From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from Galois.linutronix.de ([146.0.238.70]:47492 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726291AbfBMTfi (ORCPT ); Wed, 13 Feb 2019 14:35:38 -0500 Date: Wed, 13 Feb 2019 20:35:32 +0100 (CET) From: Thomas Gleixner Subject: Re: [PATCH v2 06/28] kernel: Define gettimeofday vdso common code In-Reply-To: <20190213170413.GE6346@brain-police> Message-ID: References: <20181129170530.37789-1-vincenzo.frascino@arm.com> <20181129170530.37789-7-vincenzo.frascino@arm.com> <20181207175321.GA11430@edgewater-inn.cambridge.arm.com> <20190208173539.GD24375@fuggles.cambridge.arm.com> <20190213170413.GE6346@brain-police> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-arch-owner@vger.kernel.org List-ID: To: Will Deacon Cc: Vincenzo Frascino , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , Arnd Bergmann , Russell King , Ralf Baechle , Paul Burton , Daniel Lezcano , Mark Salyzyn , Peter Collingbourne , marc.zyngier@arm.com Message-ID: <20190213193532.CCwnf3PjsskASupIWzJdxqf9NTpoEnl_NFX5uuddTkE@z> On Wed, 13 Feb 2019, Will Deacon wrote: > On Fri, Feb 08, 2019 at 08:30:25PM +0100, Thomas Gleixner wrote: > > > > How is the in kernel ktime_get() correctness guaranteed then? > > Luck. > > I think we'll have to introduce a dummy dependent stack read into our > counter accessor so that it's ordered by the smp_rmb(). Example diff > below, which I'll roll into a proper patch series later on. Yikes. > static inline u64 arch_counter_get_cntpct(void) > { > + u64 cnt, tmp; > + > isb(); > - return arch_timer_reg_read_stable(cntpct_el0); > + cnt = arch_timer_reg_read_stable(cntpct_el0); > + > + /* > + * This insanity brought to you by speculative, out-of-order system > + * register reads, sequence locks and Thomas Gleixner. ROTFL