2013-09-03 17:49:34

by KY Srinivasan

[permalink] [raw]
Subject: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this and bypass
the calibration code in the kernel. This would allow us to boot the Linux kernel as a
"modern VM" on Hyper-V where many of the legacy devices (such as PIT) are not emulated.

I would like to thank Olaf Hering <[email protected]>, Jan Beulich <[email protected]> and
H. Peter Anvin <[email protected]> for their help in this effort.

In this version of the patch, I have addressed Jan's comments.

Signed-off-by: K. Y. Srinivasan <[email protected]>
---
arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
arch/x86/kernel/cpu/mshyperv.c | 24 ++++++++++++++++++++++++
2 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
index b80420b..b8f1c01 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -27,6 +27,19 @@
#define HV_X64_MSR_VP_RUNTIME_AVAILABLE (1 << 0)
/* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/
#define HV_X64_MSR_TIME_REF_COUNT_AVAILABLE (1 << 1)
+
+/*
+ * There is a single feature flag that signifies the presence of the MSR
+ * that can be used to retrieve both the local APIC Timer frequency as
+ * well as the TSC frequency.
+ */
+
+/* Local APIC timer frequency MSR (HV_X64_MSR_APIC_FREQUENCY) is available */
+#define HV_X64_MSR_APIC_FREQUENCY_AVAILABLE (1 << 11)
+
+/* TSC frequency MSR (HV_X64_MSR_TSC_FREQUENCY) is available */
+#define HV_X64_MSR_TSC_FREQUENCY_AVAILABLE (1 << 11)
+
/*
* Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM
* and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15) available
@@ -136,6 +149,12 @@
/* MSR used to read the per-partition time reference counter */
#define HV_X64_MSR_TIME_REF_COUNT 0x40000020

+/* MSR used to retrieve the TSC frequency */
+#define HV_X64_MSR_TSC_FREQUENCY 0x40000022
+
+/* MSR used to retrieve the local APIC timer frequency */
+#define HV_X64_MSR_APIC_FREQUENCY 0x40000023
+
/* Define the virtual APIC registers */
#define HV_X64_MSR_EOI 0x40000070
#define HV_X64_MSR_ICR 0x40000071
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 71a39f3..b3dc639 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -15,6 +15,7 @@
#include <linux/clocksource.h>
#include <linux/module.h>
#include <linux/hardirq.h>
+#include <linux/efi.h>
#include <linux/interrupt.h>
#include <asm/processor.h>
#include <asm/hypervisor.h>
@@ -23,6 +24,7 @@
#include <asm/desc.h>
#include <asm/idle.h>
#include <asm/irq_regs.h>
+#include <asm/i8259.h>

struct ms_hyperv_info ms_hyperv;
EXPORT_SYMBOL_GPL(ms_hyperv);
@@ -67,6 +69,8 @@ static struct clocksource hyperv_cs = {

static void __init ms_hyperv_init_platform(void)
{
+ u64 hv_lapic_frequency;
+
/*
* Extract the features and hints
*/
@@ -76,6 +80,26 @@ static void __init ms_hyperv_init_platform(void)
printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
ms_hyperv.features, ms_hyperv.hints);

+ if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) {
+ /*
+ * Get the APIC frequency.
+ */
+ rdmsrl(HV_X64_MSR_APIC_FREQUENCY, hv_lapic_frequency);
+ hv_lapic_frequency /= HZ;
+ lapic_timer_frequency = hv_lapic_frequency;
+ printk(KERN_INFO "HyperV: LAPIC Timer Frequency: %#x\n",
+ lapic_timer_frequency);
+
+ /*
+ * On Hyper-V, when we are booting off an EFI firmware stack,
+ * we do not have many legacy devices including PIC, PIT etc.
+ */
+ if (efi_enabled(EFI_BOOT)) {
+ printk(KERN_INFO "HyperV: Using null_legacy_pic\n");
+ legacy_pic = &null_legacy_pic;
+ }
+ }
+
if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
}
--
1.7.4.1


2013-09-04 07:17:20

by Jan Beulich

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

