grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
@ 2014-11-26  8:59 Laszlo Ersek
  2014-11-26 13:42 ` Andrei Borzenkov
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Laszlo Ersek @ 2014-11-26  8:59 UTC (permalink / raw)
  To: grub-devel, vkuznets, decui, pjones, lersek

HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
services instead.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1150698
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1160128
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
    Please note that I'm not subscribed to the list.

 grub-core/kern/i386/tsc.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
index 3a4cae6..e499648 100644
--- a/grub-core/kern/i386/tsc.c
+++ b/grub-core/kern/i386/tsc.c
@@ -26,9 +26,14 @@
 #include <grub/i386/tsc.h>
 #include <grub/i386/cpuid.h>
 #ifdef GRUB_MACHINE_XEN
-#include <grub/xen.h>
+# include <grub/xen.h>
 #else
-#include <grub/i386/pit.h>
+# ifdef GRUB_MACHINE_EFI
+#  include <grub/efi/efi.h>
+#  include <grub/efi/api.h>
+# else
+#  include <grub/i386/pit.h>
+# endif
 #endif
 #include <grub/cpu/io.h>
 
@@ -72,8 +77,14 @@ grub_cpu_is_tsc_supported (void)
 #ifndef GRUB_MACHINE_XEN
 
 static void
-grub_pit_wait (grub_uint16_t tics)
+grub_stall (grub_uint16_t tics)
 {
+# ifdef GRUB_MACHINE_EFI
+  grub_uint64_t microseconds;
+
+  microseconds = (grub_uint64_t)tics * 1000 * 1000 * 3 / 3579545;
+  efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
+# else
   /* Disable timer2 gate and speaker.  */
   grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
 	     & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
@@ -97,6 +108,7 @@ grub_pit_wait (grub_uint16_t tics)
   grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
 	     & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
              GRUB_PIT_SPEAKER_PORT);
+# endif
 }
 #endif
 
@@ -119,7 +131,7 @@ calibrate_tsc (void)
   grub_uint64_t end_tsc;
 
   tsc_boot_time = grub_get_tsc ();
-  grub_pit_wait (0xffff);
+  grub_stall (0xffff);
   end_tsc = grub_get_tsc ();
 
   grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
-- 
1.8.3.1



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2014-11-26  8:59 [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI Laszlo Ersek
@ 2014-11-26 13:42 ` Andrei Borzenkov
  2014-11-26 13:49   ` Laszlo Ersek
  2014-11-28 19:25 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2015-11-27 17:55 ` Andrei Borzenkov
  2 siblings, 1 reply; 16+ messages in thread
From: Andrei Borzenkov @ 2014-11-26 13:42 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: lersek, vkuznets, decui

On Wed, Nov 26, 2014 at 11:59 AM, Laszlo Ersek <lersek@redhat.com> wrote:
> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
> services instead.
>

Your patch affects all EFI systems; is it possible to detect HyperV at
this level?

> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1150698
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1160128
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> ---
>
> Notes:
>     Please note that I'm not subscribed to the list.
>
>  grub-core/kern/i386/tsc.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
> index 3a4cae6..e499648 100644
> --- a/grub-core/kern/i386/tsc.c
> +++ b/grub-core/kern/i386/tsc.c
> @@ -26,9 +26,14 @@
>  #include <grub/i386/tsc.h>
>  #include <grub/i386/cpuid.h>
>  #ifdef GRUB_MACHINE_XEN
> -#include <grub/xen.h>
> +# include <grub/xen.h>
>  #else
> -#include <grub/i386/pit.h>
> +# ifdef GRUB_MACHINE_EFI
> +#  include <grub/efi/efi.h>
> +#  include <grub/efi/api.h>
> +# else
> +#  include <grub/i386/pit.h>
> +# endif
>  #endif
>  #include <grub/cpu/io.h>
>
> @@ -72,8 +77,14 @@ grub_cpu_is_tsc_supported (void)
>  #ifndef GRUB_MACHINE_XEN
>
>  static void
> -grub_pit_wait (grub_uint16_t tics)
> +grub_stall (grub_uint16_t tics)
>  {
> +# ifdef GRUB_MACHINE_EFI
> +  grub_uint64_t microseconds;
> +
> +  microseconds = (grub_uint64_t)tics * 1000 * 1000 * 3 / 3579545;
> +  efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
> +# else
>    /* Disable timer2 gate and speaker.  */
>    grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
>              & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
> @@ -97,6 +108,7 @@ grub_pit_wait (grub_uint16_t tics)
>    grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
>              & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
>               GRUB_PIT_SPEAKER_PORT);
> +# endif
>  }
>  #endif
>
> @@ -119,7 +131,7 @@ calibrate_tsc (void)
>    grub_uint64_t end_tsc;
>
>    tsc_boot_time = grub_get_tsc ();
> -  grub_pit_wait (0xffff);
> +  grub_stall (0xffff);
>    end_tsc = grub_get_tsc ();
>
>    grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
> --
> 1.8.3.1
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2014-11-26 13:42 ` Andrei Borzenkov
@ 2014-11-26 13:49   ` Laszlo Ersek
  0 siblings, 0 replies; 16+ messages in thread
