lkml.org 
[lkml]   [2019]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC 5/6] arm64: hyperv: Enable userspace to read cntvct
Date
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
\
 
 \ /
  Last update: 2019-12-16 01:21    [W:0.104 / U:4.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site