Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934672Ab3IDJlN (ORCPT ); Wed, 4 Sep 2013 05:41:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26118 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934563Ab3IDJkw (ORCPT ); Wed, 4 Sep 2013 05:40:52 -0400 Date: Wed, 4 Sep 2013 12:40:14 +0300 From: Gleb Natapov To: "K. Y. Srinivasan" Cc: x86@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, jasowang@redhat.com, tglx@linutronix.de, hpa@zytor.com, JBeulich@suse.com, bp@alien8.de Subject: Re: [PATCH V2 1/1] X86: Hyper-V: Get the local APIC timer frequency from the hypervisor Message-ID: <20130904094014.GB7402@redhat.com> References: <1378233023-4512-1-git-send-email-kys@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1378233023-4512-1-git-send-email-kys@microsoft.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4771 Lines: 128 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 , Jan Beulich and > H. Peter Anvin for their help in this effort. > > In this version of the patch, I have addressed Jan's comments. > > Signed-off-by: K. Y. Srinivasan > --- > 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 > #include > #include > +#include > #include > #include > #include > @@ -23,6 +24,7 @@ > #include > #include > #include > +#include > > 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 majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- Gleb. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/