From: Laszlo Ersek @ 2014-11-26 13:49 UTC (permalink / raw)
  To: Andrei Borzenkov, The development of GNU GRUB; +Cc: vkuznets, decui

On 11/26/14 14:42, Andrei Borzenkov wrote:
> On Wed, Nov 26, 2014 at 11:59 AM, Laszlo Ersek <lersek@redhat.com> wrote:
>> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
>> services instead.
>>
> 
> Your patch affects all EFI systems;

Which is intended -- No UEFI system guarantees the presence of the PIT,
but they are all required to provide the gBS->Stall() boot service.

So, the current PIT-based code may or may not work on a random UEFI
system (and in fact it happens to fail in HyperV Gen2 guests, because
those actually exploit the no-legacy liberty provided by the UEFI spec),
but the proposed replacement (== rely on gBS->Stall()) *must* work on
all UEFI systems.

For example, the patch works on top of OVMF in a QEMU/KVM guest too (==
different UEFI firmware implementation and different hypervisor).

> is it possible to detect HyperV at
> this level?

Perhaps, but that should definitely not be done. Enlightenment is not
the way to go about this.

Thanks
Laszlo

>> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1150698
>> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1160128
>> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
>> ---
>>
>> Notes:
>>     Please note that I'm not subscribed to the list.
>>
>>  grub-core/kern/i386/tsc.c | 20 ++++++++++++++++----
>>  1 file changed, 16 insertions(+), 4 deletions(-)
>>
>> diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
>> index 3a4cae6..e499648 100644
>> --- a/grub-core/kern/i386/tsc.c
>> +++ b/grub-core/kern/i386/tsc.c
>> @@ -26,9 +26,14 @@
>>  #include <grub/i386/tsc.h>
>>  #include <grub/i386/cpuid.h>
>>  #ifdef GRUB_MACHINE_XEN
>> -#include <grub/xen.h>
>> +# include <grub/xen.h>
>>  #else
>> -#include <grub/i386/pit.h>
>> +# ifdef GRUB_MACHINE_EFI
>> +#  include <grub/efi/efi.h>
>> +#  include <grub/efi/api.h>
>> +# else
>> +#  include <grub/i386/pit.h>
>> +# endif
>>  #endif
>>  #include <grub/cpu/io.h>
>>
>> @@ -72,8 +77,14 @@ grub_cpu_is_tsc_supported (void)
>>  #ifndef GRUB_MACHINE_XEN
>>
>>  static void
>> -grub_pit_wait (grub_uint16_t tics)
>> +grub_stall (grub_uint16_t tics)
>>  {
>> +# ifdef GRUB_MACHINE_EFI
>> +  grub_uint64_t microseconds;
>> +
>> +  microseconds = (grub_uint64_t)tics * 1000 * 1000 * 3 / 3579545;
>> +  efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
>> +# else
>>    /* Disable timer2 gate and speaker.  */
>>    grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
>>              & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
>> @@ -97,6 +108,7 @@ grub_pit_wait (grub_uint16_t tics)
>>    grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
>>              & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
>>               GRUB_PIT_SPEAKER_PORT);
>> +# endif
>>  }
>>  #endif
>>
>> @@ -119,7 +131,7 @@ calibrate_tsc (void)
>>    grub_uint64_t end_tsc;
>>
>>    tsc_boot_time = grub_get_tsc ();
>> -  grub_pit_wait (0xffff);
>> +  grub_stall (0xffff);
>>    end_tsc = grub_get_tsc ();
>>
>>    grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
>> --
>> 1.8.3.1
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2014-11-26  8:59 [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI Laszlo Ersek
  2014-11-26 13:42 ` Andrei Borzenkov
@ 2014-11-28 19:25 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-12-03 18:59   ` Andrei Borzenkov
  2015-11-27 17:55 ` Andrei Borzenkov
  2 siblings, 1 reply; 16+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-11-28 19:25 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2327 bytes --]

On 26.11.2014 10:59, Laszlo Ersek wrote:
> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
> services instead.
> 
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1150698
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1160128
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>
I don't like to be using any additional EFI function. I prefer to use
pmtimer as I did in my other patch. Is pmtimer available on hyperv?
> ---
> 
> Notes:
>     Please note that I'm not subscribed to the list.
> 
>  grub-core/kern/i386/tsc.c | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
> index 3a4cae6..e499648 100644
> --- a/grub-core/kern/i386/tsc.c
> +++ b/grub-core/kern/i386/tsc.c
> @@ -26,9 +26,14 @@
>  #include <grub/i386/tsc.h>
>  #include <grub/i386/cpuid.h>
>  #ifdef GRUB_MACHINE_XEN
> -#include <grub/xen.h>
> +# include <grub/xen.h>
>  #else
> -#include <grub/i386/pit.h>
> +# ifdef GRUB_MACHINE_EFI
> +#  include <grub/efi/efi.h>
> +#  include <grub/efi/api.h>
> +# else
> +#  include <grub/i386/pit.h>
> +# endif
>  #endif
>  #include <grub/cpu/io.h>
>  
> @@ -72,8 +77,14 @@ grub_cpu_is_tsc_supported (void)
>  #ifndef GRUB_MACHINE_XEN
>  
>  static void
> -grub_pit_wait (grub_uint16_t tics)
> +grub_stall (grub_uint16_t tics)
>  {
> +# ifdef GRUB_MACHINE_EFI
> +  grub_uint64_t microseconds;
> +
> +  microseconds = (grub_uint64_t)tics * 1000 * 1000 * 3 / 3579545;
> +  efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
> +# else
>    /* Disable timer2 gate and speaker.  */
>    grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
>  	     & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
> @@ -97,6 +108,7 @@ grub_pit_wait (grub_uint16_t tics)
>    grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
>  	     & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
>               GRUB_PIT_SPEAKER_PORT);
> +# endif
>  }
>  #endif
>  
> @@ -119,7 +131,7 @@ calibrate_tsc (void)
>    grub_uint64_t end_tsc;
>  
>    tsc_boot_time = grub_get_tsc ();
> -  grub_pit_wait (0xffff);
> +  grub_stall (0xffff);
>    end_tsc = grub_get_tsc ();
>  
>    grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2014-11-28 19:25 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-12-03 18:59   ` Andrei Borzenkov
  0 siblings, 0 replies; 16+ messages in thread
From: Andrei Borzenkov @ 2014-12-03 18:59 UTC (permalink / raw)
  To: Vladimir 'φ-coder/phcoder' Serbinenko
  Cc: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 2711 bytes --]

