Date: Thu, 20 Jan 2022 14:58:41 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: c3196306f092 - main - clockcalib: Fix an overflow bug Message-ID: <202201201458.20KEwfeA078538@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c3196306f092e46008d5ffa626fbafe1f8a94848 commit c3196306f092e46008d5ffa626fbafe1f8a94848 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-01-20 13:23:38 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-01-20 13:23:38 +0000 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 --- sys/kern/subr_clockcalib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/subr_clockcalib.c b/sys/kern/subr_clockcalib.c index 2d6a8c31a9b9..3e93dd0869bf 100644 --- a/sys/kern/subr_clockcalib.c +++ b/sys/kern/subr_clockcalib.c @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202201201458.20KEwfeA078538>