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 <duanyay...@bytedance.com> Signed-off-by: Li Yongqiang <liyongqi...@huaqin.com> Signed-off-by: Sun Ming <simon....@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 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel