Skip to content

Commit b9d8cf2

Browse files
kelleymhliuw
authored andcommitted
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/ Signed-off-by: Michael Kelley <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent 608a973 commit b9d8cf2

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

arch/x86/include/asm/mshyperv.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <asm/io.h>
99
#include <asm/hyperv-tlfs.h>
1010
#include <asm/nospec-branch.h>
11+
#include <asm/paravirt.h>
1112

1213
typedef int (*hyperv_fill_flush_list_func)(
1314
struct hv_guest_mapping_flush_list *flush,
@@ -54,6 +55,17 @@ typedef int (*hyperv_fill_flush_list_func)(
5455
vclocks_set_used(VDSO_CLOCKMODE_HVCLOCK);
5556
#define hv_get_raw_timer() rdtsc_ordered()
5657

58+
/*
59+
* Reference to pv_ops must be inline so objtool
60+
* detection of noinstr violations can work correctly.
61+
*/
62+
static __always_inline void hv_setup_sched_clock(void *sched_clock)
63+
{
64+
#ifdef CONFIG_PARAVIRT
65+
pv_ops.time.sched_clock = sched_clock;
66+
#endif
67+
}
68+
5769
void hyperv_vector_handler(struct pt_regs *regs);
5870

5971
static inline void hv_enable_stimer0_percpu_irq(int irq) {}

arch/x86/kernel/cpu/mshyperv.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,6 @@ static void __init ms_hyperv_init_platform(void)
361361
#endif
362362
}
363363

364-
void hv_setup_sched_clock(void *sched_clock)
365-
{
366-
#ifdef CONFIG_PARAVIRT
367-
pv_ops.time.sched_clock = sched_clock;
368-
#endif
369-
}
370-
371364
const __initconst struct hypervisor_x86 x86_hyper_ms_hyperv = {
372365
.name = "Microsoft Hyper-V",
373366
.detect = ms_hyperv_platform,

include/asm-generic/mshyperv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ void hyperv_report_panic_msg(phys_addr_t pa, size_t size);
168168
bool hv_is_hyperv_initialized(void);
169169
bool hv_is_hibernation_supported(void);
170170
void hyperv_cleanup(void);
171-
void hv_setup_sched_clock(void *sched_clock);
172171
#else /* CONFIG_HYPERV */
173172
static inline bool hv_is_hyperv_initialized(void) { return false; }
174173
static inline bool hv_is_hibernation_supported(void) { return false; }

0 commit comments

Comments
 (0)