Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3712644ybl; Sun, 15 Dec 2019 16:22:26 -0800 (PST) X-Google-Smtp-Source: APXvYqyfD96jSOcPVZia5DN0oQpLZenBninFtn09SqPZHM1CMBSGgXXVpVtS6yZnjgT7BVHssQx3 X-Received: by 2002:a05:6830:10a:: with SMTP id i10mr27700163otp.365.1576455746467; Sun, 15 Dec 2019 16:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576455746; cv=none; d=google.com; s=arc-20160816; b=ydvoYrh/7apBD2asWMYX9Keaz3nPBIOklSd7x+HTgB3PMr9XViElI7PG2qcJqkT86V BkTdFgsZv5akfDi5O1L8YIShN06DchOnP5JQ5YUBEBSX1yIeVPXWwGKmJh4KqFa5l+GP f+NkzM2+8gKHGfU3XALLrm5LoknQYAR8GBQ90xAW07J1wz4uKiCw47mLQ0oofi/C2n9Z sQZbgmbhgKRNn2aa7WLVAYp34cMjASSeu1out73ZDS9tyF+3kJ59ghRq0ejQlH3I/8t+ MwPzk6DqxyDYbI6QK0zlPpn2cqqKRkQsXPfUiaxFPER3Ns4e5X2gfaXTNnDJ/S/p2WL0 pmjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7S615KofXaQ1yUG/3GM94cEkec6rvE87OWT0R1mkHVE=; b=Fybs/h8Nd0VZ5mIAX6Oc8hoKG/pi+j4gIPulqcCYSMP6GY/iuIqAaS5QsGwUC7uKlu KLdVqnMxpPoZRB+rQCjl+zhoUxKHhm6T/jV/yjOaoNrzpRyt7GgOTkSXoZAHej2skmB9 +fW/XANmDBQwlQ4x4X5b324W5bTLVf3TwOIgX955Tvq+XfZ4FDjkUuZccpGf6tfWzKqK UROQ92PLcrem5ZM0wGo5Vu+m+GMTAH7UrwC0CspNUKMAHxOOyXyMioTE4MqYS6Gqc0IP 2BtmRyN9eAJBFXRSnQBmItGmcZKkp1izvgjTCOVvOy68Utk9VabA+GqoHz0kLcLTfudO K5xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nqPgX5mF; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s18si9684588otq.131.2019.12.15.16.22.14; Sun, 15 Dec 2019 16:22:26 -0800 (PST) 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=@gmail.com header.s=20161025 header.b=nqPgX5mF; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726795AbfLPAUI (ORCPT + 99 others); Sun, 15 Dec 2019 19:20:08 -0500 Received: from mail-qk1-f194.google.com ([209.85.222.194]:45417 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726526AbfLPAUH (ORCPT ); Sun, 15 Dec 2019 19:20:07 -0500 Received: by mail-qk1-f194.google.com with SMTP id x1so3866764qkl.12; Sun, 15 Dec 2019 16:20:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7S615KofXaQ1yUG/3GM94cEkec6rvE87OWT0R1mkHVE=; b=nqPgX5mFOvAOvhSP8TsLpj5UaQakaOAGyTfIYXnrJ98dEtbMpEP8y70bY2krwxvBGv 3sK8HR/8589X7H4aSpRQYDfPVFxXCiHAWknqhsEK4Dqnmtom1eCmt/84ndxMicvGc0tX SK1DtIiUK/u/cmwstnoeopb3cfXxGD4PGhoanmWF1wQx39CgqDz+4kssxSIdbFWyWPOB y63NGEJciBnX0t8sIT3OXdy/PBOf6jMsRpwBBJWBXrJ9vblwvEfFYeeNeGZ2SeNxLe1f oSONG29STbtZuutO4OQ8C6uyMnSUAFvzBbOaI53Zjw4vhBWJIWjfAI2QyCTMnpNHF0F/ 6NtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7S615KofXaQ1yUG/3GM94cEkec6rvE87OWT0R1mkHVE=; b=qMWfwPLe3kwErVCcmZUZ1Xyr9KktPkeZVoWYve63ZsT2GdpCKj6FK5T+KtM6Lezd02 +H+NfxcTf8KabF2SP7Lwbl/vAHYNaoc61hEd2G/QTi/kHJpcMOO59vPCqnh9xXbzo7mu eek/FIoYVOYJN2NjqO6RQC+NJkMXZ35jREDPeHsjjaCnL8c66+0r0WqFG7DQ22fcQ4Mj EjvaL7lYqXFpY5FZL/rkPM3lmvKZqWQE9PFTUQIx+JWM+VoCn+ghqs4OFrt9DpCjwnhH henotN2T/vW1P5g9lTXlU6mZyqgQvl0c7CuygijXYp9Jbl1s+we9f3lW6AxBXxTbQdzM s5YQ== X-Gm-Message-State: APjAAAU5CDHpkKeBnVJidKofZm/HlP97rgEbF6ofbARS73Ttt8oMp+tp 06TAjRhIkj5siH4Ztfy36jo= X-Received: by 2002:a37:684a:: with SMTP id d71mr22545035qkc.201.1576455606206; Sun, 15 Dec 2019 16:20:06 -0800 (PST) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id h1sm5312169qkc.38.2019.12.15.16.20.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Dec 2019 16:20:05 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 18F2B22442; Sun, 15 Dec 2019 19:20:04 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sun, 15 Dec 2019 19:20:04 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvddtgedgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvffufffkofgjfhgggfes tdekredtredttdenucfhrhhomhepuehoqhhunhcuhfgvnhhguceosghoqhhunhdrfhgvnh hgsehgmhgrihhlrdgtohhmqeenucfkphephedvrdduheehrdduuddurdejudenucfrrghr rghmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrg hlihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeep ghhmrghilhdrtghomhesfhhigihmvgdrnhgrmhgvnecuvehluhhsthgvrhfuihiivgepge X-ME-Proxy: Received: from localhost (unknown [52.155.111.71]) by mail.messagingengine.com (Postfix) with ESMTPA id 69CB980063; Sun, 15 Dec 2019 19:20:03 -0500 (EST) From: Boqun Feng To: linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Michael Kelley , Vincenzo Frascino , Catalin Marinas , Will Deacon , Thomas Gleixner , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin , xen-devel@lists.xenproject.org, Stefano Stabellini , Boqun Feng Subject: [RFC 6/6] arm64: hyperv: Enable vDSO Date: Mon, 16 Dec 2019 08:19:22 +0800 Message-Id: <20191216001922.23008-7-boqun.feng@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191216001922.23008-1-boqun.feng@gmail.com> References: <20191216001922.23008-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to x86, add a new vclock_mode VCLOCK_HVCLOCK, and reuse the hv_read_tsc_page() for userspace to read tsc page clocksource. Signed-off-by: Boqun Feng (Microsoft) --- arch/arm64/include/asm/clocksource.h | 3 ++- arch/arm64/include/asm/mshyperv.h | 2 +- arch/arm64/include/asm/vdso/gettimeofday.h | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/clocksource.h b/arch/arm64/include/asm/clocksource.h index fbe80057468c..c6acd45fe748 100644 --- a/arch/arm64/include/asm/clocksource.h +++ b/arch/arm64/include/asm/clocksource.h @@ -4,7 +4,8 @@ #define VCLOCK_NONE 0 /* No vDSO clock available. */ #define VCLOCK_CNTVCT 1 /* vDSO should use cntvcnt */ -#define VCLOCK_MAX 1 +#define VCLOCK_HVCLOCK 2 /* vDSO should use vread_hvclock() */ +#define VCLOCK_MAX 2 struct arch_clocksource_data { int vclock_mode; diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h index 0afb00e3501d..7c85dd816dca 100644 --- a/arch/arm64/include/asm/mshyperv.h +++ b/arch/arm64/include/asm/mshyperv.h @@ -90,7 +90,7 @@ extern void hv_get_vpreg_128(u32 reg, struct hv_get_vp_register_output *result); #define hv_set_reference_tsc(val) \ hv_set_vpreg(HV_REGISTER_REFERENCE_TSC, val) #define hv_set_clocksource_vdso(val) \ - ((val).archdata.vclock_mode = VCLOCK_NONE) + ((val).archdata.vclock_mode = VCLOCK_HVCLOCK) #if IS_ENABLED(CONFIG_HYPERV) #define hv_enable_stimer0_percpu_irq(irq) enable_percpu_irq(irq, 0) diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/include/asm/vdso/gettimeofday.h index e6e3fe0488c7..7e689b903f4d 100644 --- a/arch/arm64/include/asm/vdso/gettimeofday.h +++ b/arch/arm64/include/asm/vdso/gettimeofday.h @@ -67,6 +67,20 @@ int clock_getres_fallback(clockid_t _clkid, struct __kernel_timespec *_ts) return ret; } +#ifdef CONFIG_HYPERV_TIMER +/* This will override the default hv_get_raw_timer() */ +#define hv_get_raw_timer() __arch_counter_get_cntvct() +#include + +extern struct ms_hyperv_tsc_page +_hvclock_page __attribute__((visibility("hidden"))); + +static u64 vread_hvclock(void) +{ + return hv_read_tsc_page(&_hvclock_page); +} +#endif + static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) { u64 res; @@ -78,6 +92,11 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) if (clock_mode == VCLOCK_NONE) return __VDSO_USE_SYSCALL; +#ifdef CONFIG_HYPERV_TIMER + if (likely(clock_mode == VCLOCK_HVCLOCK)) + return vread_hvclock(); +#endif + /* * This isb() is required to prevent that the counter value * is speculated. -- 2.24.0