X86: Hyper-V: Get the local APIC timer frequency from the hypervisor
Subsystems (2)
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.
--- arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++ arch/x86/kernel/cpu/mshyperv.c | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 0 deletions(-)
arch/x86/include/uapi/asm/hyperv.h +19 -0
@@ -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
arch/x86/kernel/cpu/mshyperv.c +24 -0
@@ -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 ); }
Signature · 1 line
1.7.4.1
Quoted 13 lines
Quoted 1 line
Quoted 1 line · K. Y. Srinivasan
arch/x86/kernel/cpu/mshyperv.c +8
-0@@ -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",
arch/x86/kernel/cpu/mshyperv.c static void __init ms_hyperv_init_platform(void) · line 100
Quoted 10 lines
arch/x86/kernel/cpu/mshyperv.c +10
-0+ 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
Quoted 31 lines
-----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 hypervisorQuoted 19 lines
Quoted 1 line
Quoted 1 line · K. Y. Srinivasan
arch/x86/kernel/cpu/mshyperv.c +14
-0@@ -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. +*/
Quoted 8 lines
arch/x86/kernel/cpu/mshyperv.c static void __init ms_hyperv_init_platform(void) · line 100
Quoted 4 lines
arch/x86/kernel/cpu/mshyperv.c +4
-0+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
Quoted 2 lines
Jan
Quoted 40 lines · K. Y. Srinivasan
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(-)arch/x86/include/uapi/asm/hyperv.h +13
-0@@ -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
arch/x86/include/uapi/asm/hyperv.h line 154
Quoted 6 lines
arch/x86/include/uapi/asm/hyperv.h +3
-0@@ -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?
Quoted 70 lines
arch/x86/include/uapi/asm/hyperv.h +3
-0+/* 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 0x40000071arch/x86/kernel/cpu/mshyperv.c +24
-0@@ -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 ); }Signature · 7 lines
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.
Quoted 63 lines
-----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 hypervisorQuoted 1 line · K. Y. Srinivasan
Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this
and bypass
Quoted 1 line
the calibration code in the kernel. This would allow us to boot the Linux kernel
as a
Quoted 1 line
"modern VM" on Hyper-V where many of the legacy devices (such as PIT) are
not emulated.
Quoted 2 lines
I would like to thank Olaf Hering <[email protected]>, Jan Beulich
<[email protected]> and
Review
Quoted 11 lines
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(-)(quoted diff) +0
-0
b/arch/x86/include/uapi/asm/hyperv.hQuoted 5 lines
index b80420b..b8f1c01 100644
arch/x86/include/uapi/asm/hyperv.h +0
-0@@ -27,6 +27,19 @@#define HV_X64_MSR_VP_RUNTIME_AVAILABLE (1 << 0)arch/x86/include/uapi/asm/hyperv.h line 37
Quoted 10 lines
arch/x86/include/uapi/asm/hyperv.h +8
-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 */
Quoted 12 lines
arch/x86/include/uapi/asm/hyperv.h +5
-0+#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
Quoted 5 lines
arch/x86/include/uapi/asm/hyperv.h line 154
Quoted 3 lines
arch/x86/include/uapi/asm/hyperv.h +3
-0+/* 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
Quoted 63 lines · KY Srinivasan
Quoted 63 lines
-----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 hypervisorQuoted 1 line · K. Y. Srinivasan
Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this
and bypass
Quoted 1 line
the calibration code in the kernel. This would allow us to boot the Linux kernel
as a
Quoted 1 line
"modern VM" on Hyper-V where many of the legacy devices (such as PIT) are
not emulated.
Quoted 2 lines
I would like to thank Olaf Hering <[email protected]>, Jan Beulich
<[email protected]> and
Review
Quoted 11 lines
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(-)(quoted diff) +0
-0
b/arch/x86/include/uapi/asm/hyperv.hQuoted 5 lines
index b80420b..b8f1c01 100644
arch/x86/include/uapi/asm/hyperv.h +0
-0@@ -27,6 +27,19 @@#define HV_X64_MSR_VP_RUNTIME_AVAILABLE (1 << 0)arch/x86/include/uapi/asm/hyperv.h line 37
Quoted 10 lines
arch/x86/include/uapi/asm/hyperv.h +8
-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 */
Quoted 12 lines
arch/x86/include/uapi/asm/hyperv.h +5
-0+#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
Quoted 9 lines
Quoted 5 lines
arch/x86/include/uapi/asm/hyperv.h line 154
Quoted 3 lines
arch/x86/include/uapi/asm/hyperv.h +3
-0+/* 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.
Quoted 3 lines
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.
Quoted 128 lines
-----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 hypervisorHyper-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(-)arch/x86/include/uapi/asm/hyperv.h +8
-0@@ -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 */
arch/x86/include/uapi/asm/hyperv.h +11
-0+#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 0x40000071arch/x86/kernel/cpu/mshyperv.c +24
-1@@ -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 ); } --
Quoted 1 line
1.7.4.1
Peter,
Let me know if you want me to address any additional issues in this patch.
Regards,
K. Y
H. Peter Anvin
reviewerQuoted 5 lines · KY Srinivasan
Peter,
Let me know if you want me to address any additional issues in this patch.
Please address Jan and Gleb's feedback.
-hpa
Quoted 12 lines
-----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
Quoted 8 lines
Quoted 5 lines · KY Srinivasan
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
Quoted 20 lines
Quoted 20 lines
Quoted 1 line · KY Srinivasan
-----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 hypervisorQuoted 5 lines · KY Srinivasan
Peter,
Let me know if you want me to address any additional issues in this patch.
Quoted 6 lines
Quoted 1 line
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
Quoted 41 lines
-----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 hypervisorQuoted 8 lines
Quoted 8 lines
Quoted 1 line · KY Srinivasan
-----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-Quoted 2 lines
Quoted 10 lines
Quoted 10 lines
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor
Quoted 5 lines · KY Srinivasan
Peter,
Let me know if you want me to address any additional issues in this patch.
Quoted 6 lines
Quoted 1 line
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.
Quoted 5 lines
Indeed, apart from the question whether to change that one message's level from
KERN_INFOtoKERN_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
Quoted 16 lines · KY Srinivasan
Quoted 16 lines
-----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 hypervisorQuoted 3 lines · KY Srinivasan
Peter,
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
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.
Quoted 37 lines
-----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 hypervisorQuoted 7 lines · KY Srinivasan
Quoted 7 lines
-----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-Quoted 2 lines
Quoted 12 lines
Quoted 11 lines
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor
Quoted 5 lines · KY Srinivasan
Peter,
Let me know if you want me to address any additional issues in this patch.
Please address Jan and Gleb's feedback.
Quoted 7 lines
Quoted 1 line
Gleb's feedback was a question and I answered that as I did Jan's feedback as
well.
Quoted 1 line
Gleb, Jan, please let me know if there is something else you want addressed
here.
Quoted 1 line
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
Quoted 3 lines
--
Gleb.
Quoted 42 lines · KY Srinivasan
Quoted 42 lines
-----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 hypervisorQuoted 7 lines · KY Srinivasan
Quoted 7 lines
-----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-Quoted 2 lines
Quoted 5 lines
Quoted 5 lines
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor
Quoted 1 line · KY Srinivasan
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
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.
Quoted 1 line
Gleb, Jan, please let me know if there is something else you want addressed
here.
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
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=39289This 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.
Quoted 66 lines
-----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 hypervisorQuoted 21 lines · KY Srinivasan
Quoted 21 lines
-----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 hypervisorQuoted 7 lines · KY Srinivasan
Quoted 7 lines
-----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-Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
Quoted 1 line
Quoted 1 line
Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer
frequency
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
from the hypervisor
Quoted 4 lines · KY Srinivasan
Peter,
Let me know if you want me to address any additional issues in this
patch.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Please address Jan and Gleb's feedback.
Gleb's feedback was a question and I answered that as I did Jan's feedback
as
Quoted 2 lines
Quoted 2 lines
well.
Quoted 1 line
Gleb, Jan, please let me know if there is something else you want
addressed
Quoted 8 lines
Quoted 4 lines
here.
Quoted 1 line
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
Quoted 6 lines
Quoted 2 lines
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_FREQUENCYspecifically. 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
Quoted 3 lines
--
Gleb.
Quoted 5 lines · KY Srinivasan
Quoted 5 lines
Quoted 5 lines
Thanks Gleb. Here is the link for the latest Hyper-V specification:
http://www.microsoft.com/en-us/download/details.aspx?id=39289This spec talks about how migration is handled with regards to TSC.
Quoted 9 lines
Quoted 4 lines
All I can see is "15.4.3 Partition Reference TSC Mechanism". I see nothing about
HV_X64_MSR_TSC_FREQUENCYspecifically. 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.
Quoted 24 lines
-----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 hypervisorQuoted 10 lines · KY Srinivasan
Quoted 9 lines
Quoted 5 lines
Thanks Gleb. Here is the link for the latest Hyper-V specification:
http://www.microsoft.com/en-us/download/details.aspx?id=39289This 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_FREQUENCYspecifically. To access this MSR a partition needs AccessFrequencyMsrs privilege, may be partition that cab be migrated does not have this privilege?
Quoted 8 lines
Quoted 1 line
If you use the MSR to read the TSC frequency, then indeed when you migrate
then there
Quoted 1 line
is no guarantee that the TSC frequency won't change when you migrate. The
approach
Quoted 1 line
described in section 15.4.3 is the preferred approach that can accommodate
migration.
Quoted 1 line
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
H. Peter Anvin
reviewerQuoted 5 lines · KY Srinivasan
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
Quoted 17 lines
-----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 hypervisorQuoted 3 lines · KY Srinivasan
Peter,
Please let me know if there are other issues I need to address here. Now that
Quoted 7 lines
Dmitry has queued up the
Quoted 1 line
Hyper-V keyboard driver, with this patch we can fully support Linux on our uefi
firmware.
Quoted 1 line
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
Quoted 17 lines
-----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 hypervisorQuoted 3 lines · KY Srinivasan
Peter,
Please let me know if there are other issues I need to address here. Now that
Quoted 7 lines
Dmitry has queued up the
Quoted 1 line
Hyper-V keyboard driver, with this patch we can fully support Linux on our uefi
firmware.
Quoted 1 line
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
Quoted 3 lines
-hpa
arch/x86/kernel/cpu/mshyperv.c static void __init ms_hyperv_init_platform(void) · line 88
Quoted 10 lines · K. Y. Srinivasan
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.
arch/x86/kernel/cpu/mshyperv.c +6
-0+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
Quoted 30 lines
-----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 hypervisorQuoted 1 line · K. Y. Srinivasan
Hyper-V supports a mechanism for retrieving the local APIC frequency.Use this
and bypass
Quoted 1 line
the calibration code in the kernel. This would allow us to boot the Linux kernel
as a
Quoted 1 line
"modern VM" on Hyper-V where many of the legacy devices (such as PIT) are
not emulated.
arch/x86/kernel/cpu/mshyperv.c static void __init ms_hyperv_init_platform(void) · line 88
Quoted 6 lines
arch/x86/kernel/cpu/mshyperv.c +6
-0+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:
Quoted 4 lines
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
Quoted 3 lines
Olaf
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�
Quoted 8 lines · KY Srinivasan
Quoted 6 lines
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
Quoted 21 lines
-----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 hypervisorQuoted 7 lines · KY Srinivasan
Quoted 6 lines
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.
Quoted 7 lines
Quoted 1 line
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�
H. Peter Anvin
reviewerQuoted 3 lines · KY Srinivasan
Thanks Olaf. Could you submit the patch.
Haven't heard anything from Olaf... could you fold in the fix and resumbit?
-hpa
Quoted 12 lines
-----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
Quoted 6 lines
Quoted 3 lines · KY Srinivasan
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
Quoted 3 lines
-hpa
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