From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 20:07:08 +0000 (+0100) Subject: * grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that X-Git-Tag: 2.02-beta3~560 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2e62352bc28bd5d3efafc1b5cbe211ff9e9987fd;p=thirdparty%2Fgrub.git * grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that no division by 0 occurs. --- diff --git a/ChangeLog b/ChangeLog index ecbe11dc5..c2551db30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that + no division by 0 occurs. + 2015-01-20 Vladimir Serbinenko * include/grub/misc.h (grub_div_roundup): Remove as it's unused. diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index 3a4cae601..d7d1783e4 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -122,7 +122,11 @@ calibrate_tsc (void) grub_pit_wait (0xffff); end_tsc = grub_get_tsc (); - grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0); + grub_tsc_rate = 0; + if (end_tsc > tsc_boot_time) + grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0); + if (grub_tsc_rate == 0) + grub_tsc_rate = 5368;/* 800 MHz */ } #endif