]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that
authorVladimir Serbinenko <phcoder@gmail.com>
Tue, 20 Jan 2015 20:07:08 +0000 (21:07 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Wed, 21 Jan 2015 16:42:14 +0000 (17:42 +0100)
no division by 0 occurs.

ChangeLog
grub-core/kern/i386/tsc.c

index ecbe11dc5b9f6359b16b13b45d6202903f7d8109..c2551db3023d84bc60634989076ecb0f74114036 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that
+       no division by 0 occurs.
+
 2015-01-20  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * include/grub/misc.h (grub_div_roundup): Remove as it's unused.
index 3a4cae601d039b2b9c25de69fa3e59cccdd170b6..d7d1783e4884479d48fd5672c4f7a47770545c83 100644 (file)
@@ -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