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