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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65B39C433F5 for ; Tue, 5 Oct 2021 18:35:17 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AF034611C3 for ; Tue, 5 Oct 2021 18:35:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AF034611C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 46E4682BC7; Tue, 5 Oct 2021 20:35:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gtvrRMiZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6768182B68; Tue, 5 Oct 2021 20:35:07 +0200 (CEST) Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) (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 4EF3782D1C for ; Tue, 5 Oct 2021 20:35:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-ot1-x32c.google.com with SMTP id l16-20020a9d6a90000000b0053b71f7dc83so26036otq.7 for ; Tue, 05 Oct 2021 11:35:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5B36En8jisXaCAA7ARIQ/+afWrnrsMlig68dUB6jPfQ=; b=gtvrRMiZs/CNYMnnes4T8zdD8wKXoAg5evVEliMF2ac4STbKo4RqBvqpfUbEAUUtFd JciWpFfGveqr1AE6AsocP7F0G7UJEkYG9KiidEPP2I9eMnOTB15MI7kEhA4rl/2IbjYW 5oUU4RapYGcuOkdU0xQ6sf+ih4jiqaWHydJ8vaC/7uXI+5OO7m/mI5kirPWylPKihnDX +9h5TCFRxM7c7tY3/1q5gpczFddrgbt442vg3n9iEg15UewnLetF99em2YKuu/JS5J1Q q7G9bKg+B6IZCLGOxgsIMIxtA6RoktHmTsEWeZalat+y5H3QPCPB/6U9q00KGHe/xHZq Ponw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5B36En8jisXaCAA7ARIQ/+afWrnrsMlig68dUB6jPfQ=; b=ZfXdW/PiAwJ4kkcpVMhzoQ4dO6A+aKPSbAoc+EndpgJYZcrqsJMz2SiPG1O8Y4Wbs0 bA9v5TPaUBOmDjW65hmN6n3DnAxISL/LG2YBe7Eh4ossEboNSaemSgb1rrZn+iz5MHAL ivEMIhJ5bBMNeCzZS6deVK5kaKuTIn/AIfUJS4AMm7F5m31FENkNCOpf4/oP75GzACBr ItuhcLaPKDiUFYVBqzYBlhEr5SWxaHhh3OMCRshVmN9kzw3WcVSvv2DLC8MLUcycX1da EXi3qFJYLWTk3B4pWa+dANHTEdSlVx78128erlo2DtSnLK6YV+V2QAKAjFwXy+W+1zL0 tq0w== X-Gm-Message-State: AOAM533pnAkDyUHRIJEWomLLvk3prolvswdoBqe8KFhHWKu95w2qYfRW U60oXAvWddDGvYp2DZS/kaA= X-Google-Smtp-Source: ABdhPJy5aTBen0Rj7ZYOIa6loyl0qxPTfTGn6+PVdSdqgjjwVCFLfBJE3OgF/Tqj/oXzJcnsHMG0mg== X-Received: by 2002:a05:6830:1644:: with SMTP id h4mr14946103otr.199.1633458899852; Tue, 05 Oct 2021 11:34:59 -0700 (PDT) Received: from nuclearis3.gtech (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id y14sm2279354otk.1.2021.10.05.11.34.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Oct 2021 11:34:59 -0700 (PDT) Subject: Re: [PATCH v5 11/29] image: Use the correct checks for CRC32 To: Simon Glass , U-Boot Mailing List Cc: Andre Przywara , Rasmus Villemoes , Robert Marko , Masahiro Yamada , Tom Rini , Joe Hershberger , Marek Vasut References: <20210926014342.127913-1-sjg@chromium.org> <20210925194327.v5.11.I5ba26e911d0ffff8af74ec113d11a5421b0c009f@changeid> From: "Alex G." Message-ID: <84560f5e-eb67-edcb-8f96-19aa990a6bbd@gmail.com> Date: Tue, 5 Oct 2021 13:34:58 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210925194327.v5.11.I5ba26e911d0ffff8af74ec113d11a5421b0c009f@changeid> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean On 9/25/21 8:43 PM, Simon Glass wrote: > Add a host Kconfig for CRC32. With this we can use CONFIG_IS_ENABLED(CRC32) > directly in the host build, so drop the unnecessary indirection. > > Add a few more conditions to SPL_CRC32 to avoid build failures as well as > TPL_CRC32. Also update hash.c to make crc32 optional and to actually take > notice of SPL_CRC32. > > Signed-off-by: Simon Glass I'm not entirely convinced, but it does make CRC32 more consistent with other hashes. Reviewed-by: Alexandru Gagniuc > --- > > Changes in v5: > - Rebase to next > - Use TOOLS_ instead of HOST_ > > common/hash.c | 13 ++++++++----- > common/spl/Kconfig | 13 ++++++++++++- > lib/Kconfig | 5 +++++ > lib/Makefile | 4 +--- > tools/Kconfig | 5 +++++ > 5 files changed, 31 insertions(+), 9 deletions(-) > > diff --git a/common/hash.c b/common/hash.c > index e92f9a9594f..b4b01c193b6 100644 > --- a/common/hash.c > +++ b/common/hash.c > @@ -178,7 +178,7 @@ static int hash_finish_crc16_ccitt(struct hash_algo *algo, void *ctx, > return 0; > } > > -static int hash_init_crc32(struct hash_algo *algo, void **ctxp) > +static int __maybe_unused hash_init_crc32(struct hash_algo *algo, void **ctxp) > { > uint32_t *ctx = malloc(sizeof(uint32_t)); > *ctx = 0; > @@ -186,15 +186,16 @@ static int hash_init_crc32(struct hash_algo *algo, void **ctxp) > return 0; > } > > -static int hash_update_crc32(struct hash_algo *algo, void *ctx, > - const void *buf, unsigned int size, int is_last) > +static int __maybe_unused hash_update_crc32(struct hash_algo *algo, void *ctx, > + const void *buf, unsigned int size, > + int is_last) > { > *((uint32_t *)ctx) = crc32(*((uint32_t *)ctx), buf, size); > return 0; > } > > -static int hash_finish_crc32(struct hash_algo *algo, void *ctx, void *dest_buf, > - int size) > +static int __maybe_unused hash_finish_crc32(struct hash_algo *algo, void *ctx, > + void *dest_buf, int size) > { > if (size < algo->digest_size) > return -1; > @@ -311,6 +312,7 @@ static struct hash_algo hash_algo[] = { > .hash_update = hash_update_crc16_ccitt, > .hash_finish = hash_finish_crc16_ccitt, > }, > +#if CONFIG_IS_ENABLED(CRC32) > { > .name = "crc32", > .digest_size = 4, > @@ -320,6 +322,7 @@ static struct hash_algo hash_algo[] = { > .hash_update = hash_update_crc32, > .hash_finish = hash_finish_crc32, > }, > +#endif > }; > > /* Try to minimize code size for boards that don't want much hashing */ > diff --git a/common/spl/Kconfig b/common/spl/Kconfig > index 34f6fc2cfad..91bb6c89fb4 100644 > --- a/common/spl/Kconfig > +++ b/common/spl/Kconfig > @@ -419,7 +419,8 @@ config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION > > config SPL_CRC32 > bool "Support CRC32" > - default y if SPL_LEGACY_IMAGE_SUPPORT > + default y if SPL_LEGACY_IMAGE_SUPPORT || SPL_EFI_PARTITION > + default y if SPL_ENV_SUPPORT || TPL_BLOBLIST > help > Enable this to support CRC32 in uImages or FIT images within SPL. > This is a 32-bit checksum value that can be used to verify images. > @@ -1419,6 +1420,16 @@ config TPL_BOOTROM_SUPPORT > BOOT_DEVICE_BOOTROM (or fall-through to the next boot device in the > boot device list, if not implemented for a given board) > > +config TPL_CRC32 > + bool "Support CRC32 in TPL" > + default y if TPL_ENV_SUPPORT || TPL_BLOBLIST > + help > + Enable this to support CRC32 in uImages or FIT images within SPL. > + This is a 32-bit checksum value that can be used to verify images. > + For FIT images, this is the least secure type of checksum, suitable > + for detected accidental image corruption. For secure applications you > + should consider SHA1 or SHA256. > + > config TPL_DRIVERS_MISC > bool "Support misc drivers in TPL" > help > diff --git a/lib/Kconfig b/lib/Kconfig > index 64765acfa61..70bf8e7a464 100644 > --- a/lib/Kconfig > +++ b/lib/Kconfig > @@ -496,6 +496,11 @@ config SPL_MD5 > security applications, but it can be useful for providing a quick > checksum of a block of data. > > +config CRC32 > + def_bool y > + help > + Enables CRC32 support in U-Boot. This is normally required. > + > config CRC32C > bool > > diff --git a/lib/Makefile b/lib/Makefile > index 9c0373e2955..c523bb74119 100644 > --- a/lib/Makefile > +++ b/lib/Makefile > @@ -99,9 +99,7 @@ obj-y += display_options.o > CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='"$(BUILD_TAG)"') > obj-$(CONFIG_BCH) += bch.o > obj-$(CONFIG_MMC_SPI) += crc7.o > -#ifndef CONFIG_TPL_BUILD > -obj-y += crc32.o > -#endif > +obj-$(CONFIG_$(SPL_TPL_)CRC32) += crc32.o > obj-$(CONFIG_CRC32C) += crc32c.o > obj-y += ctype.o > obj-y += div64.o > diff --git a/tools/Kconfig b/tools/Kconfig > index 8685c800f93..91ce8ae3e51 100644 > --- a/tools/Kconfig > +++ b/tools/Kconfig > @@ -9,6 +9,11 @@ config MKIMAGE_DTC_PATH > some cases the system dtc may not support all required features > and the path to a different version should be given here. > > +config TOOLS_CRC32 > + def_bool y > + help > + Enable CRC32 support in the tools builds > + > config TOOLS_LIBCRYPTO > bool "Use OpenSSL's libcrypto library for host tools" > default y >