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

2013-10-09 Thread KY Srinivasan


> -Original Message-
> From: H. Peter Anvin [mailto:h...@zytor.com]
> Sent: Wednesday, October 09, 2013 3:50 PM
> To: KY Srinivasan
> Cc: Olaf Hering; x...@kernel.org; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; a...@canonical.com;
> jasow...@redhat.com; t...@linutronix.de; jbeul...@suse.com; b...@alien8.de
> 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
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-10-09 Thread H. Peter Anvin
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


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-10-02 Thread KY Srinivasan


> -Original Message-
> From: H. Peter Anvin [mailto:h...@zytor.com]
> Sent: Monday, September 23, 2013 8:50 AM
> To: KY Srinivasan
> Cc: Gleb Natapov; x...@kernel.org; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> a...@canonical.com; jasow...@redhat.com; t...@linutronix.de;
> jbeul...@suse.com; b...@alien8.de; dmitry.torok...@gmail.com
> 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
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-27 Thread KY Srinivasan


> -Original Message-
> From: Olaf Hering [mailto:o...@aepfle.de]
> Sent: Friday, September 27, 2013 8:10 AM
> To: KY Srinivasan
> Cc: x...@kernel.org; gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; a...@canonical.com; jasow...@redhat.com;
> t...@linutronix.de; h...@zytor.com; jbeul...@suse.com; b...@alien8.de
> 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
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-27 Thread KY Srinivasan


> -Original Message-
> From: Olaf Hering [mailto:o...@aepfle.de]
> Sent: Friday, September 27, 2013 8:33 AM
> To: KY Srinivasan
> Cc: x...@kernel.org; gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; a...@canonical.com; jasow...@redhat.com;
> t...@linutronix.de; h...@zytor.com; jbeul...@suse.com; b...@alien8.de
> 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
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-27 Thread Olaf Hering
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
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-27 Thread Olaf Hering
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
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-23 Thread KY Srinivasan


> -Original Message-
> From: H. Peter Anvin [mailto:h...@zytor.com]
> Sent: Monday, September 23, 2013 8:50 AM
> To: KY Srinivasan
> Cc: Gleb Natapov; x...@kernel.org; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> a...@canonical.com; jasow...@redhat.com; t...@linutronix.de;
> jbeul...@suse.com; b...@alien8.de; dmitry.torok...@gmail.com
> 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

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-23 Thread H. Peter Anvin
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


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-23 Thread KY Srinivasan


> -Original Message-
> From: Gleb Natapov [mailto:g...@redhat.com]
> Sent: Tuesday, September 17, 2013 10:44 PM
> To: KY Srinivasan
> Cc: H. Peter Anvin; x...@kernel.org; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> a...@canonical.com; jasow...@redhat.com; t...@linutronix.de;
> jbeul...@suse.com; b...@alien8.de
> 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 +, 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 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-17 Thread Gleb Natapov
On Tue, Sep 17, 2013 at 07:53:36PM +, 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.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-17 Thread KY Srinivasan


> -Original Message-
> From: Gleb Natapov [mailto:g...@redhat.com]
> Sent: Tuesday, September 17, 2013 6:59 AM
> To: KY Srinivasan
> Cc: H. Peter Anvin; x...@kernel.org; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> a...@canonical.com; jasow...@redhat.com; t...@linutronix.de;
> jbeul...@suse.com; b...@alien8.de
> 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 +, KY Srinivasan wrote:
> >
> >
> > > -Original Message-
> > > From: Gleb Natapov [mailto:g...@redhat.com]
> > > Sent: Friday, September 13, 2013 2:55 AM
> > > To: KY Srinivasan
> > > Cc: H. Peter Anvin; x...@kernel.org; gre...@linuxfoundation.org; linux-
> > > ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> > > a...@canonical.com; jasow...@redhat.com; t...@linutronix.de;
> > > jbeul...@suse.com; b...@alien8.de
> > > 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 +, KY Srinivasan wrote:
> > > >
> > > >
> > > > > -Original Message-
> > > > > From: H. Peter Anvin [mailto:h...@zytor.com]
> > > > > Sent: Thursday, September 12, 2013 5:28 PM
> > > > > To: KY Srinivasan
> > > > > Cc: x...@kernel.org; gre...@linuxfoundation.org; linux-
> > > ker...@vger.kernel.org;
> > > > > de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> > > > > jasow...@redhat.com; t...@linutronix.de; jbeul...@suse.com;
> > > b...@alien8.de
> > > > > 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.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-17 Thread Gleb Natapov
On Fri, Sep 13, 2013 at 02:28:35PM +, KY Srinivasan wrote:
> 
> 
> > -Original Message-
> > From: Gleb Natapov [mailto:g...@redhat.com]
> > Sent: Friday, September 13, 2013 2:55 AM
> > To: KY Srinivasan
> > Cc: H. Peter Anvin; x...@kernel.org; gre...@linuxfoundation.org; linux-
> > ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> > a...@canonical.com; jasow...@redhat.com; t...@linutronix.de;
> > jbeul...@suse.com; b...@alien8.de
> > 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 +, KY Srinivasan wrote:
> > >
> > >
> > > > -Original Message-
> > > > From: H. Peter Anvin [mailto:h...@zytor.com]
> > > > Sent: Thursday, September 12, 2013 5:28 PM
> > > > To: KY Srinivasan
> > > > Cc: x...@kernel.org; gre...@linuxfoundation.org; linux-
> > ker...@vger.kernel.org;
> > > > de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> > > > jasow...@redhat.com; t...@linutronix.de; jbeul...@suse.com;
> > b...@alien8.de
> > > > 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.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-13 Thread KY Srinivasan


