From nobody Thu May 05 18:38:10 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D4AD61AC17FE; Thu, 5 May 2022 18:38:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KvMry5cm1z4gJY; Thu, 5 May 2022 18:38:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651775890; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EuS0XWlodUgDNyE4VO10aRNwedkuNSkBGcE8BzlzWgs=; b=NnH2OgMXfuvjFmeXCHdPUs1XIIGEUlgCdrP3lEVXMrBdx6jP4cpytU4O2Fi/1J3qGGNVjI ipbQRfCTQiG68BRMTEVtcLyg8jHEC7BS96K3wFF4lUooSYs15bq9OvlhOsm//Pz6pYVUIx 94zKuT/0Y5eLYJwsze78wuGLE+0GLYwAZmtbBsOwulJrM1iUTqpkNADFnfFVzKsqq1XcEm SdTm+Y6cpuTwph2COVgp1xKpi0C+ULZXZvQI66sGEmpHL8AgZozwW+u+lduYOJgLYPAPq3 BwMQq9bgLzdfRvjYIlmsO3jdtPxyEFELGAoG4wAYc15y7NPFI5QmAB628oH7wQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A0E40485F; Thu, 5 May 2022 18:38:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 245IcAia036165; Thu, 5 May 2022 18:38:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 245IcAH5036164; Thu, 5 May 2022 18:38:10 GMT (envelope-from git) Date: Thu, 5 May 2022 18:38:10 GMT Message-Id: <202205051838.245IcAH5036164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 9470a2f7da48 - releng/13.1 - clockcalib: Fix an overflow bug List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.1 X-Git-Reftype: branch X-Git-Commit: 9470a2f7da488f3c14051e39691fbfddcf2aa0fe Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651775890; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EuS0XWlodUgDNyE4VO10aRNwedkuNSkBGcE8BzlzWgs=; b=vPMxgEjozucfrX12UIKKsSn1N5p4jJtwvTXsy3UoHFHr3pw1OWOz4+ckDJ98D6Y4WCSTIm 4kaPhmC/Q45zhOZ4LttOpRwsGWXTNW1vG1R57dacMrniKVBrYp3G7G/YFO6CD65BtAwolQ HyFArA+qqSMNukX0AjYjSeZv+f0ZQ3V9WCL4lvPd5DluXimEHFitMxbQ9/iP5Po2D+B6i+ iP3JEbx3ZwvX8XzIIF6F1vFyvuzJiNAfhqJAD8a0eJQI7BeYelvNGlqtTHFw74oA+mT3/N gAdTCsV3OebhPck3GJSB1+N+va7bEx00eEWf7Fhn8pB+guTMgs4euFD6rIq4IA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651775890; a=rsa-sha256; cv=none; b=ppWG1gkYNbRFEjMN4j1xUSTElzQY9Ltcnzv5JaYgGPNjtCkU3ow8SmLhEmiGU+917hRWdk BBgm7+m4J/AsjvLiu/6RuHuAlbgnjL28Lzp8AynqY6ObH6kNP5u3B097MbhcohkdYTY05O yhcXF9qb833FJtkhKytn9t8omNZq0GcxUY8KPCKK59WeM51MW6aJTi+SjJE8Z2inDnfvaT SxvhXg1aKB0aB1sUAsdMVIhgaLiAqjCVvfpWR7jWAT4lJoNEaf/3oRQxNa2R2wjfYkBb+G Vt8p2o+Ijm7Fpq+VjBkF2/2OHa+PfPJvDyfGOeU0phK3iwh6AhJ6yp0Gq/ZuDw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.1 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9470a2f7da488f3c14051e39691fbfddcf2aa0fe commit 9470a2f7da488f3c14051e39691fbfddcf2aa0fe Author: Mark Johnston AuthorDate: 2022-01-20 13:23:38 +0000 Commit: Mark Johnston CommitDate: 2022-05-05 18:37:48 +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. Approved by: re (gjb) Fixes: c2705ceaeb09 ("x86: Speed up clock calibration") Reviewed by: cperciva Sponsored by: The FreeBSD Foundation (cherry picked from commit c3196306f092e46008d5ffa626fbafe1f8a94848) (cherry picked from commit 58f49b7da7da50d1ea66b5d810a5e8769b5319f4) --- 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;