>>> On 03.09.13 at 20:30, "K. Y. Srinivasan" <[email protected]> wrote:
> @@ -76,6 +80,26 @@ static void __init ms_hyperv_init_platform(void)
> printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
> ms_hyperv.features, ms_hyperv.hints);
>
> + if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) {
> + /*
> + * Get the APIC frequency.
> + */
> + rdmsrl(HV_X64_MSR_APIC_FREQUENCY, hv_lapic_frequency);
> + hv_lapic_frequency /= HZ;
> + lapic_timer_frequency = hv_lapic_frequency;
> + printk(KERN_INFO "HyperV: LAPIC Timer Frequency: %#x\n",
> + lapic_timer_frequency);
> +
> + /*
> + * On Hyper-V, when we are booting off an EFI firmware stack,
> + * we do not have many legacy devices including PIC, PIT etc.
> + */
> + if (efi_enabled(EFI_BOOT)) {
> + printk(KERN_INFO "HyperV: Using null_legacy_pic\n");
> + legacy_pic = &null_legacy_pic;
> + }

And this check is really connected to the feature check around the
whole block, rather than being independent? (I'd also think that
this latter message would suffice to be KERN_DEBUG).

Jan

2013-09-04 09:41:13

by Gleb Natapov

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On Tue, Sep 03, 2013 at 11:30:23AM -0700, K. Y. Srinivasan wrote:
> Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this and bypass
> the calibration code in the kernel. This would allow us to boot the Linux kernel as a
> "modern VM" on Hyper-V where many of the legacy devices (such as PIT) are not emulated.
>
> I would like to thank Olaf Hering <[email protected]>, Jan Beulich <[email protected]> and
> H. Peter Anvin <[email protected]> for their help in this effort.
>
> In this version of the patch, I have addressed Jan's comments.
>
> Signed-off-by: K. Y. Srinivasan <[email protected]>
> ---
> arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
> arch/x86/kernel/cpu/mshyperv.c | 24 ++++++++++++++++++++++++
> 2 files changed, 43 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
> index b80420b..b8f1c01 100644
> --- a/arch/x86/include/uapi/asm/hyperv.h
> +++ b/arch/x86/include/uapi/asm/hyperv.h
> @@ -27,6 +27,19 @@
> #define HV_X64_MSR_VP_RUNTIME_AVAILABLE (1 << 0)
> /* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/
> #define HV_X64_MSR_TIME_REF_COUNT_AVAILABLE (1 << 1)
> +
> +/*
> + * There is a single feature flag that signifies the presence of the MSR
> + * that can be used to retrieve both the local APIC Timer frequency as
> + * well as the TSC frequency.
> + */
> +
> +/* Local APIC timer frequency MSR (HV_X64_MSR_APIC_FREQUENCY) is available */
> +#define HV_X64_MSR_APIC_FREQUENCY_AVAILABLE (1 << 11)
> +
> +/* TSC frequency MSR (HV_X64_MSR_TSC_FREQUENCY) is available */
> +#define HV_X64_MSR_TSC_FREQUENCY_AVAILABLE (1 << 11)
> +
> /*
> * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM
> * and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15) available
> @@ -136,6 +149,12 @@
> /* MSR used to read the per-partition time reference counter */
> #define HV_X64_MSR_TIME_REF_COUNT 0x40000020
>
> +/* MSR used to retrieve the TSC frequency */
> +#define HV_X64_MSR_TSC_FREQUENCY 0x40000022
> +
You do not use this MSR in the patch, but in general how it suppose to
work during migration if host TSC frequency changes?

> +/* MSR used to retrieve the local APIC timer frequency */
> +#define HV_X64_MSR_APIC_FREQUENCY 0x40000023
> +
> /* Define the virtual APIC registers */
> #define HV_X64_MSR_EOI 0x40000070
> #define HV_X64_MSR_ICR 0x40000071
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 71a39f3..b3dc639 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -15,6 +15,7 @@
> #include <linux/clocksource.h>
> #include <linux/module.h>
> #include <linux/hardirq.h>
> +#include <linux/efi.h>
> #include <linux/interrupt.h>
> #include <asm/processor.h>
> #include <asm/hypervisor.h>
> @@ -23,6 +24,7 @@
> #include <asm/desc.h>
> #include <asm/idle.h>
> #include <asm/irq_regs.h>
> +#include <asm/i8259.h>
>
> struct ms_hyperv_info ms_hyperv;
> EXPORT_SYMBOL_GPL(ms_hyperv);
> @@ -67,6 +69,8 @@ static struct clocksource hyperv_cs = {
>
> static void __init ms_hyperv_init_platform(void)
> {
> + u64 hv_lapic_frequency;
> +
> /*
> * Extract the features and hints
> */
> @@ -76,6 +80,26 @@ static void __init ms_hyperv_init_platform(void)
> printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
> ms_hyperv.features, ms_hyperv.hints);
>
> + if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) {
> + /*
> + * Get the APIC frequency.
> + */
> + rdmsrl(HV_X64_MSR_APIC_FREQUENCY, hv_lapic_frequency);
> + hv_lapic_frequency /= HZ;
> + lapic_timer_frequency = hv_lapic_frequency;
> + printk(KERN_INFO "HyperV: LAPIC Timer Frequency: %#x\n",
> + lapic_timer_frequency);
> +
> + /*
> + * On Hyper-V, when we are booting off an EFI firmware stack,
> + * we do not have many legacy devices including PIC, PIT etc.
> + */
> + if (efi_enabled(EFI_BOOT)) {
> + printk(KERN_INFO "HyperV: Using null_legacy_pic\n");
> + legacy_pic = &null_legacy_pic;
> + }
> + }
> +
> if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
> clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
> }
> --
> 1.7.4.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

--
Gleb.