В Fri, 28 Nov 2014 21:25:30 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:

> On 26.11.2014 10:59, Laszlo Ersek wrote:
> > HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
> > services instead.
> > 
> > RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1150698
> > RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1160128
> > Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> I don't like to be using any additional EFI function. I prefer to use
> pmtimer as I did in my other patch. Is pmtimer available on hyperv?

It was tested on Hyper-V v2 in https://savannah.gnu.org/bugs/?42944. I
have no idea if it is available on Hyper-V v1.

> > ---
> > 
> > Notes:
> >     Please note that I'm not subscribed to the list.
> > 
> >  grub-core/kern/i386/tsc.c | 20 ++++++++++++++++----
> >  1 file changed, 16 insertions(+), 4 deletions(-)
> > 
> > diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
> > index 3a4cae6..e499648 100644
> > --- a/grub-core/kern/i386/tsc.c
> > +++ b/grub-core/kern/i386/tsc.c
> > @@ -26,9 +26,14 @@
> >  #include <grub/i386/tsc.h>
> >  #include <grub/i386/cpuid.h>
> >  #ifdef GRUB_MACHINE_XEN
> > -#include <grub/xen.h>
> > +# include <grub/xen.h>
> >  #else
> > -#include <grub/i386/pit.h>
> > +# ifdef GRUB_MACHINE_EFI
> > +#  include <grub/efi/efi.h>
> > +#  include <grub/efi/api.h>
> > +# else
> > +#  include <grub/i386/pit.h>
> > +# endif
> >  #endif
> >  #include <grub/cpu/io.h>
> >  
> > @@ -72,8 +77,14 @@ grub_cpu_is_tsc_supported (void)
> >  #ifndef GRUB_MACHINE_XEN
> >  
> >  static void
> > -grub_pit_wait (grub_uint16_t tics)
> > +grub_stall (grub_uint16_t tics)
> >  {
> > +# ifdef GRUB_MACHINE_EFI
> > +  grub_uint64_t microseconds;
> > +
> > +  microseconds = (grub_uint64_t)tics * 1000 * 1000 * 3 / 3579545;
> > +  efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
> > +# else
> >    /* Disable timer2 gate and speaker.  */
> >    grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
> >  	     & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
> > @@ -97,6 +108,7 @@ grub_pit_wait (grub_uint16_t tics)
> >    grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
> >  	     & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
> >               GRUB_PIT_SPEAKER_PORT);
> > +# endif
> >  }
> >  #endif
> >  
> > @@ -119,7 +131,7 @@ calibrate_tsc (void)
> >    grub_uint64_t end_tsc;
> >  
> >    tsc_boot_time = grub_get_tsc ();
> > -  grub_pit_wait (0xffff);
> > +  grub_stall (0xffff);
> >    end_tsc = grub_get_tsc ();
> >  
> >    grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
> > 
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2014-11-26  8:59 [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI Laszlo Ersek
  2014-11-26 13:42 ` Andrei Borzenkov
  2014-11-28 19:25 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2015-11-27 17:55 ` Andrei Borzenkov
  2015-11-28  5:25   ` Elliott, Robert (Persistent Memory)
  2015-11-30 16:31   ` Vitaly Kuznetsov
  2 siblings, 2 replies; 16+ messages in thread
From: Andrei Borzenkov @ 2015-11-27 17:55 UTC (permalink / raw)
  To: The development of GNU GRUB, vkuznets, decui, pjones, lersek

26.11.2014 11:59, Laszlo Ersek пишет:
> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
> services instead.
> 


Could you retest with current master? It now supports multiple methods
to calibrate TSC and should avoid PIT on UEFI systems.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-11-27 17:55 ` Andrei Borzenkov
@ 2015-11-28  5:25   ` Elliott, Robert (Persistent Memory)
  2015-11-28  6:02     ` Andrei Borzenkov
  2015-11-30 16:31   ` Vitaly Kuznetsov
  1 sibling, 1 reply; 16+ messages in thread
From: Elliott, Robert (Persistent Memory) @ 2015-11-28  5:25 UTC (permalink / raw)
  To: The development of GNU GRUB, vkuznets@redhat.com,
	decui@microsoft.com, pjones@redhat.com, lersek@redhat.com



> -----Original Message-----
> From: grub-devel-bounces+elliott=hp.com@gnu.org [mailto:grub-devel-
> bounces+elliott=hp.com@gnu.org] On Behalf Of Andrei Borzenkov
> Sent: Friday, November 27, 2015 11:56 AM
> To: The development of GNU GRUB <grub-devel@gnu.org>;
> vkuznets@redhat.com; decui@microsoft.com; pjones@redhat.com;
> lersek@redhat.com
> Subject: Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot
> service on GRUB_MACHINE_EFI
> 
> 26.11.2014 11:59, Laszlo Ersek пишет:
> > HyperV Gen2 virtual machines have no PIT; guest code should rely on
> UEFI
> > services instead.
> >
> 
> 
> Could you retest with current master? It now supports multiple
> methods
> to calibrate TSC and should avoid PIT on UEFI systems.
> 

Patch d43a5ee results in make failing:

make[3]: *** No rule to make target 'commands/efi/acpi.c', needed by 'commands/efi/acpi_module-acpi.o'.  Stop.


---
Robert Elliott, HPE Persistent Memory



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-11-28  5:25   ` Elliott, Robert (Persistent Memory)
@ 2015-11-28  6:02     ` Andrei Borzenkov
  0 siblings, 0 replies; 16+ messages in thread
From: Andrei Borzenkov @ 2015-11-28  6:02 UTC (permalink / raw)
  To: The development of GNU GRUB, vkuznets@redhat.com,
	decui@microsoft.com, pjones@redhat.com, lersek@redhat.com

28.11.2015 08:25, Elliott, Robert (Persistent Memory) пишет:
> 
> 
>> -----Original Message-----
>> From: grub-devel-bounces+elliott=hp.com@gnu.org [mailto:grub-devel-
>> bounces+elliott=hp.com@gnu.org] On Behalf Of Andrei Borzenkov
>> Sent: Friday, November 27, 2015 11:56 AM
>> To: The development of GNU GRUB <grub-devel@gnu.org>;
>> vkuznets@redhat.com; decui@microsoft.com; pjones@redhat.com;
>> lersek@redhat.com
>> Subject: Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot
>> service on GRUB_MACHINE_EFI
>>
>> 26.11.2014 11:59, Laszlo Ersek пишет:
>>> HyperV Gen2 virtual machines have no PIT; guest code should rely on
>> UEFI
>>> services instead.
>>>
>>
>>
>> Could you retest with current master? It now supports multiple
>> methods
>> to calibrate TSC and should avoid PIT on UEFI systems.
>>
> 
> Patch d43a5ee results in make failing:
> 
> make[3]: *** No rule to make target 'commands/efi/acpi.c', needed by 'commands/efi/acpi_module-acpi.o'.  Stop.
> 

Please make clean checkout and autogen.sh to correctly recreate makefiles.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-11-27 17:55 ` Andrei Borzenkov
  2015-11-28  5:25   ` Elliott, Robert (Persistent Memory)
@ 2015-11-30 16:31   ` Vitaly Kuznetsov
  2015-11-30 16:50     ` Andrei Borzenkov
  1 sibling, 1 reply; 16+ messages in thread
From: Vitaly Kuznetsov @ 2015-11-30 16:31 UTC (permalink / raw)
  To: Andrei Borzenkov; +Cc: The development of GNU GRUB, decui, lersek

Andrei Borzenkov <arvidjaar@gmail.com> writes:

> 26.11.2014 11:59, Laszlo Ersek пишет:
>> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
>> services instead.
>> 
>
> Could you retest with current master? It now supports multiple methods
> to calibrate TSC and should avoid PIT on UEFI systems.

Unfortunately, current master (grub-2.02-beta2-561-g346a494) still
doesn't work for me, timer keeps running like crazy on Gen2 Hyper-V VMs.

-- 
  Vitaly


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-11-30 16:31   ` Vitaly Kuznetsov
@ 2015-11-30 16:50     ` Andrei Borzenkov
  2015-11-30 17:34       ` Andrei Borzenkov
  0 siblings, 1 reply; 16+ messages in thread
From: Andrei Borzenkov @ 2015-11-30 16:50 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: The development of GNU GRUB, mchang, decui, lersek

30.11.2015 19:31, Vitaly Kuznetsov пишет:
> Andrei Borzenkov <arvidjaar@gmail.com> writes:
> 
>> 26.11.2014 11:59, Laszlo Ersek пишет:
>>> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
>>> services instead.
>>>
>>
>> Could you retest with current master? It now supports multiple methods
>> to calibrate TSC and should avoid PIT on UEFI systems.
> 
> Unfortunately, current master (grub-2.02-beta2-561-g346a494) still
> doesn't work for me, timer keeps running like crazy on Gen2 Hyper-V VMs.
> 

@Michael: I remember you tested version of Vladimir patch on Hyper-V?
Could you test current master?


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-11-30 16:50     ` Andrei Borzenkov
@ 2015-11-30 17:34       ` Andrei Borzenkov
  2015-11-30 18:19         ` Vitaly Kuznetsov
  2015-12-01  3:11         ` Michael Chang
  0 siblings, 2 replies; 16+ messages in thread
From: Andrei Borzenkov @ 2015-11-30 17:34 UTC (permalink / raw)
  To: Vitaly Kuznetsov; +Cc: The development of GNU GRUB, mchang, decui, lersek

30.11.2015 19:50, Andrei Borzenkov пишет:
> 30.11.2015 19:31, Vitaly Kuznetsov пишет:
>> Andrei Borzenkov <arvidjaar@gmail.com> writes:
>>
>>> 26.11.2014 11:59, Laszlo Ersek пишет:
>>>> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
>>>> services instead.
>>>>
>>>
>>> Could you retest with current master? It now supports multiple methods
>>> to calibrate TSC and should avoid PIT on UEFI systems.
>>
>> Unfortunately, current master (grub-2.02-beta2-561-g346a494) still
>> doesn't work for me, timer keeps running like crazy on Gen2 Hyper-V VMs.
>>
> 
> @Michael: I remember you tested version of Vladimir patch on Hyper-V?
> Could you test current master?
> 


  if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) {
    ret = 1;
    /* Wait.  */
    while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
== 0x00);
  }


If PIT is not present all reads should return 0xff so this will always
succeed, right? Linux kernel is using some sanity checks, if loop
terminated too early it assumes calibration failure.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-11-30 17:34       ` Andrei Borzenkov
@ 2015-11-30 18:19         ` Vitaly Kuznetsov
  2015-12-01  3:11         ` Michael Chang
  1 sibling, 0 replies; 16+ messages in thread
From: Vitaly Kuznetsov @ 2015-11-30 18:19 UTC (permalink / raw)
  To: Andrei Borzenkov; +Cc: The development of GNU GRUB, mchang, decui, lersek

Andrei Borzenkov <arvidjaar@gmail.com> writes:

> 30.11.2015 19:50, Andrei Borzenkov пишет:
>> 30.11.2015 19:31, Vitaly Kuznetsov пишет:
>>> Andrei Borzenkov <arvidjaar@gmail.com> writes:
>>>
>>>> 26.11.2014 11:59, Laszlo Ersek пишет:
>>>>> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
>>>>> services instead.
>>>>>
>>>>
>>>> Could you retest with current master? It now supports multiple methods
>>>> to calibrate TSC and should avoid PIT on UEFI systems.
>>>
>>> Unfortunately, current master (grub-2.02-beta2-561-g346a494) still
>>> doesn't work for me, timer keeps running like crazy on Gen2 Hyper-V VMs.
>>>
>> 
>> @Michael: I remember you tested version of Vladimir patch on Hyper-V?
>> Could you test current master?
>> 
>
>   if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) {
>     ret = 1;
>     /* Wait.  */
>     while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
> == 0x00);
>   }
>
> If PIT is not present all reads should return 0xff