> -Original Message-
> From: Jan Beulich [mailto:jbeul...@suse.com]
> Sent: Thursday, September 12, 2013 11:39 PM
> To: KY Srinivasan; H. Peter Anvin
> Cc: o...@aepfle.de; b...@alien8.de; a...@canonical.com; x...@kernel.org;
> t...@linutronix.de; de...@linuxdriverproject.org; gre...@linuxfoundation.org;
> jasow...@redhat.com; linux-ker...@vger.kernel.org
> 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  wrote:
> 
> >
> >> -Original Message-
> >> From: H. Peter Anvin [mailto:h...@zytor.com]
> >> Sent: Thursday, September 12, 2013 5:28 PM
> >> To: KY Srinivasan
> >> Cc: x...@kernel.org; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org;
> >> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> >> jasow...@redhat.com; t...@linutronix.de; jbeul...@suse.com;
> b...@alien8.de
> >> 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

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-13 Thread KY Srinivasan


> -Original Message-
> From: Gleb Natapov [mailto:g...@redhat.com]
> Sent: Friday, September 13, 2013 2:55 AM
> To: KY Srinivasan
> Cc: H. Peter Anvin; x...@kernel.org; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org; de...@linuxdriverproject.org; o...@aepfle.de;
> a...@canonical.com; jasow...@redhat.com; t...@linutronix.de;
> jbeul...@suse.com; b...@alien8.de
> 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 +, KY Srinivasan wrote:
> >
> >
> > > -Original Message-
> > > From: H. Peter Anvin [mailto:h...@zytor.com]
> > > Sent: Thursday, September 12, 2013 5:28 PM
> > > To: KY Srinivasan
> > > Cc: x...@kernel.org; gre...@linuxfoundation.org; linux-
> ker...@vger.kernel.org;
> > > de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> > > jasow...@redhat.com; t...@linutronix.de; jbeul...@suse.com;
> b...@alien8.de
> > > 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.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-13 Thread Gleb Natapov
On Fri, Sep 13, 2013 at 01:43:09AM +, KY Srinivasan wrote:
> 
> 
> > -Original Message-
> > From: H. Peter Anvin [mailto:h...@zytor.com]
> > Sent: Thursday, September 12, 2013 5:28 PM
> > To: KY Srinivasan
> > Cc: x...@kernel.org; gre...@linuxfoundation.org; 
> > linux-ker...@vger.kernel.org;
> > de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> > jasow...@redhat.com; t...@linutronix.de; jbeul...@suse.com; b...@alien8.de
> > 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.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-12 Thread Jan Beulich
>>> On 13.09.13 at 03:43, KY Srinivasan  wrote:

> 
>> -Original Message-
>> From: H. Peter Anvin [mailto:h...@zytor.com]
>> Sent: Thursday, September 12, 2013 5:28 PM
>> To: KY Srinivasan
>> Cc: x...@kernel.org; gre...@linuxfoundation.org; 
>> linux-ker...@vger.kernel.org;
>> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
>> jasow...@redhat.com; t...@linutronix.de; jbeul...@suse.com; b...@alien8.de 
>> 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

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-12 Thread KY Srinivasan


