]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/rtclock.c
xnu-2422.90.20.tar.gz
[apple/xnu.git] / osfmk / i386 / rtclock.c
index 9935839d90269cb8079553cd2fb46429a5b6adb5..415ee92fd9d6dee2e344a977e83cec5a3b110a22 100644 (file)
@@ -345,8 +345,15 @@ rtc_set_timescale(uint64_t cycles)
 
        rntp->shift = shift;
 
+       /*
+        * On some platforms, the TSC is not reset at warm boot. But the
+        * rebase time must be relative to the current boot so we can't use
+        * mach_absolute_time(). Instead, we convert the TSC delta since boot
+        * to nanoseconds.
+        */
        if (tsc_rebase_abs_time == 0)
-               tsc_rebase_abs_time = mach_absolute_time();
+               tsc_rebase_abs_time = _rtc_tsc_to_nanoseconds(
+                                               rdtsc64() - tsc_at_boot, rntp);
 
        rtc_nanotime_init(0);
 }