RE: [PATCH] clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h

Thomas Gleixner posted 1 patch 3 years, 5 months ago
arch/x86/include/asm/hyperv_timer.h |    9 +++++++++
arch/x86/include/asm/mshyperv.h     |    2 --
drivers/hv/vmbus_drv.c              |    1 +
include/clocksource/hyperv_timer.h  |    4 +++-
4 files changed, 13 insertions(+), 3 deletions(-)
RE: [PATCH] clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h
Posted by Thomas Gleixner 3 years, 5 months ago
On Sun, Nov 13 2022 at 11:40, Thomas Gleixner wrote:
> Bah, that obviously wants to include the new header...
>
> --- a/include/clocksource/hyperv_timer.h
> +++ b/include/clocksource/hyperv_timer.h
> @@ -15,7 +15,8 @@
>  
>  #include <linux/clocksource.h>
>  #include <linux/math64.h>
> -#include <asm/mshyperv.h>
> +#include <asm/hyperv_timer.h>

and that breaks when CONFIG_HYPERV_TIMER=n and compiled for ARM64.

Sigh...

---
Subject: clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h
From: Thomas Gleixner <tglx@linutronix.de>
Date: Sat, 12 Nov 2022 19:08:15 +0100

clocksource/hyperv_timer.h is included into the VDSO build. It includes
asm/mshyperv.h which in turn includes the world and some more. This worked
so far by chance, but any subtle change in the include chain results in a
build breakage because VDSO builds are building user space libraries.

Include asm/hyperv-tlfs.h instead which contains everything what the VDSO
build needs and move the hv_get_raw_timer() define into the header file.

Fixup drivers/hv/vmbus_drv.c which relies on the indirect include of
asm/mshyperv.h.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/hyperv_timer.h |    9 +++++++++
 arch/x86/include/asm/mshyperv.h     |    2 --
 drivers/hv/vmbus_drv.c              |    1 +
 include/clocksource/hyperv_timer.h  |    4 +++-
 4 files changed, 13 insertions(+), 3 deletions(-)

--- /dev/null
+++ b/arch/x86/include/asm/hyperv_timer.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_HYPERV_TIMER_H
+#define _ASM_X86_HYPERV_TIMER_H
+
+#include <asm/msr.h>
+
+#define hv_get_raw_timer() rdtsc_ordered()
+
+#endif
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -19,8 +19,6 @@ typedef int (*hyperv_fill_flush_list_fun
 		struct hv_guest_mapping_flush_list *flush,
 		void *data);
 
-#define hv_get_raw_timer() rdtsc_ordered()
-
 void hyperv_vector_handler(struct pt_regs *regs);
 
 #if IS_ENABLED(CONFIG_HYPERV)
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -37,6 +37,7 @@
 #include <linux/dma-map-ops.h>
 #include <linux/pci.h>
 #include <clocksource/hyperv_timer.h>