2013-09-04 15:03:50

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: Jan Beulich [mailto:[email protected]]
> Sent: Wednesday, September 04, 2013 12:17 AM
> To: KY Srinivasan
> Cc: [email protected]; [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> >>> On 03.09.13 at 20:30, "K. Y. Srinivasan" <[email protected]> wrote:
> > @@ -76,6 +80,26 @@ static void __init ms_hyperv_init_platform(void)
> > printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
> > ms_hyperv.features, ms_hyperv.hints);
> >
> > + if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) {
> > + /*
> > + * Get the APIC frequency.
> > + */
> > + rdmsrl(HV_X64_MSR_APIC_FREQUENCY, hv_lapic_frequency);
> > + hv_lapic_frequency /= HZ;
> > + lapic_timer_frequency = hv_lapic_frequency;
> > + printk(KERN_INFO "HyperV: LAPIC Timer Frequency: %#x\n",
> > + lapic_timer_frequency);
> > +
> > + /*
> > + * On Hyper-V, when we are booting off an EFI firmware stack,
> > + * we do not have many legacy devices including PIC, PIT etc.
> > + */
> > + if (efi_enabled(EFI_BOOT)) {
> > + printk(KERN_INFO "HyperV: Using null_legacy_pic\n");
> > + legacy_pic = &null_legacy_pic;
> > + }
>
> And this check is really connected to the feature check around the
> whole block, rather than being independent? (I'd also think that
> this latter message would suffice to be KERN_DEBUG).

I felt it was safer to first check for the feature since if the feature is not
there, we need to calibrate based on PIT. Furthermore, the feature is available
even in legacy environments when we are not booting on an EFI stack.

Regards,

K. Y

>
> Jan

2013-09-04 15:16:36

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: Gleb Natapov [mailto:[email protected]]
> Sent: Wednesday, September 04, 2013 2:40 AM
> To: KY Srinivasan
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On Tue, Sep 03, 2013 at 11:30:23AM -0700, K. Y. Srinivasan wrote:
> > Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this
> and bypass
> > the calibration code in the kernel. This would allow us to boot the Linux kernel
> as a
> > "modern VM" on Hyper-V where many of the legacy devices (such as PIT) are
> not emulated.
> >
> > I would like to thank Olaf Hering <[email protected]>, Jan Beulich
> <[email protected]> and
> > H. Peter Anvin <[email protected]> for their help in this effort.
> >
> > In this version of the patch, I have addressed Jan's comments.
> >
> > Signed-off-by: K. Y. Srinivasan <[email protected]>
> > ---
> > arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
> > arch/x86/kernel/cpu/mshyperv.c | 24 ++++++++++++++++++++++++
> > 2 files changed, 43 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/x86/include/uapi/asm/hyperv.h
> b/arch/x86/include/uapi/asm/hyperv.h
> > index b80420b..b8f1c01 100644
> > --- a/arch/x86/include/uapi/asm/hyperv.h
> > +++ b/arch/x86/include/uapi/asm/hyperv.h
> > @@ -27,6 +27,19 @@
> > #define HV_X64_MSR_VP_RUNTIME_AVAILABLE (1 << 0)
> > /* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/
> > #define HV_X64_MSR_TIME_REF_COUNT_AVAILABLE (1 << 1)
> > +
> > +/*
> > + * There is a single feature flag that signifies the presence of the MSR
> > + * that can be used to retrieve both the local APIC Timer frequency as
> > + * well as the TSC frequency.
> > + */
> > +
> > +/* Local APIC timer frequency MSR (HV_X64_MSR_APIC_FREQUENCY) is
> available */
> > +#define HV_X64_MSR_APIC_FREQUENCY_AVAILABLE (1 << 11)
> > +
> > +/* TSC frequency MSR (HV_X64_MSR_TSC_FREQUENCY) is available */
> > +#define HV_X64_MSR_TSC_FREQUENCY_AVAILABLE (1 << 11)
> > +
> > /*
> > * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM
> > * and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15) available
> > @@ -136,6 +149,12 @@
> > /* MSR used to read the per-partition time reference counter */
> > #define HV_X64_MSR_TIME_REF_COUNT 0x40000020
> >
> > +/* MSR used to retrieve the TSC frequency */
> > +#define HV_X64_MSR_TSC_FREQUENCY 0x40000022
> > +
> You do not use this MSR in the patch, but in general how it suppose to
> work during migration if host TSC frequency changes?

TSC related migration issues are distinct from how we calibrate the TSC frequency. This MSR
allows you to retrieve the TSC frequency without having to do explicit calibration.

To address the migration issues; the hypervisor provides additional information on the host
that you are running that can be used to compensate for differences in TSC across hosts.

Regards,

K. Y

2013-09-05 14:20:47

by Gleb Natapov

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On Wed, Sep 04, 2013 at 03:16:30PM +0000, KY Srinivasan wrote:
>
>
> > -----Original Message-----
> > From: Gleb Natapov [mailto:[email protected]]
> > Sent: Wednesday, September 04, 2013 2:40 AM
> > To: KY Srinivasan
> > Cc: [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]
> > Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> > from the hypervisor
> >
> > On Tue, Sep 03, 2013 at 11:30:23AM -0700, K. Y. Srinivasan wrote:
> > > Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this
> > and bypass
> > > the calibration code in the kernel. This would allow us to boot the Linux kernel
> > as a
> > > "modern VM" on Hyper-V where many of the legacy devices (such as PIT) are
> > not emulated.
> > >
> > > I would like to thank Olaf Hering <[email protected]>, Jan Beulich
> > <[email protected]> and
> > > H. Peter Anvin <[email protected]> for their help in this effort.
> > >
> > > In this version of the patch, I have addressed Jan's comments.
> > >
> > > Signed-off-by: K. Y. Srinivasan <[email protected]>
> > > ---
> > > arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
> > > arch/x86/kernel/cpu/mshyperv.c | 24 ++++++++++++++++++++++++
> > > 2 files changed, 43 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/arch/x86/include/uapi/asm/hyperv.h
> > b/arch/x86/include/uapi/asm/hyperv.h
> > > index b80420b..b8f1c01 100644
> > > --- a/arch/x86/include/uapi/asm/hyperv.h
> > > +++ b/arch/x86/include/uapi/asm/hyperv.h
> > > @@ -27,6 +27,19 @@
> > > #define HV_X64_MSR_VP_RUNTIME_AVAILABLE (1 << 0)
> > > /* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/
> > > #define HV_X64_MSR_TIME_REF_COUNT_AVAILABLE (1 << 1)
> > > +
> > > +/*
> > > + * There is a single feature flag that signifies the presence of the MSR
> > > + * that can be used to retrieve both the local APIC Timer frequency as
> > > + * well as the TSC frequency.
> > > + */
> > > +
> > > +/* Local APIC timer frequency MSR (HV_X64_MSR_APIC_FREQUENCY) is
> > available */
> > > +#define HV_X64_MSR_APIC_FREQUENCY_AVAILABLE (1 << 11)
> > > +
> > > +/* TSC frequency MSR (HV_X64_MSR_TSC_FREQUENCY) is available */
> > > +#define HV_X64_MSR_TSC_FREQUENCY_AVAILABLE (1 << 11)
> > > +
> > > /*
> > > * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM
> > > * and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15) available
> > > @@ -136,6 +149,12 @@
> > > /* MSR used to read the per-partition time reference counter */
> > > #define HV_X64_MSR_TIME_REF_COUNT 0x40000020
> > >
> > > +/* MSR used to retrieve the TSC frequency */
> > > +#define HV_X64_MSR_TSC_FREQUENCY 0x40000022
> > > +
> > You do not use this MSR in the patch, but in general how it suppose to
> > work during migration if host TSC frequency changes?
>
> TSC related migration issues are distinct from how we calibrate the TSC frequency. This MSR
> allows you to retrieve the TSC frequency without having to do explicit calibration.
>
But the value retrieved can be obsolete by the time guest sues it due to
migration.

> To address the migration issues; the hypervisor provides additional information on the host
> that you are running that can be used to compensate for differences in TSC across hosts.
>
Are you referring to "Reference TSC Page" here?

--
Gleb.

2013-09-13 00:06:57

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: K. Y. Srinivasan [mailto:[email protected]]
> Sent: Tuesday, September 03, 2013 11:30 AM
> To: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Cc: KY Srinivasan
> Subject: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from
> the hypervisor
>
> Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this
> and bypass
> the calibration code in the kernel. This would allow us to boot the Linux kernel as
> a
> "modern VM" on Hyper-V where many of the legacy devices (such as PIT) are not
> emulated.
>
> I would like to thank Olaf Hering <[email protected]>, Jan Beulich
> <[email protected]> and
> H. Peter Anvin <[email protected]> for their help in this effort.
>
> In this version of the patch, I have addressed Jan's comments.
>
> Signed-off-by: K. Y. Srinivasan <[email protected]>
> ---
> arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
> arch/x86/kernel/cpu/mshyperv.c | 24 ++++++++++++++++++++++++
> 2 files changed, 43 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/include/uapi/asm/hyperv.h
> b/arch/x86/include/uapi/asm/hyperv.h
> index b80420b..b8f1c01 100644
> --- a/arch/x86/include/uapi/asm/hyperv.h
> +++ b/arch/x86/include/uapi/asm/hyperv.h
> @@ -27,6 +27,19 @@
> #define HV_X64_MSR_VP_RUNTIME_AVAILABLE (1 << 0)
> /* Partition Reference Counter (HV_X64_MSR_TIME_REF_COUNT) available*/
> #define HV_X64_MSR_TIME_REF_COUNT_AVAILABLE (1 << 1)
> +
> +/*
> + * There is a single feature flag that signifies the presence of the MSR
> + * that can be used to retrieve both the local APIC Timer frequency as
> + * well as the TSC frequency.
> + */
> +
> +/* Local APIC timer frequency MSR (HV_X64_MSR_APIC_FREQUENCY) is
> available */
> +#define HV_X64_MSR_APIC_FREQUENCY_AVAILABLE (1 << 11)
> +
> +/* TSC frequency MSR (HV_X64_MSR_TSC_FREQUENCY) is available */
> +#define HV_X64_MSR_TSC_FREQUENCY_AVAILABLE (1 << 11)
> +
> /*
> * Basic SynIC MSRs (HV_X64_MSR_SCONTROL through HV_X64_MSR_EOM
> * and HV_X64_MSR_SINT0 through HV_X64_MSR_SINT15) available
> @@ -136,6 +149,12 @@
> /* MSR used to read the per-partition time reference counter */
> #define HV_X64_MSR_TIME_REF_COUNT 0x40000020
>
> +/* MSR used to retrieve the TSC frequency */
> +#define HV_X64_MSR_TSC_FREQUENCY 0x40000022
> +
> +/* MSR used to retrieve the local APIC timer frequency */
> +#define HV_X64_MSR_APIC_FREQUENCY 0x40000023
> +
> /* Define the virtual APIC registers */
> #define HV_X64_MSR_EOI 0x40000070
> #define HV_X64_MSR_ICR 0x40000071
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> index 71a39f3..b3dc639 100644
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -15,6 +15,7 @@
> #include <linux/clocksource.h>
> #include <linux/module.h>
> #include <linux/hardirq.h>
> +#include <linux/efi.h>
> #include <linux/interrupt.h>
> #include <asm/processor.h>
> #include <asm/hypervisor.h>
> @@ -23,6 +24,7 @@
> #include <asm/desc.h>
> #include <asm/idle.h>
> #include <asm/irq_regs.h>
> +#include <asm/i8259.h>
>
> struct ms_hyperv_info ms_hyperv;
> EXPORT_SYMBOL_GPL(ms_hyperv);
> @@ -67,6 +69,8 @@ static struct clocksource hyperv_cs = {
>
> static void __init ms_hyperv_init_platform(void)
> {
> + u64 hv_lapic_frequency;
> +
> /*
> * Extract the features and hints
> */
> @@ -76,6 +80,26 @@ static void __init ms_hyperv_init_platform(void)
> printk(KERN_INFO "HyperV: features 0x%x, hints 0x%x\n",
> ms_hyperv.features, ms_hyperv.hints);
>
> + if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) {
> + /*
> + * Get the APIC frequency.
> + */
> + rdmsrl(HV_X64_MSR_APIC_FREQUENCY, hv_lapic_frequency);
> + hv_lapic_frequency /= HZ;
> + lapic_timer_frequency = hv_lapic_frequency;
> + printk(KERN_INFO "HyperV: LAPIC Timer Frequency: %#x\n",
> + lapic_timer_frequency);
> +
> + /*
> + * On Hyper-V, when we are booting off an EFI firmware stack,
> + * we do not have many legacy devices including PIC, PIT etc.
> + */
> + if (efi_enabled(EFI_BOOT)) {
> + printk(KERN_INFO "HyperV: Using null_legacy_pic\n");
> + legacy_pic = &null_legacy_pic;
> + }
> + }
> +
> if (ms_hyperv.features & HV_X64_MSR_TIME_REF_COUNT_AVAILABLE)
> clocksource_register_hz(&hyperv_cs, NSEC_PER_SEC/100);
> }
> --
> 1.7.4.1

Peter,

Let me know if you want me to address any additional issues in this patch.


Regards,

K. Y

2013-09-13 00:29:12

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On 09/12/2013 05:06 PM, KY Srinivasan wrote:
>
> Peter,
>
> Let me know if you want me to address any additional issues in this patch.
>

Please address Jan and Gleb's feedback.

-hpa

2013-09-13 01:43:16

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: H. Peter Anvin [mailto:[email protected]]
> Sent: Thursday, September 12, 2013 5:28 PM
> To: KY Srinivasan
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On 09/12/2013 05:06 PM, KY Srinivasan wrote:
> >
> > Peter,
> >
> > Let me know if you want me to address any additional issues in this patch.
> >
>
> Please address Jan and Gleb's feedback.

Gleb's feedback was a question and I answered that as I did Jan's feedback as well.
Gleb, Jan, please let me know if there is something else you want addressed here.

Regards,

K. Y

2013-09-13 06:39:15

by Jan Beulich

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

>>> On 13.09.13 at 03:43, KY Srinivasan <[email protected]> wrote:

>
>> -----Original Message-----
>> From: H. Peter Anvin [mailto:[email protected]]
>> Sent: Thursday, September 12, 2013 5:28 PM
>> To: KY Srinivasan
>> Cc: [email protected]; [email protected]; [email protected];
>> [email protected]; [email protected]; [email protected];
>> [email protected]; [email protected]; [email protected]; [email protected]
>> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
>> from the hypervisor
>>
>> On 09/12/2013 05:06 PM, KY Srinivasan wrote:
>> >
>> > Peter,
>> >
>> > Let me know if you want me to address any additional issues in this patch.
>> >
>>
>> Please address Jan and Gleb's feedback.
>
> Gleb's feedback was a question and I answered that as I did Jan's feedback
> as well.
> Gleb, Jan, please let me know if there is something else you want addressed
> here.

Indeed, apart from the question whether to change that one
message's level from KERN_INFO to KERN_DEBUG, there was
nothing really left unexplained (the aspect of the artificial tying
together of distinct features is really something KY has to
decide - I merely tried to point out that this is odd).

Jan

2013-09-13 09:56:06

by Gleb Natapov

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On Fri, Sep 13, 2013 at 01:43:09AM +0000, KY Srinivasan wrote:
>
>
> > -----Original Message-----
> > From: H. Peter Anvin [mailto:[email protected]]
> > Sent: Thursday, September 12, 2013 5:28 PM
> > To: KY Srinivasan
> > Cc: [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected]; [email protected]
> > Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> > from the hypervisor
> >
> > On 09/12/2013 05:06 PM, KY Srinivasan wrote:
> > >
> > > Peter,
> > >
> > > Let me know if you want me to address any additional issues in this patch.
> > >
> >
> > Please address Jan and Gleb's feedback.
>
> Gleb's feedback was a question and I answered that as I did Jan's feedback as well.
> Gleb, Jan, please let me know if there is something else you want addressed here.
>
No, I am just interesting to know some details about the interface since
I cannot find it documented in Hyper-V spec.

--
Gleb.

2013-09-13 14:29:45

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: Gleb Natapov [mailto:[email protected]]
> Sent: Friday, September 13, 2013 2:55 AM
> To: KY Srinivasan
> Cc: H. Peter Anvin; [email protected]; [email protected]; linux-
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On Fri, Sep 13, 2013 at 01:43:09AM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: H. Peter Anvin [mailto:[email protected]]
> > > Sent: Thursday, September 12, 2013 5:28 PM
> > > To: KY Srinivasan
> > > Cc: [email protected]; [email protected]; linux-
> [email protected];
> > > [email protected]; [email protected]; [email protected];
> > > [email protected]; [email protected]; [email protected];
> [email protected]
> > > Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> > > from the hypervisor
> > >
> > > On 09/12/2013 05:06 PM, KY Srinivasan wrote:
> > > >
> > > > Peter,
> > > >
> > > > Let me know if you want me to address any additional issues in this patch.
> > > >
> > >
> > > Please address Jan and Gleb's feedback.
> >
> > Gleb's feedback was a question and I answered that as I did Jan's feedback as
> well.
> > Gleb, Jan, please let me know if there is something else you want addressed
> here.
> >
> No, I am just interesting to know some details about the interface since
> I cannot find it documented in Hyper-V spec.

Thanks Gleb. Here is the link for the latest Hyper-V specification:
http://www.microsoft.com/en-us/download/details.aspx?id=39289

This spec talks about how migration is handled with regards to TSC.

Peter, if you are ok with the message level, there is no other current issue
that is left unaddressed.

Regards,

K. Y
>
> --
> Gleb.

2013-09-13 14:30:20

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: Jan Beulich [mailto:[email protected]]
> Sent: Thursday, September 12, 2013 11:39 PM
> To: KY Srinivasan; H. Peter Anvin
> Cc: [email protected]; [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> >>> On 13.09.13 at 03:43, KY Srinivasan <[email protected]> wrote:
>
> >
> >> -----Original Message-----
> >> From: H. Peter Anvin [mailto:[email protected]]
> >> Sent: Thursday, September 12, 2013 5:28 PM
> >> To: KY Srinivasan
> >> Cc: [email protected]; [email protected]; linux-
> [email protected];
> >> [email protected]; [email protected]; [email protected];
> >> [email protected]; [email protected]; [email protected];
> [email protected]
> >> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> >> from the hypervisor
> >>
> >> On 09/12/2013 05:06 PM, KY Srinivasan wrote:
> >> >
> >> > Peter,
> >> >
> >> > Let me know if you want me to address any additional issues in this patch.
> >> >
> >>
> >> Please address Jan and Gleb's feedback.
> >
> > Gleb's feedback was a question and I answered that as I did Jan's feedback
> > as well.
> > Gleb, Jan, please let me know if there is something else you want addressed
> > here.
>
> Indeed, apart from the question whether to change that one
> message's level from KERN_INFO to KERN_DEBUG, there was
> nothing really left unexplained (the aspect of the artificial tying
> together of distinct features is really something KY has to
> decide - I merely tried to point out that this is odd).

Thanks Jan. Peter, if it is ok with you, I would like to keep the message
level at KERN_INFO.

Regards,

K. Y

2013-09-17 14:54:34

by Gleb Natapov

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On Fri, Sep 13, 2013 at 02:28:35PM +0000, KY Srinivasan wrote:
>
>
> > -----Original Message-----
> > From: Gleb Natapov [mailto:[email protected]]
> > Sent: Friday, September 13, 2013 2:55 AM
> > To: KY Srinivasan
> > Cc: H. Peter Anvin; [email protected]; [email protected]; linux-
> > [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]; [email protected];
> > [email protected]; [email protected]
> > Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> > from the hypervisor
> >
> > On Fri, Sep 13, 2013 at 01:43:09AM +0000, KY Srinivasan wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: H. Peter Anvin [mailto:[email protected]]
> > > > Sent: Thursday, September 12, 2013 5:28 PM
> > > > To: KY Srinivasan
> > > > Cc: [email protected]; [email protected]; linux-
> > [email protected];
> > > > [email protected]; [email protected]; [email protected];
> > > > [email protected]; [email protected]; [email protected];
> > [email protected]
> > > > Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> > > > from the hypervisor
> > > >
> > > > On 09/12/2013 05:06 PM, KY Srinivasan wrote:
> > > > >
> > > > > Peter,
> > > > >
> > > > > Let me know if you want me to address any additional issues in this patch.
> > > > >
> > > >
> > > > Please address Jan and Gleb's feedback.
> > >
> > > Gleb's feedback was a question and I answered that as I did Jan's feedback as
> > well.
> > > Gleb, Jan, please let me know if there is something else you want addressed
> > here.
> > >
> > No, I am just interesting to know some details about the interface since
> > I cannot find it documented in Hyper-V spec.
>
> Thanks Gleb. Here is the link for the latest Hyper-V specification:
> http://www.microsoft.com/en-us/download/details.aspx?id=39289
>
> This spec talks about how migration is handled with regards to TSC.
>
All I can see is "15.4.3 Partition Reference TSC Mechanism". I see
nothing about HV_X64_MSR_TSC_FREQUENCY specifically. To access this MSR
a partition needs AccessFrequencyMsrs privilege, may be partition that
cab be migrated does not have this privilege?

--
Gleb.

2013-09-17 19:53:42

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: Gleb Natapov [mailto:[email protected]]
> Sent: Tuesday, September 17, 2013 6:59 AM
> To: KY Srinivasan
> Cc: H. Peter Anvin; [email protected]; [email protected]; linux-
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On Fri, Sep 13, 2013 at 02:28:35PM +0000, KY Srinivasan wrote:
> >
> >
> > > -----Original Message-----
> > > From: Gleb Natapov [mailto:[email protected]]
> > > Sent: Friday, September 13, 2013 2:55 AM
> > > To: KY Srinivasan
> > > Cc: H. Peter Anvin; [email protected]; [email protected]; linux-
> > > [email protected]; [email protected]; [email protected];
> > > [email protected]; [email protected]; [email protected];
> > > [email protected]; [email protected]
> > > Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> > > from the hypervisor
> > >
> > > On Fri, Sep 13, 2013 at 01:43:09AM +0000, KY Srinivasan wrote:
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: H. Peter Anvin [mailto:[email protected]]
> > > > > Sent: Thursday, September 12, 2013 5:28 PM
> > > > > To: KY Srinivasan
> > > > > Cc: [email protected]; [email protected]; linux-
> > > [email protected];
> > > > > [email protected]; [email protected]; [email protected];
> > > > > [email protected]; [email protected]; [email protected];
> > > [email protected]
> > > > > Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer
> frequency
> > > > > from the hypervisor
> > > > >
> > > > > On 09/12/2013 05:06 PM, KY Srinivasan wrote:
> > > > > >
> > > > > > Peter,
> > > > > >
> > > > > > Let me know if you want me to address any additional issues in this
> patch.
> > > > > >
> > > > >
> > > > > Please address Jan and Gleb's feedback.
> > > >
> > > > Gleb's feedback was a question and I answered that as I did Jan's feedback
> as
> > > well.
> > > > Gleb, Jan, please let me know if there is something else you want
> addressed
> > > here.
> > > >
> > > No, I am just interesting to know some details about the interface since
> > > I cannot find it documented in Hyper-V spec.
> >
> > Thanks Gleb. Here is the link for the latest Hyper-V specification:
> > http://www.microsoft.com/en-us/download/details.aspx?id=39289
> >
> > This spec talks about how migration is handled with regards to TSC.
> >
> All I can see is "15.4.3 Partition Reference TSC Mechanism". I see
> nothing about HV_X64_MSR_TSC_FREQUENCY specifically. To access this MSR
> a partition needs AccessFrequencyMsrs privilege, may be partition that
> cab be migrated does not have this privilege?

If you use the MSR to read the TSC frequency, then indeed when you migrate then there
is no guarantee that the TSC frequency won't change when you migrate. The approach
described in section 15.4.3 is the preferred approach that can accommodate migration.

Regards,

K. Y
>
> --
> Gleb.

2013-09-18 05:44:07

by Gleb Natapov

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On Tue, Sep 17, 2013 at 07:53:36PM +0000, KY Srinivasan wrote:
> > > Thanks Gleb. Here is the link for the latest Hyper-V specification:
> > > http://www.microsoft.com/en-us/download/details.aspx?id=39289
> > >
> > > This spec talks about how migration is handled with regards to TSC.
> > >
> > All I can see is "15.4.3 Partition Reference TSC Mechanism". I see
> > nothing about HV_X64_MSR_TSC_FREQUENCY specifically. To access this MSR
> > a partition needs AccessFrequencyMsrs privilege, may be partition that
> > cab be migrated does not have this privilege?
>
> If you use the MSR to read the TSC frequency, then indeed when you migrate then there
> is no guarantee that the TSC frequency won't change when you migrate. The approach
> described in section 15.4.3 is the preferred approach that can accommodate migration.
>
Thanks.

--
Gleb.

2013-09-23 13:03:13

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: Gleb Natapov [mailto:[email protected]]
> Sent: Tuesday, September 17, 2013 10:44 PM
> To: KY Srinivasan
> Cc: H. Peter Anvin; [email protected]; [email protected]; linux-
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On Tue, Sep 17, 2013 at 07:53:36PM +0000, KY Srinivasan wrote:
> > > > Thanks Gleb. Here is the link for the latest Hyper-V specification:
> > > > http://www.microsoft.com/en-us/download/details.aspx?id=39289
> > > >
> > > > This spec talks about how migration is handled with regards to TSC.
> > > >
> > > All I can see is "15.4.3 Partition Reference TSC Mechanism". I see
> > > nothing about HV_X64_MSR_TSC_FREQUENCY specifically. To access this MSR
> > > a partition needs AccessFrequencyMsrs privilege, may be partition that
> > > cab be migrated does not have this privilege?
> >
> > If you use the MSR to read the TSC frequency, then indeed when you migrate
> then there
> > is no guarantee that the TSC frequency won't change when you migrate. The
> approach
> > described in section 15.4.3 is the preferred approach that can accommodate
> migration.
> >
> Thanks.

Peter,
Please let me know if there are other issues I need to address here. Now that Dmitry has queued up the
Hyper-V keyboard driver, with this patch we can fully support Linux on our uefi firmware.

Regards,

K. Y

2013-09-23 15:52:12

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On 09/23/2013 06:02 AM, KY Srinivasan wrote:
>
> Peter,
> Please let me know if there are other issues I need to address here. Now that Dmitry has queued up the
> Hyper-V keyboard driver, with this patch we can fully support Linux on our uefi firmware.
>

I just got back from Plumber's -- this is on my short list of things to
look at. If you haven't heard anything by Wednesday, ping me.

-hpa

2013-09-23 19:24:10

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: H. Peter Anvin [mailto:[email protected]]
> Sent: Monday, September 23, 2013 8:50 AM
> To: KY Srinivasan
> Cc: Gleb Natapov; [email protected]; [email protected]; linux-
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On 09/23/2013 06:02 AM, KY Srinivasan wrote:
> >
> > Peter,
> > Please let me know if there are other issues I need to address here. Now that
> Dmitry has queued up the
> > Hyper-V keyboard driver, with this patch we can fully support Linux on our uefi
> firmware.
> >
>
> I just got back from Plumber's -- this is on my short list of things to
> look at. If you haven't heard anything by Wednesday, ping me.

Thank you.

K. Y

2013-09-27 15:10:42

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On Tue, Sep 03, K. Y. Srinivasan wrote:

> Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this and bypass
> the calibration code in the kernel. This would allow us to boot the Linux kernel as a
> "modern VM" on Hyper-V where many of the legacy devices (such as PIT) are not emulated.

> + if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) {
> + /*
> + * Get the APIC frequency.
> + */
> + rdmsrl(HV_X64_MSR_APIC_FREQUENCY, hv_lapic_frequency);
> + hv_lapic_frequency /= HZ;

This leads to build errors on 32bit:

linux-3.12-rc2/arch/x86/kernel/cpu/mshyperv.c:88: undefined reference to `__udivdi3'

Up to now I have only tested on 64bit, sorry for that.


Olaf

2013-09-27 15:23:34

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: Olaf Hering [mailto:[email protected]]
> Sent: Friday, September 27, 2013 8:10 AM
> To: KY Srinivasan
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On Tue, Sep 03, K. Y. Srinivasan wrote:
>
> > Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this
> and bypass
> > the calibration code in the kernel. This would allow us to boot the Linux kernel
> as a
> > "modern VM" on Hyper-V where many of the legacy devices (such as PIT) are
> not emulated.
>
> > + if (ms_hyperv.features & HV_X64_MSR_APIC_FREQUENCY_AVAILABLE) {
> > + /*
> > + * Get the APIC frequency.
> > + */
> > + rdmsrl(HV_X64_MSR_APIC_FREQUENCY, hv_lapic_frequency);
> > + hv_lapic_frequency /= HZ;
>
> This leads to build errors on 32bit:
>
> linux-3.12-rc2/arch/x86/kernel/cpu/mshyperv.c:88: undefined reference to
> `__udivdi3'
>
> Up to now I have only tested on 64bit, sorry for that.

Thanks Olaf. I am travelling currently; I will fix it when I get back (early next week).

K. Y
>
>
> Olaf
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-09-27 15:32:57

by Olaf Hering

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On Fri, Sep 27, KY Srinivasan wrote:

> > This leads to build errors on 32bit:
> >
> > linux-3.12-rc2/arch/x86/kernel/cpu/mshyperv.c:88: undefined reference to
> > `__udivdi3'
> >
> > Up to now I have only tested on 64bit, sorry for that.
>
> Thanks Olaf. I am travelling currently; I will fix it when I get back (early next week).

This change seems to fix it:

-+ hv_lapic_frequency /= HZ;
++ div_u64(hv_lapic_frequency, HZ);

Olaf

2013-09-27 15:35:26

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: Olaf Hering [mailto:[email protected]]
> Sent: Friday, September 27, 2013 8:33 AM
> To: KY Srinivasan
> Cc: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On Fri, Sep 27, KY Srinivasan wrote:
>
> > > This leads to build errors on 32bit:
> > >
> > > linux-3.12-rc2/arch/x86/kernel/cpu/mshyperv.c:88: undefined reference to
> > > `__udivdi3'
> > >
> > > Up to now I have only tested on 64bit, sorry for that.
> >
> > Thanks Olaf. I am travelling currently; I will fix it when I get back (early next
> week).
>
> This change seems to fix it:
>
> -+ hv_lapic_frequency /= HZ;
> ++ div_u64(hv_lapic_frequency, HZ);

Thanks Olaf. Could you submit the patch.

Regards,

K. Y
????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2013-10-02 23:11:45

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: H. Peter Anvin [mailto:[email protected]]
> Sent: Monday, September 23, 2013 8:50 AM
> To: KY Srinivasan
> Cc: Gleb Natapov; [email protected]; [email protected]; linux-
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On 09/23/2013 06:02 AM, KY Srinivasan wrote:
> >
> > Peter,
> > Please let me know if there are other issues I need to address here. Now that
> Dmitry has queued up the
> > Hyper-V keyboard driver, with this patch we can fully support Linux on our uefi
> firmware.
> >
>
> I just got back from Plumber's -- this is on my short list of things to
> look at. If you haven't heard anything by Wednesday, ping me.

Ping.

K. Y
>
> -hpa
>

2013-10-09 22:50:41

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor

On 09/27/2013 08:35 AM, KY Srinivasan wrote:
>
> Thanks Olaf. Could you submit the patch.
>

Haven't heard anything from Olaf... could you fold in the fix and resumbit?

-hpa

2013-10-10 00:04:25

by KY Srinivasan

[permalink] [raw]
Subject: RE: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor



> -----Original Message-----
> From: H. Peter Anvin [mailto:[email protected]]
> Sent: Wednesday, October 09, 2013 3:50 PM
> To: KY Srinivasan
> Cc: Olaf Hering; [email protected]; [email protected]; linux-
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency
> from the hypervisor
>
> On 09/27/2013 08:35 AM, KY Srinivasan wrote:
> >
> > Thanks Olaf. Could you submit the patch.
> >
>
> Haven't heard anything from Olaf... could you fold in the fix and resumbit?

I think Olaf sent the updated patch out; I will dig up the email and resend it.

Regards,

K. Y
>
> -hpa
>

????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?