clockcalib: Fix an overflow bug
tc_counter_mask is an unsigned int and in the TSC timecounter is equal to UINT_MAX, so the addition tc->tc_counter_mask + 1 can overflow to 0, resulting in a hang during boot. Fixes: c2705ceaeb09 ("x86: Speed up clock calibration") Reviewed by: cperciva Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33956
This commit is contained in:
parent
e0282802a6
commit
c3196306f0
@ -108,7 +108,7 @@ clockcalib(uint64_t (*clk)(void), const char *clkname)
|
||||
clk1 = clk() - clk0;
|
||||
t1 = tc->tc_get_timecount(tc) & tc->tc_counter_mask;
|
||||
while (t1 + tadj < tlast)
|
||||
tadj += tc->tc_counter_mask + 1;
|
||||
tadj += (uint64_t)tc->tc_counter_mask + 1;
|
||||
tlast = t1 + tadj;
|
||||
t1 += tadj - t0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user