Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2486061ybd; Mon, 24 Jun 2019 07:15:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOOVLbJQoevfvfjiupTPZ2A+CeRYaLgd7Mp9S4yc3p+sV2zUJHW72zdK+f/DS/rIDHZCnZ X-Received: by 2002:a17:90a:cd04:: with SMTP id d4mr25864314pju.128.1561385749937; Mon, 24 Jun 2019 07:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561385749; cv=none; d=google.com; s=arc-20160816; b=xM7CHenYpAl/mmHZuerOhCKZfRKsAEyVL2YSRuL9ab8e4otCs1GICd1rGJhepdma0b FimuO12+pTHnRbBgtsTjikBeniu+T1fPKrFLNt7A1E1I8Z5yrTtXIDKI4Q6zQ6YWYSiL n6P34FsupLL2X7Mykh2mkmf9h19zcLzUm7Bmt5Uv77tRy6/aQpfhT80mTbWkFlPlQDMT o1iouTcx7n6gUxGiuwaQYmM5MU6A5DeYXinQFJTUyKzfw0Fnoq5NwkpMEKtZ9SdOD+BT sCXEN1/AHseziZmSplYfIfcfOQ6yPWEJ7o+JX+MlSGpGkIqwXZhv9EFjBnbwpG+XD1a/ sZ0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=mum4K3Z5tyHH2ZARv8NXC20RPeCqm5ZNVJyvOseh7ig=; b=VBrTB7deS8PtOY/UNqvqlw9R/hWan0eTLYVUbAMyJn4FJ0Q2PDM8jucCabEb6HZ1MQ CyBFBVNhDUOGH3jwGg8ZHZqhiXC2hj2+CnRaWH5H/2ZJXOSWr9QENrsBCoMG4v5KfAwK /kFQqfNyWQkdxIWehS4/6trXAFuI9xVKlmlHiz0RysYwdaI0EbrNkxAXXXh/5Z36YxX7 ButFAsP4fWxt+qDlrTvV3uaXASUdDAPvQgf02zGdhqpfV1e1fhKjrequFZ50tyHqYo18 idV2OdAroTHGtgqRDTa6ccnaWvNjEdddA+3q47l3ZJyy45dIwtxVz9YS3snCET4FpTrn IbkA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21si10287527pgd.544.2019.06.24.07.15.34; Mon, 24 Jun 2019 07:15:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729987AbfFXNgN (ORCPT + 99 others); Mon, 24 Jun 2019 09:36:13 -0400 Received: from foss.arm.com ([217.140.110.172]:50588 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725562AbfFXNgN (ORCPT ); Mon, 24 Jun 2019 09:36:13 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1D0E0344; Mon, 24 Jun 2019 06:36:12 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 859783F71E; Mon, 24 Jun 2019 06:36:09 -0700 (PDT) Date: Mon, 24 Jun 2019 14:36:07 +0100 From: Will Deacon To: Vincenzo Frascino Cc: linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-kselftest@vger.kernel.org, Catalin Marinas , Arnd Bergmann , Russell King , Ralf Baechle , Paul Burton , Daniel Lezcano , Thomas Gleixner , Mark Salyzyn , Peter Collingbourne , Shuah Khan , Dmitry Safonov <0x7f454c46@gmail.com>, Rasmus Villemoes , Huw Davies , Shijith Thotton , Andre Przywara Subject: Re: [PATCH v7 04/25] arm64: Substitute gettimeofday with C implementation Message-ID: <20190624133607.GI29497@fuggles.cambridge.arm.com> References: <20190621095252.32307-1-vincenzo.frascino@arm.com> <20190621095252.32307-5-vincenzo.frascino@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190621095252.32307-5-vincenzo.frascino@arm.com> User-Agent: Mutt/1.11.1+86 (6f28e57d73f2) () Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vincenzo, On Fri, Jun 21, 2019 at 10:52:31AM +0100, Vincenzo Frascino wrote: > To take advantage of the commonly defined vdso interface for > gettimeofday the architectural code requires an adaptation. > > Re-implement the gettimeofday vdso in C in order to use lib/vdso. > > With the new implementation arm64 gains support for CLOCK_BOOTTIME > and CLOCK_TAI. > > Cc: Catalin Marinas > Cc: Will Deacon > Signed-off-by: Vincenzo Frascino > Tested-by: Shijith Thotton > Tested-by: Andre Przywara > --- > arch/arm64/Kconfig | 2 + > arch/arm64/include/asm/vdso/gettimeofday.h | 86 ++++++ > arch/arm64/include/asm/vdso/vsyscall.h | 53 ++++ > arch/arm64/include/asm/vdso_datapage.h | 48 --- > arch/arm64/kernel/asm-offsets.c | 33 +- > arch/arm64/kernel/vdso.c | 51 +--- > arch/arm64/kernel/vdso/Makefile | 34 ++- > arch/arm64/kernel/vdso/gettimeofday.S | 334 --------------------- > arch/arm64/kernel/vdso/vgettimeofday.c | 28 ++ I'm concerned about an apparent semantic change introduced by your patch: > +static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) > +{ > + u64 res; > + > + asm volatile("mrs %0, cntvct_el0" : "=r" (res) :: "memory"); > + > + return res; > +} vs: > - .macro get_clock_shifted_nsec res, cycle_last, mult > - /* Read the virtual counter. */ > - isb > - mrs x_tmp, cntvct_el0 > - /* Calculate cycle delta and convert to ns. */ > - sub \res, x_tmp, \cycle_last > - /* We can only guarantee 56 bits of precision. */ > - movn x_tmp, #0xff00, lsl #48 > - and \res, x_tmp, \res > - mul \res, \res, \mult > - /* > - * Fake address dependency from the value computed from the counter > - * register to subsequent data page accesses so that the sequence > - * locking also orders the read of the counter. > - */ > - and x_tmp, \res, xzr > - add vdso_data, vdso_data, x_tmp > - .endm It looks like you're dropping both the preceding ISB (allowing the counter value to be speculated) and also the subsequent dependency (allowing the seq lock to be speculated). If I've missed them, apologies, but I couldn't spot them elsewhere in this patch. __arch_get_hw_counter should probably be identical to __arch_counter_get_cntvct to avoid these problems. I guess we don't need to care about the case where the counter is unstable, since we'll just disable the vDSO altogether on such systems? Will