I've instrumented pit_calibrate_tsc() in Linux and can confirm inb(0x61)
returns 0xff on Hyper-V Gen2 VMs.

> so this will always
> succeed, right? Linux kernel is using some sanity checks, if loop
> terminated too early it assumes calibration failure.

-- 
  Vitaly


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-11-30 17:34       ` Andrei Borzenkov
  2015-11-30 18:19         ` Vitaly Kuznetsov
@ 2015-12-01  3:11         ` Michael Chang
  2015-12-01  8:34           ` Vitaly Kuznetsov
  1 sibling, 1 reply; 16+ messages in thread
From: Michael Chang @ 2015-12-01  3:11 UTC (permalink / raw)
  To: Andrei Borzenkov
  Cc: The development of GNU GRUB, Vitaly Kuznetsov, decui, lersek

On Mon, Nov 30, 2015 at 08:34:18PM +0300, Andrei Borzenkov wrote:
> 30.11.2015 19:50, Andrei Borzenkov пишет:
> > 30.11.2015 19:31, Vitaly Kuznetsov пишет:
> >> Andrei Borzenkov <arvidjaar@gmail.com> writes:
> >>
> >>> 26.11.2014 11:59, Laszlo Ersek пишет:
> >>>> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
> >>>> services instead.
> >>>>
> >>>
> >>> Could you retest with current master? It now supports multiple methods
> >>> to calibrate TSC and should avoid PIT on UEFI systems.
> >>
> >> Unfortunately, current master (grub-2.02-beta2-561-g346a494) still
> >> doesn't work for me, timer keeps running like crazy on Gen2 Hyper-V VMs.
> >>
> > 
> > @Michael: I remember you tested version of Vladimir patch on Hyper-V?
> > Could you test current master?
> > 