+#include <asm/mshyperv.h>
 #include "hyperv_vmbus.h"
 
 struct vmbus_dynid {
--- a/include/clocksource/hyperv_timer.h
+++ b/include/clocksource/hyperv_timer.h
@@ -15,13 +15,15 @@
 
 #include <linux/clocksource.h>
 #include <linux/math64.h>
-#include <asm/mshyperv.h>
+#include <asm/hyperv-tlfs.h>
 
 #define HV_MAX_MAX_DELTA_TICKS 0xffffffff
 #define HV_MIN_DELTA_TICKS 1
 
 #ifdef CONFIG_HYPERV_TIMER
 
+#include <asm/hyperv_timer.h>
+
 /* Routines called by the VMbus driver */
 extern int hv_stimer_alloc(bool have_percpu_irqs);
 extern int hv_stimer_cleanup(unsigned int cpu);
RE: [PATCH] clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h
Posted by Thomas Gleixner 3 years, 4 months ago
Michael!

On Sun, Nov 13 2022 at 22:21, Thomas Gleixner wrote:
> Subject: clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h
> From: Thomas Gleixner <tglx@linutronix.de>
> Date: Sat, 12 Nov 2022 19:08:15 +0100
>
> clocksource/hyperv_timer.h is included into the VDSO build. It includes
> asm/mshyperv.h which in turn includes the world and some more. This worked
> so far by chance, but any subtle change in the include chain results in a
> build breakage because VDSO builds are building user space libraries.
>
> Include asm/hyperv-tlfs.h instead which contains everything what the VDSO
> build needs and move the hv_get_raw_timer() define into the header file.
>
> Fixup drivers/hv/vmbus_drv.c which relies on the indirect include of
> asm/mshyperv.h.

Any comments on this latest version?

> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
>  arch/x86/include/asm/hyperv_timer.h |    9 +++++++++
>  arch/x86/include/asm/mshyperv.h     |    2 --
>  drivers/hv/vmbus_drv.c              |    1 +
>  include/clocksource/hyperv_timer.h  |    4 +++-
>  4 files changed, 13 insertions(+), 3 deletions(-)
>
> --- /dev/null
> +++ b/arch/x86/include/asm/hyperv_timer.h
> @@ -0,0 +1,9 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _ASM_X86_HYPERV_TIMER_H
> +#define _ASM_X86_HYPERV_TIMER_H
> +
> +#include <asm/msr.h>
> +
> +#define hv_get_raw_timer() rdtsc_ordered()
> +
> +#endif
> --- a/arch/x86/include/asm/mshyperv.h
> +++ b/arch/x86/include/asm/mshyperv.h
> @@ -19,8 +19,6 @@ typedef int (*hyperv_fill_flush_list_fun
>  		struct hv_guest_mapping_flush_list *flush,
>  		void *data);
>  
> -#define hv_get_raw_timer() rdtsc_ordered()
> -
>  void hyperv_vector_handler(struct pt_regs *regs);
>  
>  #if IS_ENABLED(CONFIG_HYPERV)
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -37,6 +37,7 @@
>  #include <linux/dma-map-ops.h>
>  #include <linux/pci.h>
>  #include <clocksource/hyperv_timer.h>
> +#include <asm/mshyperv.h>
>  #include "hyperv_vmbus.h"
>  
>  struct vmbus_dynid {
> --- a/include/clocksource/hyperv_timer.h
> +++ b/include/clocksource/hyperv_timer.h
> @@ -15,13 +15,15 @@
>  
>  #include <linux/clocksource.h>
>  #include <linux/math64.h>
> -#include <asm/mshyperv.h>
> +#include <asm/hyperv-tlfs.h>
>  
>  #define HV_MAX_MAX_DELTA_TICKS 0xffffffff
>  #define HV_MIN_DELTA_TICKS 1
>  
>  #ifdef CONFIG_HYPERV_TIMER
>  
> +#include <asm/hyperv_timer.h>
> +
>  /* Routines called by the VMbus driver */
>  extern int hv_stimer_alloc(bool have_percpu_irqs);
>  extern int hv_stimer_cleanup(unsigned int cpu);
RE: [PATCH] clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h
Posted by Michael Kelley (LINUX) 3 years, 4 months ago
From: Thomas Gleixner <tglx@linutronix.de> Sent: Wednesday, November 16, 2022 12:52 PM
>
> Michael!
> 
> On Sun, Nov 13 2022 at 22:21, Thomas Gleixner wrote:
> > Subject: clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not
> asm/mshyperv.h
> > From: Thomas Gleixner <tglx@linutronix.de>
> > Date: Sat, 12 Nov 2022 19:08:15 +0100
> >
> > clocksource/hyperv_timer.h is included into the VDSO build. It includes
> > asm/mshyperv.h which in turn includes the world and some more. This worked
> > so far by chance, but any subtle change in the include chain results in a
> > build breakage because VDSO builds are building user space libraries.
> >
> > Include asm/hyperv-tlfs.h instead which contains everything what the VDSO
> > build needs and move the hv_get_raw_timer() define into the header file.
> >
> > Fixup drivers/hv/vmbus_drv.c which relies on the indirect include of
> > asm/mshyperv.h.
> 
> Any comments on this latest version?

Sorry.  This looks good to me.  Maybe the commit message needs a
bit of tweaking -- it's not clear what "move hv_get_raw_timer()
define into the header file" exactly refers to.  But otherwise,

Reviewed-by: Michael Kelley <mikelley@microsoft.com>

> 
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > ---
> >  arch/x86/include/asm/hyperv_timer.h |    9 +++++++++
> >  arch/x86/include/asm/mshyperv.h     |    2 --
> >  drivers/hv/vmbus_drv.c              |    1 +
> >  include/clocksource/hyperv_timer.h  |    4 +++-
> >  4 files changed, 13 insertions(+), 3 deletions(-)
> >
> > --- /dev/null
> > +++ b/arch/x86/include/asm/hyperv_timer.h
> > @@ -0,0 +1,9 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _ASM_X86_HYPERV_TIMER_H
> > +#define _ASM_X86_HYPERV_TIMER_H
> > +
> > +#include <asm/msr.h>
> > +
> > +#define hv_get_raw_timer() rdtsc_ordered()
> > +
> > +#endif
> > --- a/arch/x86/include/asm/mshyperv.h
> > +++ b/arch/x86/include/asm/mshyperv.h
> > @@ -19,8 +19,6 @@ typedef int (*hyperv_fill_flush_list_fun
> >  		struct hv_guest_mapping_flush_list *flush,
> >  		void *data);
> >
> > -#define hv_get_raw_timer() rdtsc_ordered()
> > -
> >  void hyperv_vector_handler(struct pt_regs *regs);
> >
> >  #if IS_ENABLED(CONFIG_HYPERV)
> > --- a/drivers/hv/vmbus_drv.c
> > +++ b/drivers/hv/vmbus_drv.c
> > @@ -37,6 +37,7 @@
> >  #include <linux/dma-map-ops.h>
> >  #include <linux/pci.h>
> >  #include <clocksource/hyperv_timer.h>
> > +#include <asm/mshyperv.h>
> >  #include "hyperv_vmbus.h"
> >
> >  struct vmbus_dynid {
> > --- a/include/clocksource/hyperv_timer.h
> > +++ b/include/clocksource/hyperv_timer.h
> > @@ -15,13 +15,15 @@
> >
> >  #include <linux/clocksource.h>
> >  #include <linux/math64.h>
> > -#include <asm/mshyperv.h>
> > +#include <asm/hyperv-tlfs.h>
> >
> >  #define HV_MAX_MAX_DELTA_TICKS 0xffffffff
> >  #define HV_MIN_DELTA_TICKS 1
> >
> >  #ifdef CONFIG_HYPERV_TIMER
> >
> > +#include <asm/hyperv_timer.h>
> > +
> >  /* Routines called by the VMbus driver */
> >  extern int hv_stimer_alloc(bool have_percpu_irqs);
> >  extern int hv_stimer_cleanup(unsigned int cpu);
RE: [PATCH] clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h
Posted by Thomas Gleixner 3 years, 4 months ago
On Wed, Nov 16 2022 at 22:34, Michael Kelley wrote:
> From: Thomas Gleixner <tglx@linutronix.de> Sent: Wednesday, November 16, 2022 12:52 PM
>> On Sun, Nov 13 2022 at 22:21, Thomas Gleixner wrote:
>> > Subject: clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not
>> asm/mshyperv.h
>> > From: Thomas Gleixner <tglx@linutronix.de>
>> > Date: Sat, 12 Nov 2022 19:08:15 +0100
>> >
>> > clocksource/hyperv_timer.h is included into the VDSO build. It includes
>> > asm/mshyperv.h which in turn includes the world and some more. This worked
>> > so far by chance, but any subtle change in the include chain results in a
>> > build breakage because VDSO builds are building user space libraries.
>> >
>> > Include asm/hyperv-tlfs.h instead which contains everything what the VDSO
>> > build needs and move the hv_get_raw_timer() define into the header file.
>> >
>> > Fixup drivers/hv/vmbus_drv.c which relies on the indirect include of
>> > asm/mshyperv.h.
>> 
>> Any comments on this latest version?
>
> Sorry.  This looks good to me.  Maybe the commit message needs a
> bit of tweaking -- it's not clear what "move hv_get_raw_timer()
> define into the header file" exactly refers to.  But otherwise,

That should obviously be 'into a separate header file, which is included
from clocksource/hyperv_timer.h' or something like that.

Thanks,

        tglx
[tip: irq/core] clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h
Posted by tip-bot2 for Thomas Gleixner 3 years, 4 months ago
The following commit has been merged into the irq/core branch of tip:

Commit-ID:     e5dfd093eca01a5d8d967f959a2372d7d82eb59c
Gitweb:        https://git.kernel.org/tip/e5dfd093eca01a5d8d967f959a2372d7d82eb59c
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Sun, 13 Nov 2022 22:21:15 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 17 Nov 2022 13:58:32 +01:00

clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h

clocksource/hyperv_timer.h is included into the VDSO build. It includes
asm/mshyperv.h which in turn includes the world and some more. This worked
so far by chance, but any subtle change in the include chain results in a
build breakage because VDSO builds are building user space libraries.

Include asm/hyperv-tlfs.h instead which contains everything what the VDSO
build needs except the hv_get_raw_timer() define. Move this define into a
separate header file, which contains the prerequisites (msr.h) and is
included by clocksource/hyperv_timer.h.

Fixup drivers/hv/vmbus_drv.c which relies on the indirect include of
asm/mshyperv.h.

With that the VDSO build only pulls in the minimum requirements.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/87fsemtut0.ffs@tglx

---
 arch/x86/include/asm/hyperv_timer.h |  9 +++++++++
 arch/x86/include/asm/mshyperv.h     |  2 --
 drivers/hv/vmbus_drv.c              |  1 +
 include/clocksource/hyperv_timer.h  |  4 +++-
 4 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 arch/x86/include/asm/hyperv_timer.h

diff --git a/arch/x86/include/asm/hyperv_timer.h b/arch/x86/include/asm/hyperv_timer.h
new file mode 100644
index 0000000..388fa81
--- /dev/null
+++ b/arch/x86/include/asm/hyperv_timer.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_HYPERV_TIMER_H
+#define _ASM_X86_HYPERV_TIMER_H
+
+#include <asm/msr.h>
+
+#define hv_get_raw_timer() rdtsc_ordered()
+
+#endif
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 61f0c20..6d502f3 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -19,8 +19,6 @@ typedef int (*hyperv_fill_flush_list_func)(
 		struct hv_guest_mapping_flush_list *flush,
 		void *data);
 
-#define hv_get_raw_timer() rdtsc_ordered()
-
 void hyperv_vector_handler(struct pt_regs *regs);
 
 #if IS_ENABLED(CONFIG_HYPERV)
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 8b2e413..1f5d37a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -37,6 +37,7 @@
 #include <linux/dma-map-ops.h>
 #include <linux/pci.h>
 #include <clocksource/hyperv_timer.h>
+#include <asm/mshyperv.h>
 #include "hyperv_vmbus.h"
 
 struct vmbus_dynid {
diff --git a/include/clocksource/hyperv_timer.h b/include/clocksource/hyperv_timer.h
index b3f5d73..b4a3935 100644
--- a/include/clocksource/hyperv_timer.h
+++ b/include/clocksource/hyperv_timer.h
@@ -15,13 +15,15 @@
 
 #include <linux/clocksource.h>
 #include <linux/math64.h>
-#include <asm/mshyperv.h>
+#include <asm/hyperv-tlfs.h>
 
 #define HV_MAX_MAX_DELTA_TICKS 0xffffffff
 #define HV_MIN_DELTA_TICKS 1
 
 #ifdef CONFIG_HYPERV_TIMER
 
+#include <asm/hyperv_timer.h>
+
 /* Routines called by the VMbus driver */
 extern int hv_stimer_alloc(bool have_percpu_irqs);
 extern int hv_stimer_cleanup(unsigned int cpu);
[tip: timers/core] clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h
Posted by tip-bot2 for Thomas Gleixner 3 years, 4 months ago
The following commit has been merged into the timers/core branch of tip:

Commit-ID:     d3fe5c2f206148f86f85f56671109a3118bf0d2b
Gitweb:        https://git.kernel.org/tip/d3fe5c2f206148f86f85f56671109a3118bf0d2b
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Sun, 13 Nov 2022 22:21:15 +01:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 17 Nov 2022 11:41:19 +01:00

clocksource/drivers/hyper-v: Include asm/hyperv-tlfs.h not asm/mshyperv.h

clocksource/hyperv_timer.h is included into the VDSO build. It includes
asm/mshyperv.h which in turn includes the world and some more. This worked
so far by chance, but any subtle change in the include chain results in a
build breakage because VDSO builds are building user space libraries.

Include asm/hyperv-tlfs.h instead which contains everything what the VDSO
build needs except the hv_get_raw_timer() define. Move this define into a
separate header file, which contains the prerequisites (msr.h) and is
included by clocksource/hyperv_timer.h.

Fixup drivers/hv/vmbus_drv.c which relies on the indirect include of
asm/mshyperv.h.

With that the VDSO build only pulls in the minimum requirements.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/87fsemtut0.ffs@tglx

---
 arch/x86/include/asm/hyperv_timer.h |  9 +++++++++
 arch/x86/include/asm/mshyperv.h     |  2 --
 drivers/hv/vmbus_drv.c              |  1 +
 include/clocksource/hyperv_timer.h  |  4 +++-
 4 files changed, 13 insertions(+), 3 deletions(-)
 create mode 100644 arch/x86/include/asm/hyperv_timer.h

diff --git a/arch/x86/include/asm/hyperv_timer.h b/arch/x86/include/asm/hyperv_timer.h
new file mode 100644
index 0000000..388fa81
--- /dev/null
+++ b/arch/x86/include/asm/hyperv_timer.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ASM_X86_HYPERV_TIMER_H
+#define _ASM_X86_HYPERV_TIMER_H
+
+#include <asm/msr.h>
+
+#define hv_get_raw_timer() rdtsc_ordered()
+
+#endif
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 61f0c20..6d502f3 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -19,8 +19,6 @@ typedef int (*hyperv_fill_flush_list_func)(
 		struct hv_guest_mapping_flush_list *flush,
 		void *data);
 
-#define hv_get_raw_timer() rdtsc_ordered()
-
 void hyperv_vector_handler(struct pt_regs *regs);
 
 #if IS_ENABLED(CONFIG_HYPERV)
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 8b2e413..1f5d37a 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -37,6 +37,7 @@
 #include <linux/dma-map-ops.h>
 #include <linux/pci.h>
 #include <clocksource/hyperv_timer.h>
+#include <asm/mshyperv.h>
 #include "hyperv_vmbus.h"
 
 struct vmbus_dynid {
diff --git a/include/clocksource/hyperv_timer.h b/include/clocksource/hyperv_timer.h
index b3f5d73..b4a3935 100644
--- a/include/clocksource/hyperv_timer.h
+++ b/include/clocksource/hyperv_timer.h
@@ -15,13 +15,15 @@
 
 #include <linux/clocksource.h>
 #include <linux/math64.h>
-#include <asm/mshyperv.h>
+#include <asm/hyperv-tlfs.h>
 
 #define HV_MAX_MAX_DELTA_TICKS 0xffffffff
 #define HV_MIN_DELTA_TICKS 1
 
 #ifdef CONFIG_HYPERV_TIMER
 
+#include <asm/hyperv_timer.h>
+
 /* Routines called by the VMbus driver */
 extern int hv_stimer_alloc(bool have_percpu_irqs);
 extern int hv_stimer_cleanup(unsigned int cpu);