|
|
f725e3 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
f725e3 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
f725e3 |
Date: Fri, 10 Oct 2014 11:11:09 +0200
|
|
|
f725e3 |
Subject: [PATCH] calibrate_tsc(): use the Stall() EFI boot service on
|
|
|
f725e3 |
GRUB_MACHINE_EFI
|
|
|
f725e3 |
|
|
|
f725e3 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1150698
|
|
|
f725e3 |
|
|
|
f725e3 |
HyperV Gen2 virtual machines have no PIT; guest code should rely on UEFI
|
|
|
f725e3 |
services instead.
|
|
|
f725e3 |
|
|
|
f725e3 |
Signed-off-by: RHEL Ninjas <example@example.com>
|
|
|
f725e3 |
---
|
|
|
f725e3 |
grub-core/kern/i386/tsc.c | 20 ++++++++++++++++----
|
|
|
f725e3 |
1 file changed, 16 insertions(+), 4 deletions(-)
|
|
|
f725e3 |
|
|
|
f725e3 |
diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c
|
|
|
f725e3 |
index 3a4cae601d0..e49964833ca 100644
|
|
|
f725e3 |
--- a/grub-core/kern/i386/tsc.c
|
|
|
f725e3 |
+++ b/grub-core/kern/i386/tsc.c
|
|
|
f725e3 |
@@ -26,9 +26,14 @@
|
|
|
f725e3 |
#include <grub/i386/tsc.h>
|
|
|
f725e3 |
#include <grub/i386/cpuid.h>
|
|
|
f725e3 |
#ifdef GRUB_MACHINE_XEN
|
|
|
f725e3 |
-#include <grub/xen.h>
|
|
|
f725e3 |
+# include <grub/xen.h>
|
|
|
f725e3 |
#else
|
|
|
f725e3 |
-#include <grub/i386/pit.h>
|
|
|
f725e3 |
+# ifdef GRUB_MACHINE_EFI
|
|
|
f725e3 |
+# include <grub/efi/efi.h>
|
|
|
f725e3 |
+# include <grub/efi/api.h>
|
|
|
f725e3 |
+# else
|
|
|
f725e3 |
+# include <grub/i386/pit.h>
|
|
|
f725e3 |
+# endif
|
|
|
f725e3 |
#endif
|
|
|
f725e3 |
#include <grub/cpu/io.h>
|
|
|
f725e3 |
|
|
|
f725e3 |
@@ -72,8 +77,14 @@ grub_cpu_is_tsc_supported (void)
|
|
|
f725e3 |
#ifndef GRUB_MACHINE_XEN
|
|
|
f725e3 |
|
|
|
f725e3 |
static void
|
|
|
f725e3 |
-grub_pit_wait (grub_uint16_t tics)
|
|
|
f725e3 |
+grub_stall (grub_uint16_t tics)
|
|
|
f725e3 |
{
|
|
|
f725e3 |
+# ifdef GRUB_MACHINE_EFI
|
|
|
f725e3 |
+ grub_uint64_t microseconds;
|
|
|
f725e3 |
+
|
|
|
f725e3 |
+ microseconds = (grub_uint64_t)tics * 1000 * 1000 * 3 / 3579545;
|
|
|
f725e3 |
+ efi_call_1 (grub_efi_system_table->boot_services->stall, microseconds);
|
|
|
f725e3 |
+# else
|
|
|
f725e3 |
/* Disable timer2 gate and speaker. */
|
|
|
f725e3 |
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
|
|
|
f725e3 |
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
|
|
|
f725e3 |
@@ -97,6 +108,7 @@ grub_pit_wait (grub_uint16_t tics)
|
|
|
f725e3 |
grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT)
|
|
|
f725e3 |
& ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2),
|
|
|
f725e3 |
GRUB_PIT_SPEAKER_PORT);
|
|
|
f725e3 |
+# endif
|
|
|
f725e3 |
}
|
|
|
f725e3 |
#endif
|
|
|
f725e3 |
|
|
|
f725e3 |
@@ -119,7 +131,7 @@ calibrate_tsc (void)
|
|
|
f725e3 |
grub_uint64_t end_tsc;
|
|
|
f725e3 |
|
|
|
f725e3 |
tsc_boot_time = grub_get_tsc ();
|
|
|
f725e3 |
- grub_pit_wait (0xffff);
|
|
|
f725e3 |
+ grub_stall (0xffff);
|
|
|
f725e3 |
end_tsc = grub_get_tsc ();
|
|
|
f725e3 |
|
|
|
f725e3 |
grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0);
|