Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp756143ybd; Wed, 26 Jun 2019 05:38:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqysCX7LJdPJ/6HLhJZyTXWQcX7DRHG1XNK7Qqo+R4zNDv1PviNuzwM+Uno6VL3iryi3s7BA X-Received: by 2002:a65:510c:: with SMTP id f12mr2721569pgq.92.1561552736136; Wed, 26 Jun 2019 05:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561552736; cv=none; d=google.com; s=arc-20160816; b=PVpwD8PjWOLhwO/Ll/FOV/axThDBvog76fkx2LyZ+Cfy8wK3z9nYrTkytzjHCfzjLo OZlcYe79AcRevLv31saQzRJorrqNwguxxgX0hNQUkmkypXLdaZKQNxxl1wOT95rVEefR DUzVc0Jbm+lnXsUYaFN0INUNblSFzKbqTjtCX9lnPIUxfbi3+zgLkk97FlAA4o/7ObIN LvZr6d259ClMuAb3RmsnZG9nDb2CuwIoMRc8KfFMKWmvYmL1u5JLhAgoF0y3yLYzRqQd WmDFbhV1MAkrGQ7ELlcYeoNNYkGvyOsJv6YP3kTMhwDtE4xhrkCTvOP9OWTnQdF7ppcN 9/6w== 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=XEYCA3vQc6FHmSM/ghRpCRXb5lwdekWXabaFoToGNeE=; b=qwymzsVbn8KVTWtNVRqT35mH7E/s7gfsQkgKZz4j5fVESY/DED3hWjLdSpjxToWmTh 0Fwi/PeWg+jUeU3eFGmST7nbsr6tZ7AVJCTwC8bViL5zdxqnZWMsJIDE3IyJBtDuGBzY zUF7WTWrLNCT4TnWNfr0Mv718qSAcIoBFezMd1Uoi/lw2BGlyVKkmNGTzZNJFtKbp6oe xhzhcHmj1vOHx+fQ9JO+UdvQDwTrEF35txusAYRasezw7oG+1cw3g4rVVkg1NHCVyZzZ sDR5yljZrjmEz5N0Z5A/VRjRUHD8NiRSoMxCjL77ExWHIo0915E61BR0L4cODnvoC0ll c+1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zytor.com header.s=2019061801 header.b=AaiMosiZ; 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 y21si3159300plp.332.2019.06.26.05.38.39; Wed, 26 Jun 2019 05:38:56 -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=AaiMosiZ; 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 S1727499AbfFZMiY (ORCPT + 99 others); Wed, 26 Jun 2019 08:38:24 -0400 Received: from terminus.zytor.com ([198.137.202.136]:53899 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbfFZMiY (ORCPT ); Wed, 26 Jun 2019 08:38:24 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x5QCcFFv4104794 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 26 Jun 2019 05:38:15 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x5QCcFFv4104794 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019061801; t=1561552695; bh=XEYCA3vQc6FHmSM/ghRpCRXb5lwdekWXabaFoToGNeE=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=AaiMosiZgJBkcuzlJ7XXUKaUb3XjqZTv1kOGYqYvVEYwis+8PN/2FIRJxaEPIKO8T KnCr92vtEsaQGjTf9SAJYicI8OwVb5u0wpmBi12vCXh/FuJgS2vP/SzQDkK+FVPV45 UBCWJTTHHekO/cucAPCau7ecTaSo65HhteqWkL8RnLcvmmy7JWzyIiz2VBK71d/9et RZbww2ZleuLx/IJe9D9JWY7ut+bQ20ddBNHKLliuPS94qcJWT7cOVLSlDBT89yBSYg iRZm344fpRSX1/B94cPODBKQqfa67nJircPxmVL9MZUtRHG7/rVxXadYPCmP7YdTnQ m7DJUSqzvQvPw== Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x5QCcEoW4104791; Wed, 26 Jun 2019 05:38:14 -0700 Date: Wed, 26 Jun 2019 05:38:14 -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: will.deacon@arm.com, vincenzo.frascino@arm.com, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com, tglx@linutronix.de Reply-To: catalin.marinas@arm.com, will.deacon@arm.com, mingo@kernel.org, hpa@zytor.com, tglx@linutronix.de, vincenzo.frascino@arm.com, linux-kernel@vger.kernel.org In-Reply-To: <20190625161804.38713-2-vincenzo.frascino@arm.com> References: <20190625161804.38713-2-vincenzo.frascino@arm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:timers/vdso] arm64: Fix __arch_get_hw_counter() implementation Git-Commit-ID: 27e11a9fe2e2e7e0d13f854e89a71e488678fb17 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: 27e11a9fe2e2e7e0d13f854e89a71e488678fb17 Gitweb: https://git.kernel.org/tip/27e11a9fe2e2e7e0d13f854e89a71e488678fb17 Author: Vincenzo Frascino AuthorDate: Tue, 25 Jun 2019 17:18:03 +0100 Committer: Thomas Gleixner CommitDate: Wed, 26 Jun 2019 14:26:54 +0200 arm64: 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-2-vincenzo.frascino@arm.com --- arch/arm64/include/asm/vdso/gettimeofday.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/include/asm/vdso/gettimeofday.h index 447ef417de45..b08f476b72b4 100644 --- a/arch/arm64/include/asm/vdso/gettimeofday.h +++ b/arch/arm64/include/asm/vdso/gettimeofday.h @@ -10,6 +10,8 @@ #include #include +#define __VDSO_USE_SYSCALL ULLONG_MAX + #define VDSO_HAS_CLOCK_GETRES 1 static __always_inline @@ -68,7 +70,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("mrs %0, cntvct_el0" : "=r" (res) :: "memory"); + /* + * This isb() is required to prevent that the seq lock is + * speculated.# + */ + isb(); return res; }