[RFC 1/6] arm64: hyperv: Allow hv_get_raw_timer() definition to be overridden
From: Boqun Feng
Date: Sun Dec 15 2019 - 19:20:00 EST
In order to support vDSO, hv_read_tsc_page() should be able to be called
from userspace if tsc page mapped. As a result, hv_get_raw_timer(),
called by hv_read_tsc_page() requires to be called by both kernel and
vDSO. Currently, it's defined as arch_timer_read_counter(), which is a
function pointer initialized (using a kernel address) by the arch timer
driver, therefore not usable in vDSO.
Fix this by allowing a previous definition to override the default one,
so that in vDSO code, we can define it as a function callable in
userspace.
Signed-off-by: Boqun Feng (Microsoft) <boqun.feng@xxxxxxxxx>
---
arch/arm64/include/asm/mshyperv.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h
index a8468a611912..9cc4aeddf2d0 100644
--- a/arch/arm64/include/asm/mshyperv.h
+++ b/arch/arm64/include/asm/mshyperv.h
@@ -97,8 +97,15 @@ extern void hv_get_vpreg_128(u32 reg, struct hv_get_vp_register_output *result);
#define hv_disable_stimer0_percpu_irq(irq) disable_percpu_irq(irq)
#endif
-/* ARM64 specific code to read the hardware clock */
+/*
+ * ARM64 specific code to read the hardware clock.
+ *
+ * This could be used in both kernel space and userspace (vDSO), so make it
+ * possible for a previous definition to override the default one.
+ */
+#ifndef hv_get_raw_timer
#define hv_get_raw_timer() arch_timer_read_counter()
+#endif
#include <asm-generic/mshyperv.h>
--
2.24.0