From nobody Mon Oct 03 23:11:14 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 4MhGmL5tWZz4V1Gx; Mon, 3 Oct 2022 23:11:14 +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 4MhGmL5Ntxz3PNX; Mon, 3 Oct 2022 23:11:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664838674; 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=ZHipYwVDYLwbBQLoghybyLNfAorZyspfnTbPm/FITIk=; b=ARCdKYNx06iO0NZSFPPVZhx3lRIZuZsCLLnxJMlmmvqdWteWI1tK8t/IZnE8IT1QzXuF4P yvqK1lJokPGu2QYOEh+zCcyM6IBJsYLnCc4etVc6r3Nb1vQ11dIi2I331KApnNkB7PwXPD F2jo6mNho9OIKdRWVJ2BXQAGEChP4/gV5zDVra3CREorrHRVUq+cVAema5RJZJX5SQE8RV GXLp1bmOVQrrsITsWO5Rd2LDk/Gd30Ex0ZCTNFIKtz9k+aByU1p+GUBmdVpIa9SKFAtmDA nzeMy0NhmmdJq46IRYSYwXByelTm8KCXUR0MAS4qJG1fpRim4JOXVl1HxUSJgg== 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 4MhGmL4K5VzMVf; Mon, 3 Oct 2022 23:11:14 +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 293NBEgV065433; Mon, 3 Oct 2022 23:11:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 293NBEsI065432; Mon, 3 Oct 2022 23:11:14 GMT (envelope-from git) Date: Mon, 3 Oct 2022 23:11:14 GMT Message-Id: <202210032311.293NBEsI065432@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: e0df0dce71d8 - main - powerpc_nvram: Fix a bug in the adler32 checksum. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e0df0dce71d86796195502b923243bb6bacdcdc2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664838674; 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=ZHipYwVDYLwbBQLoghybyLNfAorZyspfnTbPm/FITIk=; b=ShYb+iKy4mVAIad+8jXOWAlMIRtikPzLMAHyHuO6kLARhoBIOvqol1qXp/gnRM5mzeBMB1 k4DCgRFZLjDsNALYg4G4wiAAJS/WunQNyq25H/dNaVgV99JIgYe2AT/8ssXylxQP5mrKg9 pKQTCj5GQADIiVVX2/tmhT6aO7vyl5tDVASm9qeBx5qE7uPCSqP3XH+AeWHtJYHz4Yp9PT 2SzVeKpggIaA/1a/W1u6JwrNoCifUjVHh/fVS1RH6sS3IIhGwgGeyEc4L4HmvCc6sApYDd KjQfGzSKmMb11Apqr4f14mojmEAlACnRgwkBf0y6gbVxMqnnXqSJsnEeD4kqrw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664838674; a=rsa-sha256; cv=none; b=v2BmNt0VyP3sisKDCsLzcRLhX0JQSxD31lMfs0ALYDG/H8FvpPcwrSHfcYDfVQlCvzn7FV exGjLa+9eoEG+RA3iio8XTRcFWL+2UL4qRmfIWldyrQnwtI6HX+/vdXgchkLrvxG2CxQkR iq+SJDqPSVOXdyshxEFo22FScAdPE6TuZ6URqowvWmJfvX4562SsK3jYwCh414hcKWUyW7 qs1bZx9kBMMFTNRZoL0FQBFPWbRcoKzpu2t+R8YsEVpyWhmyTjTW/gO6Q5jcO0h3nc4s4N wA6E3F5kqjcUoplT2n5g+tqQderH3MKZGe9F0yzCGdDLaXR4QLlwcV9gAzOYDQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e0df0dce71d86796195502b923243bb6bacdcdc2 commit e0df0dce71d86796195502b923243bb6bacdcdc2 Author: John Baldwin AuthorDate: 2022-10-03 23:10:41 +0000 Commit: John Baldwin CommitDate: 2022-10-03 23:10:41 +0000 powerpc_nvram: Fix a bug in the adler32 checksum. The Adler32 digest consists of two 16-bit words whose values are calculated modulo 65521 (largest prime < 2^16). To avoid two division instructions per byte, this version copies an optimization found in zlib which defers the modulus until close to the point that the intermediate sums can overflow 2^32. (zlib uses NMAX == 5552 for this, this version uses 5000) The bug is that in the deferred modulus case, the modulus was only applied to the high word (and twice at that) but not to the low word. The fix is to apply it to both words. Reviewed by: jhibbits Reported by: Miod Vallat Differential Revision: https://reviews.freebsd.org/D36798 --- sys/dev/powermac_nvram/powermac_nvram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/powermac_nvram/powermac_nvram.c b/sys/dev/powermac_nvram/powermac_nvram.c index 247d35264441..e201a734ad1f 100644 --- a/sys/dev/powermac_nvram/powermac_nvram.c +++ b/sys/dev/powermac_nvram/powermac_nvram.c @@ -360,7 +360,7 @@ adler_checksum(uint8_t *data, int len) high = 0; for (i = 0; i < len; i++) { if ((i % 5000) == 0) { - high %= 65521UL; + low %= 65521UL; high %= 65521UL; } low += data[i];