mirror of
https://github.com/opnsense/src.git
synced 2026-06-08 16:22:46 -04:00
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
Differential Revision: https://reviews.freebsd.org/D33956
This commit is contained in:
parent
e0282802a6
commit
c3196306f0
1 changed files with 1 additions and 1 deletions
|
|
@ -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 a new issue