grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Bugfix: grub menu gets stuck


From: Duan Yayong
Subject: [PATCH] Bugfix: grub menu gets stuck
Date: Thu, 28 Nov 2024 11:48:26 +0800

Adding "if (grub_tsc_rate == 0)" judgement just in case other unknown
instruction exception, so that
"grub_tsc_calibrate_from_pit||grub_tsc_calibrate_from_efi" getting
"grub_tsc_rate" methods have a opportunity to be performed but
causing grub menu stucking.

Signed-off-by: Duan Yayong <duanyayong@bytedance.com>
Signed-off-by: Li Yongqiang <liyongqiang@huaqin.com>
Signed-off-by: Sun Ming <simon.sun@huaqin.com>
---
 grub-core/kern/i386/tsc_pmtimer.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/grub-core/kern/i386/tsc_pmtimer.c 
b/grub-core/kern/i386/tsc_pmtimer.c
index 5c03c510a..90db49514 100644
--- a/grub-core/kern/i386/tsc_pmtimer.c
+++ b/grub-core/kern/i386/tsc_pmtimer.c
@@ -143,5 +143,15 @@ grub_tsc_calibrate_from_pmtimer (void)
   if (tsc_diff == 0)
     return 0;
   grub_tsc_rate = grub_divmod64 ((1ULL << 32), tsc_diff, 0);
+  /*
+   * Specifically, when the tsc_diff (end_tsc - start_tsc) is greater than 
(1ULL << 32),
+   * the result of grub_divmod64() becomes zero, causing grub_tsc_rate to 
always be zero.
+   * As a result, grub_tsc_get_time_ms() consistently returns zero, and the 
grub menu
+   * countdown gets stuck. To resolve this, we return 0 to proceed to the next 
calibration
+   * function when grub_tsc_rate is zero.
+   */
+  if (grub_tsc_rate == 0)
+    return 0;
+
   return 1;
 }
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]