Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp757901ybd; Wed, 26 Jun 2019 05:40:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/7AxDw/9ncrcFsDMX6XrdYSIyCprIdpwemT6X5ZvSOGZ+5EdgkE9u5JGHpgIquv5cUNDI X-Received: by 2002:a17:902:bd0a:: with SMTP id p10mr5340225pls.134.1561552848441; Wed, 26 Jun 2019 05:40:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561552848; cv=none; d=google.com; s=arc-20160816; b=xTOHHd06zdvI/OWrvkPC4nBTpp5v8N1DDqTs9TLACgkzPmWFOtVymxWqcmxBPuSSfp CKqzOiveVn2t7aR+7iss/gtuSHZSAB/gR6Do/misnr76NGN9b3RJdNzjmqjRqkhU7fmT D1NTQH6h6VnILSnd1XpsWQziAezEQL9Xm0iNJGzdxBgkGU1NealDEejWDxKvd76E99BE O4UIl4ob63dDucQCcb+LmpJfkAxRRdNAimWwV5Sxk7wqZi8b4XjVuiXb5bI9PCi1Y/gK jk0TIXxQrGxAvq5EO9+wfljsP/ilPri6333au3T/gLxqUkcvZ+OuIniF4SJBq5wyT6lp VB4w== 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=dAaEZGvy9qdqJmr0mW2LtwUrDRbyw+2VWaF0BtcV8To=; b=OjiOrIJv7u7qqOl0Jv82EqNFIb1cBb1mJ57U6ZN9OIHCCXzi3vi2pdPU2Hpb8D9GIa wBo8kylgIQtk8dBUZ+fJxKAj7I0xNs60Yn7tkFFAK1PSJ1Y8Q6Pu/t7sCCdbu51uqF5I UamDS29ozRk534Muzl9WwDttsC+X3h5WWEve58uGg/QkHGEHaRhAkicWxAGJA1pR0Hh0 fHxCe+ZgkoUdEcFkwoI5PeZl7jKijNrVfVJzbIRMScTanN1U/N1xEOKm/rk9upzIfTE5 SZex/U+3lalNtJW7feqyxxjguc5CmDrEWeRfR8YgYsC2HcGM9p/a0gkKipRovuCwH5JU aJfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=crroid2D; 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 f7si15901795pgq.404.2019.06.26.05.40.31; Wed, 26 Jun 2019 05:40:48 -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=crroid2D; 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 S1727468AbfFZMjK (ORCPT + 99 others); Wed, 26 Jun 2019 08:39:10 -0400 Received: from terminus.zytor.com ([198.137.202.136]:47567 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726339AbfFZMjK (ORCPT ); Wed, 26 Jun 2019 08:39:10 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5QCd1tc4104848 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 26 Jun 2019 05:39:01 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5QCd1tc4104848 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1561552741; bh=dAaEZGvy9qdqJmr0mW2LtwUrDRbyw+2VWaF0BtcV8To=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=crroid2Dgj22+BpkZWbHE/qlKaaN/lssiG1by/i8iKQFgik50YrUecVCxa10acRqj NHLBAAb7/duOz0J7yiEuYxJehMBlLDYruBo/jLm/cLw4wVPwo0gbmgu6CpZBjncWdt qU1jTdzerwNhEVywc2uVD6qVXVFxq0vxWz341fCN8ni2EBJy+AmBwMqEV72OS4MyyI m3rQzF6p7KLliH6GqSdY0Fhz70NOZgs7r63BZHe8YR4lv/yRzwvREEKRro33S6tcco 4pX6JA9w1a3xJ4XEfoDgCAGVbiukBfD5zhhnYxthykxqx+NkhcqsJWyBIYUcPYQB8l +pSz4+RYgfvhA== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5QCd0US4104845; Wed, 26 Jun 2019 05:39:00 -0700 Date: Wed, 26 Jun 2019 05:39:00 -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: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, tglx@linutronix.de, vincenzo.frascino@arm.com, mingo@kernel.org, hpa@zytor.com, will.deacon@arm.com Reply-To: hpa@zytor.com, will.deacon@arm.com, mingo@kernel.org, tglx@linutronix.de, vincenzo.frascino@arm.com, linux-kernel@vger.kernel.org, catalin.marinas@arm.com In-Reply-To: <20190625161804.38713-3-vincenzo.frascino@arm.com> References: <20190625161804.38713-3-vincenzo.frascino@arm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/vdso] arm64: compat: Fix __arch_get_hw_counter() implementation Git-Commit-ID: 6241c4dc6ec56a7627b972959da8b492b765b209 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=0.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_12_24,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, DKIM_VALID_EF autolearn=no autolearn_force=no version=3.4.2 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: 6241c4dc6ec56a7627b972959da8b492b765b209 Gitweb: https://git.kernel.org/tip/6241c4dc6ec56a7627b972959da8b492b765b209 Author: Vincenzo Frascino AuthorDate: Tue, 25 Jun 2019 17:18:04 +0100 Committer: Thomas Gleixner CommitDate: Wed, 26 Jun 2019 14:26:54 +0200 arm64: compat: Fix __arch_get_hw_counter() implementation Provide the following fixes for the __arch_get_hw_counter() implementation on arm64: - Fallback on syscall when an unstable counter is detected. - Introduce isb()s before and after the counter read to avoid speculation of the counter value and of the seq lock respectively. The second isb() is a temporary solution that will be revisited in 5.3-rc1. These fixes restore the semantics that __arch_counter_get_cntvct() had on arm64. 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@arm.com Cc: will.deacon@arm.com Cc: arnd@arndb.de Cc: linux@armlinux.org.uk Cc: ralf@linux-mips.org Cc: paul.burton@mips.com Cc: daniel.lezcano@linaro.org Cc: salyzyn@android.com Cc: pcc@google.com Cc: shuah@kernel.org Cc: 0x7f454c46@gmail.com Cc: linux@rasmusvillemoes.dk Cc: huw@codeweavers.com Cc: sthotton@marvell.com Cc: andre.przywara@arm.com Cc: Catalin Marinas Cc: Will Deacon Link: https://lkml.kernel.org/r/20190625161804.38713-3-vincenzo.frascino@arm.com --- arch/arm64/include/asm/vdso/compat_gettimeofday.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/include/asm/vdso/compat_gettimeofday.h b/arch/arm64/include/asm/vdso/compat_gettimeofday.h index 93dbd935b66d..f4812777f5c5 100644 --- a/arch/arm64/include/asm/vdso/compat_gettimeofday.h +++ b/arch/arm64/include/asm/vdso/compat_gettimeofday.h @@ -12,6 +12,8 @@ #include +#define __VDSO_USE_SYSCALL ULLONG_MAX + #define VDSO_HAS_CLOCK_GETRES 1 static __always_inline @@ -74,8 +76,24 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) { u64 res; + /* + * clock_mode == 0 implies that vDSO are enabled otherwise + * fallback on syscall. + */ + if (clock_mode) + return __VDSO_USE_SYSCALL; + + /* + * This isb() is required to prevent that the counter value + * is speculated. + */ isb(); asm volatile("mrrc p15, 1, %Q0, %R0, c14" : "=r" (res)); + /* + * This isb() is required to prevent that the seq lock is + * speculated. + */ + isb(); return res; }