* [tip:x86/hyperv] x86, hyperv: Get the local APIC timer frequency from the hypervisor
[not found] <1380554932-9888-1-git-send-email-olaf@aepfle.de>
@ 2013-10-10 19:00 ` tip-bot for K. Y. Srinivasan
2013-10-11 23:07 ` [patch x86/hyperv] x86, hyperv: Fix build error David Rientjes
0 siblings, 1 reply; 7+ messages in thread
From: tip-bot for K. Y. Srinivasan @ 2013-10-10 19:00 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, olaf, kys, tglx, hpa
Commit-ID: 9e7827b5ea4ca93b4d864bc07c0fafb838d496b1
Gitweb: http://git.kernel.org/tip/9e7827b5ea4ca93b4d864bc07c0fafb838d496b1
Author: K. Y. Srinivasan <kys@microsoft.com>
AuthorDate: Mon, 30 Sep 2013 17:28:52 +0200
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Thu, 10 Oct 2013 11:44:12 -0700
x86, hyperv: 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 <olaf@aepfle.de>, Jan Beulich <JBeulich@suse.com> and
H. Peter Anvin <h.peter.anvin@intel.com> for their help in this effort.
In this version of the patch, I have addressed Jan's comments.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Link: http://lkml.kernel.org/r/1380554932-9888-1-git-send-email-olaf@aepfle.de
Tested-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
arch/x86/kernel/cpu/mshyperv.c | 24 ++++++++++++++++++++++++
2 files changed, 43 insertions(+)
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..0a490ca 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 = div_u64(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);
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [patch x86/hyperv] x86, hyperv: Fix build error
2013-10-10 19:00 ` [tip:x86/hyperv] x86, hyperv: Get the local APIC timer frequency from the hypervisor tip-bot for K. Y. Srinivasan
@ 2013-10-11 23:07 ` David Rientjes
2013-10-11 23:16 ` KY Srinivasan
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: David Rientjes @ 2013-10-11 23:07 UTC (permalink / raw)
To: Ingo Molnar, H. Peter Anvin, tglx, H. Peter Anvin
Cc: K. Y. Srinivasan, Olaf Hering, linux-kernel, linux-tip-commits
9e7827b5ea4c ("x86, hyperv: Get the local APIC timer frequency from the
hypervisor") breaks the build with some configs because apic.h isn't
directly included:
arch/x86/kernel/cpu/mshyperv.c: In function 'ms_hyperv_init_platform':
arch/x86/kernel/cpu/mshyperv.c:90:3: error: 'lapic_timer_frequency' undeclared (first use in this function)
arch/x86/kernel/cpu/mshyperv.c:90:3: note: each undeclared identifier is reported only once for each function it appears in
Fix it by including asm/apic.h.
Signed-off-by: David Rientjes <rientjes@google.com>
---
arch/x86/kernel/cpu/mshyperv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -25,6 +25,7 @@
#include <asm/idle.h>
#include <asm/irq_regs.h>
#include <asm/i8259.h>
+#include <asm/apic.h>
struct ms_hyperv_info ms_hyperv;
EXPORT_SYMBOL_GPL(ms_hyperv);
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [patch x86/hyperv] x86, hyperv: Fix build error
2013-10-11 23:07 ` [patch x86/hyperv] x86, hyperv: Fix build error David Rientjes
@ 2013-10-11 23:16 ` KY Srinivasan
2013-10-11 23:28 ` David Rientjes
2013-10-30 22:19 ` [patch x86/hyperv resend] " David Rientjes
2013-10-30 22:54 ` [tip:x86/hyperv] x86, hyperv: Fix build error due to missing <asm /apic.h> include tip-bot for David Rientjes
2 siblings, 1 reply; 7+ messages in thread
From: KY Srinivasan @ 2013-10-11 23:16 UTC (permalink / raw)
To: David Rientjes, Ingo Molnar, H. Peter Anvin, tglx, H. Peter Anvin
Cc: Olaf Hering, linux-kernel, linux-tip-commits
> -----Original Message-----
> From: David Rientjes [mailto:rientjes@google.com]
> Sent: Friday, October 11, 2013 4:08 PM
> To: Ingo Molnar; H. Peter Anvin; tglx@linutronix.de; H. Peter Anvin
> Cc: KY Srinivasan; Olaf Hering; linux-kernel@vger.kernel.org; linux-tip-
> commits@vger.kernel.org
> Subject: [patch x86/hyperv] x86, hyperv: Fix build error
>
> 9e7827b5ea4c ("x86, hyperv: Get the local APIC timer frequency from the
> hypervisor") breaks the build with some configs because apic.h isn't
> directly included:
>
> arch/x86/kernel/cpu/mshyperv.c: In function 'ms_hyperv_init_platform':
> arch/x86/kernel/cpu/mshyperv.c:90:3: error: 'lapic_timer_frequency' undeclared
> (first use in this function)
> arch/x86/kernel/cpu/mshyperv.c:90:3: note: each undeclared identifier is
> reported only once for each function it appears in
>
> Fix it by including asm/apic.h.
Thank you. The issue was configuration related - local APIC was not configured. This has already been fixed.
Regards.
K. Y
>
> Signed-off-by: David Rientjes <rientjes@google.com>
> ---
> arch/x86/kernel/cpu/mshyperv.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
> --- a/arch/x86/kernel/cpu/mshyperv.c
> +++ b/arch/x86/kernel/cpu/mshyperv.c
> @@ -25,6 +25,7 @@
> #include <asm/idle.h>
> #include <asm/irq_regs.h>
> #include <asm/i8259.h>
> +#include <asm/apic.h>
>
> struct ms_hyperv_info ms_hyperv;
> EXPORT_SYMBOL_GPL(ms_hyperv);
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [patch x86/hyperv] x86, hyperv: Fix build error
2013-10-11 23:16 ` KY Srinivasan
@ 2013-10-11 23:28 ` David Rientjes
2013-10-11 23:31 ` KY Srinivasan
0 siblings, 1 reply; 7+ messages in thread
From: David Rientjes @ 2013-10-11 23:28 UTC (permalink / raw)
To: KY Srinivasan
Cc: Ingo Molnar, H. Peter Anvin, tglx, H. Peter Anvin, Olaf Hering,
linux-kernel, linux-tip-commits
On Fri, 11 Oct 2013, KY Srinivasan wrote:
> > From: David Rientjes [mailto:rientjes@google.com]
> > Sent: Friday, October 11, 2013 4:08 PM
> > To: Ingo Molnar; H. Peter Anvin; tglx@linutronix.de; H. Peter Anvin
> > Cc: KY Srinivasan; Olaf Hering; linux-kernel@vger.kernel.org; linux-tip-
> > commits@vger.kernel.org
> > Subject: [patch x86/hyperv] x86, hyperv: Fix build error
> >
> > 9e7827b5ea4c ("x86, hyperv: Get the local APIC timer frequency from the
> > hypervisor") breaks the build with some configs because apic.h isn't
> > directly included:
> >
> > arch/x86/kernel/cpu/mshyperv.c: In function 'ms_hyperv_init_platform':
> > arch/x86/kernel/cpu/mshyperv.c:90:3: error: 'lapic_timer_frequency' undeclared
> > (first use in this function)
> > arch/x86/kernel/cpu/mshyperv.c:90:3: note: each undeclared identifier is
> > reported only once for each function it appears in
> >
> > Fix it by including asm/apic.h.
>
> Thank you. The issue was configuration related - local APIC was not configured. This has already been fixed.
>
Yeah, it's config related as stated in the changelog. If you're referring
to 90ab9d551093 ("x86, hyperv: Correctly guard the local APIC calibration
code ")as "fixing" it, it does not. (I'm left to wonder what you mean by
it being fixed since you didn't elaborate.) You can trigger this build
breakage even with CONFIG_X86_LOCAL_APIC=y.
Let me be explicit: this file includes desc.h, which includes linux/smp.h,
which includes asm/smp.h iff CONFIG_SMP is enabled. That's what you're
relying upon to get asm/apic.h when CONFIG_X86_LOCAL_APIC is enabled. It
will break when CONFIG_SMP is disabled.
So you need to include asm/apic.h directly for such a configuration.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [patch x86/hyperv] x86, hyperv: Fix build error
2013-10-11 23:28 ` David Rientjes
@ 2013-10-11 23:31 ` KY Srinivasan
0 siblings, 0 replies; 7+ messages in thread
From: KY Srinivasan @ 2013-10-11 23:31 UTC (permalink / raw)
To: David Rientjes
Cc: Ingo Molnar, H. Peter Anvin, tglx, H. Peter Anvin, Olaf Hering,
linux-kernel, linux-tip-commits
> -----Original Message-----
> From: David Rientjes [mailto:rientjes@google.com]
> Sent: Friday, October 11, 2013 4:29 PM
> To: KY Srinivasan
> Cc: Ingo Molnar; H. Peter Anvin; tglx@linutronix.de; H. Peter Anvin; Olaf Hering;
> linux-kernel@vger.kernel.org; linux-tip-commits@vger.kernel.org
> Subject: RE: [patch x86/hyperv] x86, hyperv: Fix build error
>
> On Fri, 11 Oct 2013, KY Srinivasan wrote:
>
> > > From: David Rientjes [mailto:rientjes@google.com]
> > > Sent: Friday, October 11, 2013 4:08 PM
> > > To: Ingo Molnar; H. Peter Anvin; tglx@linutronix.de; H. Peter Anvin
> > > Cc: KY Srinivasan; Olaf Hering; linux-kernel@vger.kernel.org; linux-tip-
> > > commits@vger.kernel.org
> > > Subject: [patch x86/hyperv] x86, hyperv: Fix build error
> > >
> > > 9e7827b5ea4c ("x86, hyperv: Get the local APIC timer frequency from the
> > > hypervisor") breaks the build with some configs because apic.h isn't
> > > directly included:
> > >
> > > arch/x86/kernel/cpu/mshyperv.c: In function 'ms_hyperv_init_platform':
> > > arch/x86/kernel/cpu/mshyperv.c:90:3: error: 'lapic_timer_frequency'
> undeclared
> > > (first use in this function)
> > > arch/x86/kernel/cpu/mshyperv.c:90:3: note: each undeclared identifier is
> > > reported only once for each function it appears in
> > >
> > > Fix it by including asm/apic.h.
> >
> > Thank you. The issue was configuration related - local APIC was not configured.
> This has already been fixed.
> >
>
> Yeah, it's config related as stated in the changelog. If you're referring
> to 90ab9d551093 ("x86, hyperv: Correctly guard the local APIC calibration
> code ")as "fixing" it, it does not. (I'm left to wonder what you mean by
> it being fixed since you didn't elaborate.) You can trigger this build
> breakage even with CONFIG_X86_LOCAL_APIC=y.
>
> Let me be explicit: this file includes desc.h, which includes linux/smp.h,
> which includes asm/smp.h iff CONFIG_SMP is enabled. That's what you're
> relying upon to get asm/apic.h when CONFIG_X86_LOCAL_APIC is enabled. It
> will break when CONFIG_SMP is disabled.
>
> So you need to include asm/apic.h directly for such a configuration.
Thank you for the details.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Regards,
K. Y
^ permalink raw reply [flat|nested] 7+ messages in thread
* [patch x86/hyperv resend] x86, hyperv: Fix build error
2013-10-11 23:07 ` [patch x86/hyperv] x86, hyperv: Fix build error David Rientjes
2013-10-11 23:16 ` KY Srinivasan
@ 2013-10-30 22:19 ` David Rientjes
2013-10-30 22:54 ` [tip:x86/hyperv] x86, hyperv: Fix build error due to missing <asm /apic.h> include tip-bot for David Rientjes
2 siblings, 0 replies; 7+ messages in thread
From: David Rientjes @ 2013-10-30 22:19 UTC (permalink / raw)
To: Ingo Molnar, H. Peter Anvin, tglx, H. Peter Anvin
Cc: K. Y. Srinivasan, Olaf Hering, linux-kernel, linux-tip-commits
9e7827b5ea4c ("x86, hyperv: Get the local APIC timer frequency from the
hypervisor") breaks the build when CONFIG_SMP is disabled because apic.h
isn't directly included:
arch/x86/kernel/cpu/mshyperv.c: In function 'ms_hyperv_init_platform':
arch/x86/kernel/cpu/mshyperv.c:90:3: error: 'lapic_timer_frequency' undeclared (first use in this function)
arch/x86/kernel/cpu/mshyperv.c:90:3: note: each undeclared identifier is reported only once for each function it appears in
This happens because mshyperv.c includes linux/desc.h, which includes
linux/smp.h, which includes asm/smp.h iff CONFIG_SMP is enabled, and
asm/smp.h is what includes asm/apic.h for CONFIG_X86_LOCAL_APIC.
Fix it by directly including asm/apic.h.
Acked-by: "K. Y. Srinivasan" <kys@microsoft.com>
Signed-off-by: David Rientjes <rientjes@google.com>
---
arch/x86/kernel/cpu/mshyperv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -25,6 +25,7 @@
#include <asm/idle.h>
#include <asm/irq_regs.h>
#include <asm/i8259.h>
+#include <asm/apic.h>
struct ms_hyperv_info ms_hyperv;
EXPORT_SYMBOL_GPL(ms_hyperv);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:x86/hyperv] x86, hyperv: Fix build error due to missing <asm /apic.h> include
2013-10-11 23:07 ` [patch x86/hyperv] x86, hyperv: Fix build error David Rientjes
2013-10-11 23:16 ` KY Srinivasan
2013-10-30 22:19 ` [patch x86/hyperv resend] " David Rientjes
@ 2013-10-30 22:54 ` tip-bot for David Rientjes
2 siblings, 0 replies; 7+ messages in thread
From: tip-bot for David Rientjes @ 2013-10-30 22:54 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, kys, tglx, hpa, rientjes
Commit-ID: d68ce0177c1e51fb332369e0c99852a6d05668af
Gitweb: http://git.kernel.org/tip/d68ce0177c1e51fb332369e0c99852a6d05668af
Author: David Rientjes <rientjes@google.com>
AuthorDate: Fri, 11 Oct 2013 16:07:31 -0700
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Wed, 30 Oct 2013 15:37:47 -0700
x86, hyperv: Fix build error due to missing <asm/apic.h> include
9e7827b5ea4c ("x86, hyperv: Get the local APIC timer frequency from the
hypervisor") breaks the build with some configs because apic.h isn't
directly included:
arch/x86/kernel/cpu/mshyperv.c: In function 'ms_hyperv_init_platform':
arch/x86/kernel/cpu/mshyperv.c:90:3: error: 'lapic_timer_frequency' undeclared (first use in this function)
arch/x86/kernel/cpu/mshyperv.c:90:3: note: each undeclared identifier is reported only once for each function it appears in
Fix it by including asm/apic.h.
Signed-off-by: David Rientjes <rientjes@google.com>
Link: http://lkml.kernel.org/r/alpine.DEB.2.02.1310111604160.31170@chino.kir.corp.google.com
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/kernel/cpu/mshyperv.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 628ff50..9f6e9f8 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -25,6 +25,7 @@
#include <asm/idle.h>
#include <asm/irq_regs.h>
#include <asm/i8259.h>
+#include <asm/apic.h>
struct ms_hyperv_info ms_hyperv;
EXPORT_SYMBOL_GPL(ms_hyperv);
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-10-30 22:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <1380554932-9888-1-git-send-email-olaf@aepfle.de>
2013-10-10 19:00 ` [tip:x86/hyperv] x86, hyperv: Get the local APIC timer frequency from the hypervisor tip-bot for K. Y. Srinivasan
2013-10-11 23:07 ` [patch x86/hyperv] x86, hyperv: Fix build error David Rientjes
2013-10-11 23:16 ` KY Srinivasan
2013-10-11 23:28 ` David Rientjes
2013-10-11 23:31 ` KY Srinivasan
2013-10-30 22:19 ` [patch x86/hyperv resend] " David Rientjes
2013-10-30 22:54 ` [tip:x86/hyperv] x86, hyperv: Fix build error due to missing <asm /apic.h> include tip-bot for David Rientjes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome