2020-08-10 01:31:53

by Michael Kelley (LINUX)

[permalink] [raw]
Subject: [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/

Signed-off-by: Michael Kelley <[email protected]>
---
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(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 60b944d..4f77b8f 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -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) {}
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index af94f05..3112544 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -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,
diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
index 1c4fd95..c5edc5e 100644
--- a/include/asm-generic/mshyperv.h
+++ b/include/asm-generic/mshyperv.h
@@ -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; }
--
1.8.3.1


2020-08-10 09:48:59

by Wei Liu

[permalink] [raw]
Subject: Re: [PATCH 1/1] x86/hyperv: Make hv_setup_sched_clock inline

On Sun, Aug 09, 2020 at 06:29:51PM -0700, Michael Kelley wrote:
> 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.

2020-08-10 11:22:05

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH 1/1] x86/hyperv: Make hv_setup_sched_clock inline

On Sun, Aug 09, 2020 at 06:29:51PM -0700, Michael Kelley wrote:
> 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]>

Thanks!

Acked-by: Peter Zijlstra (Intel) <[email protected]>

2020-08-10 20:09:45

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH 1/1] x86/hyperv: Make hv_setup_sched_clock inline

Michael Kelley <[email protected]> writes:
> 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: Thomas Gleixner <[email protected]>

2020-08-11 10:58:38

by Wei Liu

[permalink] [raw]
Subject: Re: [PATCH 1/1] x86/hyperv: Make hv_setup_sched_clock inline

On Mon, Aug 10, 2020 at 10:08:41PM +0200, Thomas Gleixner wrote:
> Michael Kelley <[email protected]> writes:
> > 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: Thomas Gleixner <[email protected]>

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.

2020-08-11 11:25:50

by Thomas Gleixner

[permalink] [raw]
Subject: Re: [PATCH 1/1] x86/hyperv: Make hv_setup_sched_clock inline

Wei Liu <[email protected]> writes:

> On Mon, Aug 10, 2020 at 10:08:41PM +0200, Thomas Gleixner wrote:
>> Michael Kelley <[email protected]> writes:
>> > 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: Thomas Gleixner <[email protected]>
>
> 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 :)