From nobody Thu May 05 16:09:03 2022 X-Original-To: dev-commits-src-all@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 6D77A1AC0F02; Thu, 5 May 2022 16:09:03 +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 4KvJXv2LkMz3qCy; Thu, 5 May 2022 16:09:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651766943; 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=PNk9LITf0PRL2OIISmH6lRizJTcablz03y/k4wnyR4s=; b=fhCVTaWFmkpKZ4YlXuu4ypzB155V1q3Q/SJRjjcb6mCwCn3tQu56OlWSdjNRA57NEdPKyy 6iS+0VhqTW+hVMzh9yfu6I9LQc56kGKSlW4kflD/IEstZK/n1ymQ7362PwzXJIBoRSuKj3 sexC0D64Q3h2nsO1n7T4cfU9bYKlR3SpERjqvRzWDLHkrTWq7fkvr0OWlpUOxnfV+/EyVn UeTQk9UBKNr1h+PqerL4tThYafTfCxp02eM9xjXWXT8td1m1XVY55w6GnJkJbkOoO5AV1X Q8IV5D4tccBPhPBrS5dpG9KVut6SCeoBKEw8Ius5Hs0m19pVTupx1zyQ2me7Hw== 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 31C15205B; Thu, 5 May 2022 16:09:03 +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 245G93Dj034166; Thu, 5 May 2022 16:09:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 245G934s034165; Thu, 5 May 2022 16:09:03 GMT (envelope-from git) Date: Thu, 5 May 2022 16:09:03 GMT Message-Id: <202205051609.245G934s034165@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: 58f49b7da7da - stable/13 - clockcalib: Fix an overflow bug List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 58f49b7da7da50d1ea66b5d810a5e8769b5319f4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651766943; 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=PNk9LITf0PRL2OIISmH6lRizJTcablz03y/k4wnyR4s=; b=Pf91sV7uOV5XS2bfBE2e6w9Y5RR1LfND1Mo0dPtlhb8JOngEphwr7njFUTFrAAUd1BxBun f1SSY9xMxid0aadANFJI5QFlPgAr9c/pYtg9RfI/QZqYurmmyKb9ACLGjiZqEguvnFmzRc P7/oahA6NscFxJTOdoKTT6DVh4WZ9yZDxMz6BREqnpfkZo9SYqNAnJxTNsubMX1RNIbbQE red3ZMQwrC/D0JQMW09nHo5uWd6oWSQNjDV5tNhbzHt3r5V7SuTqZkMNt83gJF93HzWu47 lC4bv0TSI/ayAG2HfdmBaK1Xg1VTd3AzF+aceb4XGePJ5D2ZVL+yZ0KP59csxw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651766943; a=rsa-sha256; cv=none; b=a6b2mPu7iR3eX1uMtlosLCrGSMbX/NbwdZGd9/ws3TqYQfVq0b+6t9E3vuVkqfNB5jTr7T KPR0Q6PC2mi6dvl64CG8ufqulG0bFfjNDnvsSi21YMvGmnm9VZiIKKBUCHsiL6+QihjUQP /Q9vK4MrTe08lrwOoc3CPRXu3duWwqSdIwn41tJTprkBefBZsP1sk+OddoOtd1cMyvBhRO /k7xo+zD+RXjLoTbDAYOvKpTYDWpBddiuZVPzkk+TYikcDHEMxXfxK3pZDFSu/ImVbAqr4 vJ8jl+z2YVdtLIWIS77GtJwCTdKd00Vgyp4KdldvkGWrjAYnlIT5804yJzUZkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=58f49b7da7da50d1ea66b5d810a5e8769b5319f4 commit 58f49b7da7da50d1ea66b5d810a5e8769b5319f4 Author: Mark Johnston AuthorDate: 2022-01-20 13:23:38 +0000 Commit: Mark Johnston CommitDate: 2022-05-05 16:08:54 +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 (cherry picked from commit c3196306f092e46008d5ffa626fbafe1f8a94848) --- 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;