From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A952EB64DD for ; Tue, 25 Jul 2023 21:38:57 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AA5D386871; Tue, 25 Jul 2023 23:38:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="BOgTWKNW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8716086777; Tue, 25 Jul 2023 23:37:13 +0200 (CEST) Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B7250867F0 for ; Tue, 25 Jul 2023 23:36:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd32.google.com with SMTP id ca18e2360f4ac-783546553ddso220073039f.0 for ; Tue, 25 Jul 2023 14:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1690321012; x=1690925812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MbF6wVO8ciRrQrYcahgP4aaa8HGopSKjAtcMcFewtos=; b=BOgTWKNWr96Wwm56lZTyDMX3943M8dj4bLkMgrbaN8MAdB0dLv64HpRR4dt+0Y5U3k DjhmLwQcZk+Oqh/ZjJ+no/bUhL/kxxHfpp/XBB7+0fz8lxSzKws8W2X51nkxkS67HlZz 17+VVZUeRhBD52/9RB5DFvsPPSOUDzLXD2azE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690321012; x=1690925812; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MbF6wVO8ciRrQrYcahgP4aaa8HGopSKjAtcMcFewtos=; b=BvtdkK0ThO0jw7aamzFo92VFGYfNM6nnkkOPd2ZiK2Y99HG9p0+dPy8CnEgfAnVAKj A9eTM9mVLvi/JC0dixgQlX8NpF2FfgScxPmJ9BpPg6Ow3bpNNeS7cIjCfodtLmqfREMr 1z34UDtN/BBNRPDATd4qA8M7vvnIFzniTHv6QOO2pBKPsSMJj0ZAnKBNAYsp6o8LHwHx 24/49Lms7YaKJYtECnm0g49+6dTmLQEjBGTU06nnTYOJFcboT4LMsBpCDtZmRYo6jown sgSFnLPhCpQ9fSuEUATKQEtCbSvToDsQTblbGIDCaAFl3OqEEIZrupWSzwasHkqq355b JEYA== X-Gm-Message-State: ABy/qLaQRXumNxx/MjQlbd74fRGS1jwjlawEcIQA6W/XYkb3m6p5HjTr /7M/sxz/CXNCl2kYzUIwFOwrwzK2fiH0Zgv9vGI= X-Google-Smtp-Source: APBJJlFlHcUwkVoGV7aO/dp+SeSxkKv6Uq60KZ7ZaFS31FhA2GPo4rJifaXF6YRvqFmpcy9ARHW+tw== X-Received: by 2002:a05:6e02:1522:b0:348:c8a8:1ba0 with SMTP id i2-20020a056e02152200b00348c8a81ba0mr298553ilu.10.1690321012205; Tue, 25 Jul 2023 14:36:52 -0700 (PDT) Received: from kea.bld.corp.google.com ([2620:15c:183:200:ce78:3dad:1309:8d43]) by smtp.gmail.com with ESMTPSA id ep18-20020a0566384e1200b0042b2d43ee3fsm3891987jab.82.2023.07.25.14.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 14:36:51 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Ilias Apalodimas , Tom Rini , Julius Werner , Dan Handley , Jose Marinho , Simon Glass , Bin Meng , Nikhil M Jain Subject: [PATCH 08/14] bloblist: Change the checksum algorithm Date: Tue, 25 Jul 2023 15:36:20 -0600 Message-ID: <20230725213634.255345-9-sjg@chromium.org> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog In-Reply-To: <20230725213634.255345-1-sjg@chromium.org> References: <20230725213634.255345-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Use a sinple 8-bit checksum for bloblist, as specified by the spec version 0.9 Signed-off-by: Simon Glass --- common/bloblist.c | 14 ++++++++------ include/bloblist.h | 5 ++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/bloblist.c b/common/bloblist.c index 96b82fe625c..77892582b90 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -308,14 +309,15 @@ int bloblist_resize(uint tag, int new_size) static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr) { struct bloblist_rec *rec; - u32 chksum; + u8 chksum; - chksum = crc32(0, (unsigned char *)hdr, - offsetof(struct bloblist_hdr, chksum)); + chksum = table_compute_checksum(hdr, hdr->hdr_size); + chksum += hdr->chksum; foreach_rec(rec, hdr) { - chksum = crc32(chksum, (void *)rec, rec_hdr_size(rec)); - chksum = crc32(chksum, (void *)rec + rec_hdr_size(rec), - rec->size); + chksum -= table_compute_checksum((void *)rec, + rec_hdr_size(rec)); + chksum -= table_compute_checksum((void *)rec + + rec_hdr_size(rec), rec->size); } return chksum; diff --git a/include/bloblist.h b/include/bloblist.h index 6592ea75403..ee3644878b2 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -156,11 +156,10 @@ enum bloblist_tag_t { * @alloced: Total size allocated so far for this bloblist. This starts out as * sizeof(bloblist_hdr) since we need at least that much space to store a * valid bloblist - * @chksum: CRC32 for the entire bloblist allocated area. Since any of the + * @chksum: checksum for the entire bloblist allocated area. Since any of the * blobs can be altered after being created, this checksum is only valid * when the bloblist is finalised before jumping to the next stage of boot. - * Note that chksum is last to make it easier to exclude it from the - * checksum calculation. + * This is the value needed to make all checksummed bytes sum to 0 */ struct bloblist_hdr { u32 magic; -- 2.41.0.487.g6d72f3e995-goog