I don't have access to Hyper-V either. My initial patch was tested on
Hyper-V from my colleage in Nuremburg. For Vladimir's patch I did tests
on my EFI machine and mostly intersted in pmtimer to function properly,
as that's new introduced timer to the patch .. 

> 
> 
>   if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) {
>     ret = 1;
>     /* Wait.  */
>     while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
> == 0x00);
>   }
> 
> 
> If PIT is not present all reads should return 0xff so this will always
> succeed, right? Linux kernel is using some sanity checks, if loop
> terminated too early it assumes calibration failure.

Well, yes the detection is bogus, I think the condition should check for
return 0x00, which means the timer is counting and can continue to wait
for it to finish.

   if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0) {
     ret = 1;
     /* Wait.  */
     while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
 == 0x00);
   }

Vitaly, could you please help to retest ?

Thanks,
Michael

> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-12-01  3:11         ` Michael Chang
@ 2015-12-01  8:34           ` Vitaly Kuznetsov
  2015-12-01 15:54             ` Andrei Borzenkov
  0 siblings, 1 reply; 16+ messages in thread
From: Vitaly Kuznetsov @ 2015-12-01  8:34 UTC (permalink / raw)
  To: Michael Chang
  Cc: Andrei Borzenkov, The development of GNU GRUB, decui, lersek

Michael Chang <mchang@suse.com> writes:

> On Mon, Nov 30, 2015 at 08:34:18PM +0300, Andrei Borzenkov wrote:
>> 30.11.2015 19:50, Andrei Borzenkov пишет:
>> > 30.11.2015 19:31, Vitaly Kuznetsov пишет:
>> >> Andrei Borzenkov <arvidjaar@gmail.com> writes:
>> >>
>> >>> 26.11.2014 11:59, Laszlo Ersek пишет:
>> >>>> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
>> >>>> services instead.
>> >>>>
>> >>>
>> >>> Could you retest with current master? It now supports multiple methods
>> >>> to calibrate TSC and should avoid PIT on UEFI systems.
>> >>
>> >> Unfortunately, current master (grub-2.02-beta2-561-g346a494) still
>> >> doesn't work for me, timer keeps running like crazy on Gen2 Hyper-V VMs.
>> >>
>> > 
>> > @Michael: I remember you tested version of Vladimir patch on Hyper-V?
>> > Could you test current master?
>> > 
>
> I don't have access to Hyper-V either. My initial patch was tested on
> Hyper-V from my colleage in Nuremburg. For Vladimir's patch I did tests
> on my EFI machine and mostly intersted in pmtimer to function properly,
> as that's new introduced timer to the patch .. 
>
>> 
>> 
>>   if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) {
>>     ret = 1;
>>     /* Wait.  */
>>     while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
>> == 0x00);
>>   }
>> 
>> 
>> If PIT is not present all reads should return 0xff so this will always
>> succeed, right? Linux kernel is using some sanity checks, if loop
>> terminated too early it assumes calibration failure.
>
> Well, yes the detection is bogus, I think the condition should check for
> return 0x00, which means the timer is counting and can continue to wait
> for it to finish.
>
>    if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0) {
>      ret = 1;
>      /* Wait.  */
>      while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
>  == 0x00);
>    }
>
> Vitaly, could you please help to retest ?
>

Sure,

just did and with this change timer seems to be working as expected.

-- 
  Vitaly


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-12-01  8:34           ` Vitaly Kuznetsov
@ 2015-12-01 15:54             ` Andrei Borzenkov
  2015-12-02 11:02               ` Vitaly Kuznetsov
  0 siblings, 1 reply; 16+ messages in thread
From: Andrei Borzenkov @ 2015-12-01 15:54 UTC (permalink / raw)
  To: Vitaly Kuznetsov, Michael Chang
  Cc: The development of GNU GRUB, decui, lersek

01.12.2015 11:34, Vitaly Kuznetsov пишет:
> Michael Chang <mchang@suse.com> writes:
> 
>> On Mon, Nov 30, 2015 at 08:34:18PM +0300, Andrei Borzenkov wrote:
>>> 30.11.2015 19:50, Andrei Borzenkov пишет:
>>>> 30.11.2015 19:31, Vitaly Kuznetsov пишет:
>>>>> Andrei Borzenkov <arvidjaar@gmail.com> writes:
>>>>>
>>>>>> 26.11.2014 11:59, Laszlo Ersek пишет:
>>>>>>> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
>>>>>>> services instead.
>>>>>>>
>>>>>>
>>>>>> Could you retest with current master? It now supports multiple methods
>>>>>> to calibrate TSC and should avoid PIT on UEFI systems.
>>>>>
>>>>> Unfortunately, current master (grub-2.02-beta2-561-g346a494) still
>>>>> doesn't work for me, timer keeps running like crazy on Gen2 Hyper-V VMs.
>>>>>
>>>>
>>>> @Michael: I remember you tested version of Vladimir patch on Hyper-V?
>>>> Could you test current master?
>>>>
>>
>> I don't have access to Hyper-V either. My initial patch was tested on
>> Hyper-V from my colleage in Nuremburg. For Vladimir's patch I did tests
>> on my EFI machine and mostly intersted in pmtimer to function properly,
>> as that's new introduced timer to the patch .. 
>>
>>>
>>>
>>>   if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) {
>>>     ret = 1;
>>>     /* Wait.  */
>>>     while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
>>> == 0x00);
>>>   }
>>>
>>>
>>> If PIT is not present all reads should return 0xff so this will always
>>> succeed, right? Linux kernel is using some sanity checks, if loop
>>> terminated too early it assumes calibration failure.
>>
>> Well, yes the detection is bogus, I think the condition should check for
>> return 0x00, which means the timer is counting and can continue to wait
>> for it to finish.
>>
>>    if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0) {
>>      ret = 1;
>>      /* Wait.  */
>>      while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
>>  == 0x00);
>>    }
>>
>> Vitaly, could you please help to retest ?
>>
> 
> Sure,
> 
> just did and with this change timer seems to be working as expected.
> 

Thank you! I pushed fix, if you could verify that master now works on
Hyper-V would be great.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI
  2015-12-01 15:54             ` Andrei Borzenkov
@ 2015-12-02 11:02               ` Vitaly Kuznetsov
  0 siblings, 0 replies; 16+ messages in thread
From: Vitaly Kuznetsov @ 2015-12-02 11:02 UTC (permalink / raw)
  To: Andrei Borzenkov
  Cc: The development of GNU GRUB, Michael Chang, decui, lersek

Andrei Borzenkov <arvidjaar@gmail.com> writes:

> 01.12.2015 11:34, Vitaly Kuznetsov пишет:
>> Michael Chang <mchang@suse.com> writes:
>> 
>>> On Mon, Nov 30, 2015 at 08:34:18PM +0300, Andrei Borzenkov wrote:
>>>> 30.11.2015 19:50, Andrei Borzenkov пишет:
>>>>> 30.11.2015 19:31, Vitaly Kuznetsov пишет:
>>>>>> Andrei Borzenkov <arvidjaar@gmail.com> writes:
>>>>>>
>>>>>>> 26.11.2014 11:59, Laszlo Ersek пишет:
>>>>>>>> HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
>>>>>>>> services instead.
>>>>>>>>
>>>>>>>
>>>>>>> Could you retest with current master? It now supports multiple methods
>>>>>>> to calibrate TSC and should avoid PIT on UEFI systems.
>>>>>>
>>>>>> Unfortunately, current master (grub-2.02-beta2-561-g346a494) still
>>>>>> doesn't work for me, timer keeps running like crazy on Gen2 Hyper-V VMs.
>>>>>>
>>>>>
>>>>> @Michael: I remember you tested version of Vladimir patch on Hyper-V?
>>>>> Could you test current master?
>>>>>
>>>
>>> I don't have access to Hyper-V either. My initial patch was tested on
>>> Hyper-V from my colleage in Nuremburg. For Vladimir's patch I did tests
>>> on my EFI machine and mostly intersted in pmtimer to function properly,
>>> as that's new introduced timer to the patch .. 
>>>
>>>>
>>>>
>>>>   if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) {
>>>>     ret = 1;
>>>>     /* Wait.  */
>>>>     while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
>>>> == 0x00);
>>>>   }
>>>>
>>>>
>>>> If PIT is not present all reads should return 0xff so this will always
>>>> succeed, right? Linux kernel is using some sanity checks, if loop
>>>> terminated too early it assumes calibration failure.
>>>
>>> Well, yes the detection is bogus, I think the condition should check for
>>> return 0x00, which means the timer is counting and can continue to wait
>>> for it to finish.
>>>
>>>    if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0) {
>>>      ret = 1;
>>>      /* Wait.  */
>>>      while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)
>>>  == 0x00);
>>>    }
>>>
>>> Vitaly, could you please help to retest ?
>>>
>> 
>> Sure,
>> 
>> just did and with this change timer seems to be working as expected.
>> 
>
> Thank you! I pushed fix, if you could verify that master now works on
> Hyper-V would be great.

Just tested grub-2.02-beta2-562-ga03c103, works as well. Thanks!

-- 
  Vitaly


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-12-02 11:02 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26  8:59 [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI Laszlo Ersek
2014-11-26 13:42 ` Andrei Borzenkov
2014-11-26 13:49   ` Laszlo Ersek
2014-11-28 19:25 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-12-03 18:59   ` Andrei Borzenkov
2015-11-27 17:55 ` Andrei Borzenkov
2015-11-28  5:25   ` Elliott, Robert (Persistent Memory)
2015-11-28  6:02     ` Andrei Borzenkov
2015-11-30 16:31   ` Vitaly Kuznetsov
2015-11-30 16:50     ` Andrei Borzenkov
2015-11-30 17:34       ` Andrei Borzenkov
2015-11-30 18:19         ` Vitaly Kuznetsov
2015-12-01  3:11         ` Michael Chang
2015-12-01  8:34           ` Vitaly Kuznetsov
2015-12-01 15:54             ` Andrei Borzenkov
2015-12-02 11:02               ` Vitaly Kuznetsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).