From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1XtcdW-0008TZ-NC for mharc-grub-devel@gnu.org; Wed, 26 Nov 2014 08:28:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtYRl-0007i1-Dr for grub-devel@gnu.org; Wed, 26 Nov 2014 03:59:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XtYRf-0003DI-9D for grub-devel@gnu.org; Wed, 26 Nov 2014 03:59:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58025) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XtYRf-0003DE-1s for grub-devel@gnu.org; Wed, 26 Nov 2014 03:59:31 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sAQ8xTVv021779 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 26 Nov 2014 03:59:29 -0500 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sAQ8xP8t002343; Wed, 26 Nov 2014 03:59:26 -0500 From: Laszlo Ersek To: grub-devel@gnu.org, vkuznets@redhat.com, decui@microsoft.com, pjones@redhat.com, lersek@redhat.com Subject: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on GRUB_MACHINE_EFI Date: Wed, 26 Nov 2014 09:59:21 +0100 Message-Id: <1416992361-4167-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 X-Mailman-Approved-At: Wed, 26 Nov 2014 08:28:01 -0500 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Nov 2014 08:59:43 -0000 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 --- 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 #include #ifdef GRUB_MACHINE_XEN -#include +# include #else -#include +# ifdef GRUB_MACHINE_EFI +# include +# include +# else +# include +# endif #endif #include @@ -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