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:c2705ceaeb
("x86: Speed up clock calibration") Reviewed by: cperciva Sponsored by: The FreeBSD Foundation (cherry picked from commitc3196306f0
)
This commit is contained in:
parent
249d205cb8
commit
58f49b7da7
@ -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…
Reference in New Issue
Block a user