> -Original Message-
> From: H. Peter Anvin [mailto:h...@zytor.com]
> Sent: Thursday, September 12, 2013 5:28 PM
> To: KY Srinivasan
> Cc: x...@kernel.org; gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> jasow...@redhat.com; t...@linutronix.de; jbeul...@suse.com; b...@alien8.de
> 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

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-12 Thread KY Srinivasan


> -Original Message-
> From: K. Y. Srinivasan [mailto:k...@microsoft.com]
> Sent: Tuesday, September 03, 2013 11:30 AM
> To: x...@kernel.org; gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> jasow...@redhat.com; t...@linutronix.de; h...@zytor.com;
> jbeul...@suse.com; b...@alien8.de
> 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 , 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_COUNT0x4020
> 
> +/* MSR used to retrieve the TSC frequency */
> +#define HV_X64_MSR_TSC_FREQUENCY 0x4022
> +
> +/* MSR used to retrieve the local APIC timer frequency */
> +#define HV_X64_MSR_APIC_FREQUENCY0x4023
> +
>  /* Define the virtual APIC registers */
>  #define HV_X64_MSR_EOI   0x4070
>  #define HV_X64_MSR_ICR   0x4071
> 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

Peter,

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


Regards,

K. Y
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-12 Thread H. Peter Anvin
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


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-05 Thread Gleb Natapov
On Wed, Sep 04, 2013 at 03:16:30PM +, KY Srinivasan wrote:
> 
> 
> > -Original Message-
> > From: Gleb Natapov [mailto:g...@redhat.com]
> > Sent: Wednesday, September 04, 2013 2:40 AM
> > To: KY Srinivasan
> > Cc: x...@kernel.org; gre...@linuxfoundation.org; 
> > linux-ker...@vger.kernel.org;
> > de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> > jasow...@redhat.com; t...@linutronix.de; h...@zytor.com;
> > jbeul...@suse.com; b...@alien8.de
> > 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 , 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_COUNT0x4020
> > >
> > > +/* MSR used to retrieve the TSC frequency */
> > > +#define HV_X64_MSR_TSC_FREQUENCY 0x4022
> > > +
> > 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.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-04 Thread KY Srinivasan


> -Original Message-
> From: Gleb Natapov [mailto:g...@redhat.com]
> Sent: Wednesday, September 04, 2013 2:40 AM
> To: KY Srinivasan
> Cc: x...@kernel.org; gre...@linuxfoundation.org; linux-ker...@vger.kernel.org;
> de...@linuxdriverproject.org; o...@aepfle.de; a...@canonical.com;
> jasow...@redhat.com; t...@linutronix.de; h...@zytor.com;
> jbeul...@suse.com; b...@alien8.de
> 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 , 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  0x4020
> >
> > +/* MSR used to retrieve the TSC frequency */
> > +#define HV_X64_MSR_TSC_FREQUENCY   0x4022
> > +
> 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
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-04 Thread KY Srinivasan


> -Original Message-
> From: Jan Beulich [mailto:jbeul...@suse.com]
> Sent: Wednesday, September 04, 2013 12:17 AM
> To: KY Srinivasan
> Cc: o...@aepfle.de; b...@alien8.de; a...@canonical.com; x...@kernel.org;
> t...@linutronix.de; de...@linuxdriverproject.org; gre...@linuxfoundation.org;
> jasow...@redhat.com; linux-ker...@vger.kernel.org; h...@zytor.com
> 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"  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

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-04 Thread Gleb Natapov
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_COUNT0x4020
>  
> +/* MSR used to retrieve the TSC frequency */
> +#define HV_X64_MSR_TSC_FREQUENCY 0x4022
> +
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_FREQUENCY0x4023
> +
>  /* Define the virtual APIC registers */
>  #define HV_X64_MSR_EOI   0x4070
>  #define HV_X64_MSR_ICR   0x4071
> 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 majord...@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.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-04 Thread Jan Beulich
>>> On 03.09.13 at 20:30, "K. Y. Srinivasan"  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

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


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

2013-09-03 Thread 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 , 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  0x4020
 
+/* MSR used to retrieve the TSC frequency */
+#define HV_X64_MSR_TSC_FREQUENCY   0x4022
+
+/* MSR used to retrieve the local APIC timer frequency */
+#define HV_X64_MSR_APIC_FREQUENCY  0x4023
+
 /* Define the virtual APIC registers */
 #define HV_X64_MSR_EOI 0x4070
 #define HV_X64_MSR_ICR 0x4071
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

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel