]> xenbits.xensource.com Git - xen.git/commitdiff
x86: Fix time-scale calculation to avoid #DE fault.
authorKeir Fraser <keir@xensource.com>
Thu, 11 Oct 2007 18:23:40 +0000 (19:23 +0100)
committerKeir Fraser <keir@xensource.com>
Thu, 11 Oct 2007 18:23:40 +0000 (19:23 +0100)
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/time.c

index b00ee01aa3227a8de37310320d8a1d752fa57ef1..a9e2b5b7353c742e973ef1a22094f0b8a3afa324 100644 (file)
@@ -214,6 +214,8 @@ static void set_time_scale(struct time_scale *ts, u64 ticks_per_sec)
     u32 tps32;
     int shift = 0;
 
+    ASSERT(tps64 != 0);
+
     while ( tps64 > (MILLISECS(1000)*2) )
     {
         tps64 >>= 1;
@@ -221,7 +223,7 @@ static void set_time_scale(struct time_scale *ts, u64 ticks_per_sec)
     }
 
     tps32 = (u32)tps64;
-    while ( tps32 < (u32)MILLISECS(1000) )
+    while ( tps32 <= (u32)MILLISECS(1000) )
     {
         tps32 <<= 1;
         shift++;