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 24BD5C433EF for ; Sun, 26 Sep 2021 01:49:07 +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 9B16E60184 for ; Sun, 26 Sep 2021 01:49:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9B16E60184 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org 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 D294383621; Sun, 26 Sep 2021 03:47:44 +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="cgiOSgUk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9C96F83571; Sun, 26 Sep 2021 03:44:42 +0200 (CEST) Received: from mail-oo1-xc34.google.com (mail-oo1-xc34.google.com [IPv6:2607:f8b0:4864:20::c34]) (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 88B1E835CB for ; Sun, 26 Sep 2021 03:44:02 +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-oo1-xc34.google.com with SMTP id a17-20020a4a6851000000b002b59bfbf669so659249oof.9 for ; Sat, 25 Sep 2021 18:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/manz/l/1X8VHS+7XqGP3GDq7cEP+W5Zfj73Vs+5qXA=; b=cgiOSgUkTC0A3UjPQH9yVTDWvbxPgsKnrVNr1YG2tPDn9ZfvsPuHgivsz5x5N3Tk0P NchbuDUHuy++PM9QW9euY3zNozm+1RBlBGzgFbdiXImlot+1T9sulO6QAhobolfWndeW M5EfaBwDm8SzNlCR3LMdMfSje8E9LZ52xYR0M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/manz/l/1X8VHS+7XqGP3GDq7cEP+W5Zfj73Vs+5qXA=; b=c39SGQ6JPOQ9hThqohJlI3E1U+Jn0W9M3oeBDp+sBbSDS+ycniR+NoBX07moLSxEBT lC4M/igGYN/oLwMBvDkyAEprfANwviJymkiHrlnv4SxgTtBNPs+Ywnf2FJI8FDTyWVDC LIZc1w5enJ5BmogOOi64OXSvTMj/SOW6WT9F0IIwyv8+R0WY3nRzQK+jWOh1mJZzfZ/o IHoWM9P83+chGeUbITdy0vibKq5WHZ3xaIQ+LMJw7fWYfhvL1yUp8qhxG43lj3AxdRu+ +fzh13jIYZFWY+t8+WUCYG78rEtwQG/BSz8ifL3oxhTY19rLe2vMTYpoytEjkU/NrLwu Y2bw== X-Gm-Message-State: AOAM532Zqz1GZ2f/4Tw52C74NPLTaD19F3MptgAZj5NTl5hdkzkDRXHr gydXWaJx7OQ8RFOjQ5iiZsgGIcoqGacw5A== X-Google-Smtp-Source: ABdhPJzfSklMx1y6Raq+eI/TYD+U1TD5y/w7zrDTaV6NgqO5JXsuvLQ0KSz30ieSdJsamJKZys3muw== X-Received: by 2002:a4a:e9e4:: with SMTP id w4mr14970503ooc.13.1632620640748; Sat, 25 Sep 2021 18:44:00 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id c18sm330378otr.72.2021.09.25.18.43.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Sep 2021 18:44:00 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alexandru Gagniuc , Andre Przywara , Rasmus Villemoes , Robert Marko , Masahiro Yamada , Tom Rini , Simon Glass , Joe Hershberger , Marek Vasut Subject: [PATCH v5 11/29] image: Use the correct checks for CRC32 Date: Sat, 25 Sep 2021 19:43:24 -0600 Message-Id: <20210925194327.v5.11.I5ba26e911d0ffff8af74ec113d11a5421b0c009f@changeid> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog In-Reply-To: <20210926014342.127913-1-sjg@chromium.org> References: <20210926014342.127913-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 --- 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 -- 2.33.0.685.g46640cef36-goog