linux-hyperv.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: linux-hyperv@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: Michael Kelley <mikelley@microsoft.com>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	Sasha Levin <sashal@kernel.org>,
	xen-devel@lists.xenproject.org,
	Stefano Stabellini <sstabellini@kernel.org>,
	Boqun Feng <boqun.feng@gmail.com>
Subject: [RFC 5/6] arm64: hyperv: Enable userspace to read cntvct
Date: Mon, 16 Dec 2019 08:19:21 +0800	[thread overview]
Message-ID: <20191216001922.23008-6-boqun.feng@gmail.com> (raw)
In-Reply-To: <20191216001922.23008-1-boqun.feng@gmail.com>

Since reading hyperv-timer clocksource requires reading cntvct,
userspace should be allowed to read it, otherwise reading cntvct will
result in traps, which makes vsyscall's cost similar compared to
syscall's.

So enable it on every cpu when a Hyper-V guest booting up.

Signed-off-by: Boqun Feng (Microsoft) <boqun.feng@gmail.com>
---
 arch/arm64/hyperv/hv_init.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm64/hyperv/hv_init.c b/arch/arm64/hyperv/hv_init.c
index 86e4621d5885..1ea97ecfb143 100644
--- a/arch/arm64/hyperv/hv_init.c
+++ b/arch/arm64/hyperv/hv_init.c
@@ -27,6 +27,7 @@
 #include <linux/sched_clock.h>
 #include <asm-generic/bug.h>
 #include <asm/hyperv-tlfs.h>
+#include <asm/arch_timer.h>
 #include <asm/mshyperv.h>
 #include <asm/sysreg.h>
 #include <clocksource/hyperv_timer.h>
@@ -45,6 +46,7 @@ EXPORT_SYMBOL_GPL(hv_max_vp_index);
 static int hv_cpu_init(unsigned int cpu)
 {
 	u64 msr_vp_index;
+	u32 cntkctl;
 
 	hv_get_vp_index(msr_vp_index);
 
@@ -53,6 +55,11 @@ static int hv_cpu_init(unsigned int cpu)
 	if (msr_vp_index > hv_max_vp_index)
 		hv_max_vp_index = msr_vp_index;
 
+	/* Enable EL0 to access cntvct */
+	cntkctl = arch_timer_get_cntkctl();
+	cntkctl |= ARCH_TIMER_USR_VCT_ACCESS_EN;
+	arch_timer_set_cntkctl(cntkctl);
+
 	return 0;
 }
 
-- 
2.24.0


  parent reply	other threads:[~2019-12-16  0:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-16  0:19 [RFC 0/6] vDSO support for Hyper-V guest on ARM64 Boqun Feng
2019-12-16  0:19 ` [RFC 1/6] arm64: hyperv: Allow hv_get_raw_timer() definition to be overridden Boqun Feng
2019-12-16  0:19 ` [RFC 2/6] arm64: vdso: Add support for multiple vDSO data pages Boqun Feng
2019-12-16  0:19 ` [RFC 3/6] arm/arm64: clocksource: Introduce vclock_mode Boqun Feng
2019-12-16  0:19 ` [RFC 4/6] arm64: vdso: hyperv: Map tsc page into vDSO if enabled Boqun Feng
2019-12-16  0:19 ` Boqun Feng [this message]
2019-12-16  0:19 ` [RFC 6/6] arm64: hyperv: Enable vDSO Boqun Feng
2019-12-17 14:10   ` Vitaly Kuznetsov
2019-12-18  5:47     ` Boqun Feng
2020-01-23 10:48 ` [RFC 0/6] vDSO support for Hyper-V guest on ARM64 Vincenzo Frascino
2020-01-24  6:32   ` Boqun Feng
2020-01-24 10:24     ` Vincenzo Frascino
2020-01-28  5:58       ` Boqun Feng
2020-01-28 11:48         ` Marc Zyngier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191216001922.23008-6-boqun.feng@gmail.com \
    --to=boqun.feng@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=sashal@kernel.org \
    --cc=sstabellini@kernel.org \
    --cc=sthemmin@microsoft.com \
    --cc=tglx@linutronix.de \
    --cc=vincenzo.frascino@arm.com \
    --cc=will@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).