Skip to contentSkip to conversation

x86/hyperv: Make hv_setup_sched_clock inline

PATCH Applied Michael Kelley 4 participants 6 messages Aug 10, 2020 – Aug 11, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/hyperv: Make hv_setup_sched_clock inline

Make hv_setup_sched_clock inline so the reference to pv_ops works correctly with objtool updates to detect noinstr violations. See https://lore.kernel.org/patchwork/patch/1283635/

---
 arch/x86/include/asm/mshyperv.h | 12 ++++++++++++
 arch/x86/kernel/cpu/mshyperv.c  |  7 -------
 include/asm-generic/mshyperv.h  |  1 -
 3 files changed, 12 insertions(+), 8 deletions(-)
arch/x86/include/asm/mshyperv.h +12 -0
index 60b944d..4f77b8f 100644
@@ -8,6 +8,7 @@
 #include <asm/io.h>
 #include <asm/hyperv-tlfs.h>
 #include <asm/nospec-branch.h>
+#include <asm/paravirt.h>
 
 typedef int (*hyperv_fill_flush_list_func)(
 		struct hv_guest_mapping_flush_list *flush,
@@ -54,6 +55,17 @@ typedef int (*hyperv_fill_flush_list_func)(
 	vclocks_set_used(VDSO_CLOCKMODE_HVCLOCK);
 #define hv_get_raw_timer() rdtsc_ordered()
 
+/*
+ * Reference to pv_ops must be inline so objtool
+ * detection of noinstr violations can work correctly.
+ */
+static __always_inline void hv_setup_sched_clock(void *sched_clock)
+{
+#ifdef CONFIG_PARAVIRT
+	pv_ops.time.sched_clock = sched_clock;
+#endif
+}
+
 void hyperv_vector_handler(struct pt_regs *regs);
 
 static inline void hv_enable_stimer0_percpu_irq(int irq) {}
arch/x86/kernel/cpu/mshyperv.c +0 -7
index af94f05..3112544 100644
@@ -361,13 +361,6 @@ static void __init ms_hyperv_init_platform(void)
 #endif
 }
 
-void hv_setup_sched_clock(void *sched_clock)
-{
-#ifdef CONFIG_PARAVIRT
-	pv_ops.time.sched_clock = sched_clock;
-#endif
-}
-
 const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
 	.name			= "Microsoft Hyper-V",
 	.detect			= ms_hyperv_platform,
include/asm-generic/mshyperv.h +0 -1
index 1c4fd95..c5edc5e 100644
@@ -168,7 +168,6 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
 bool hv_is_hyperv_initialized(void);
 bool hv_is_hibernation_supported(void);
 void hyperv_cleanup(void);
-void hv_setup_sched_clock(void *sched_clock);
 #else /* CONFIG_HYPERV */
 static inline bool hv_is_hyperv_initialized(void) { return false; }
 static inline bool hv_is_hibernation_supported(void) { return false; }
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 4 lines · Michael Kelley

Make hv_setup_sched_clock inline so the reference to pv_ops works correctly with objtool updates to detect noinstr violations. See https://lore.kernel.org/patchwork/patch/1283635/

I read the reference link. This change looks sensible.

I will wait a few days before queueing this up in case other people have an opinion on this.

Wei.

maintainer Applied
#4 lore raw
Quoted 8 lines · Thomas Gleixner
Quoted 5 lines · Michael Kelley

Make hv_setup_sched_clock inline so the reference to pv_ops works correctly with objtool updates to detect noinstr violations. See https://lore.kernel.org/patchwork/patch/1283635/

Thomas and Peter, thank you for your acks.

I have applied to hyperv-fixes and plan to submit it to Linus in a few days' time.

Thomas, let me know if you want this patch to go through the tip tree. I will revert it from hyperv-fixes if that's the case.

Wei.

#5 lore raw
Quoted 10 lines · Wei Liu
Quoted 8 lines · Thomas Gleixner
Quoted 5 lines · Michael Kelley

Make hv_setup_sched_clock inline so the reference to pv_ops works correctly with objtool updates to detect noinstr violations. See https://lore.kernel.org/patchwork/patch/1283635/

Quoted 7 lines

Thomas and Peter, thank you for your acks.

I have applied to hyperv-fixes and plan to submit it to Linus in a few days' time.

Thomas, let me know if you want this patch to go through the tip tree. I will revert it from hyperv-fixes if that's the case.

I acked it so you can pick it up :)