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 158B9C433EF for ; Sun, 26 Sep 2021 01:44:03 +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 B940D6108B for ; Sun, 26 Sep 2021 01:44:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B940D6108B 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 CBD2F835AB; Sun, 26 Sep 2021 03:43: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=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="F55G9nVc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 681A5835A9; Sun, 26 Sep 2021 03:43:55 +0200 (CEST) Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) (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 72C8183538 for ; Sun, 26 Sep 2021 03:43:51 +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-oi1-x22c.google.com with SMTP id w19so20273332oik.10 for ; Sat, 25 Sep 2021 18:43:51 -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:mime-version :content-transfer-encoding; bh=K7+r8FqIUowQQtCG+l3gEua4nOgHlLQzX61vfUNxojY=; b=F55G9nVcx2WMJ6unWmdE34VufymIIxf38/DZ3W7QYt0Ylg/OW2NsIGMF1YOEeOMSyR 7rhA/AlykpEM75bUiLe7FxF9F2AQNP73DVYuwq2b4yAwI/88Sr78exerLBDIzoojM1fb bNBKt4DDjLwETsqFX3wn9g4gM2YtkXLSOzjzc= 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:mime-version :content-transfer-encoding; bh=K7+r8FqIUowQQtCG+l3gEua4nOgHlLQzX61vfUNxojY=; b=ZO67xaCXRyelr2rd68NSGUnntday597TVf4u9yvjap5t1lV/MKY4R0oKPt23/+C3vv 52d60x4K2iKnDrZwJW0HNodxw+rE/6Lha/TRKmbIA9N1UQnTDBD/+cpFnT99YcZUD6wU MFVIwihcR+pTmqtlxsaf3LafnlgV7PtpSRgvHo5PrTkgzYhY+hWZ6myS2fEQ8VEL34DN 459iEvW1kBQoC9sCfl+U3B+9qMNrNlTlFKAA9bxJK9REM+iVRzVv5j8MnA10NwWDTUCz i2wDePpOb6vluMB84/lAjQDhOwthCiLn4wV4vhyVmD+ln9qKnRRoE/dejoR4dpiu5CIm IIuw== X-Gm-Message-State: AOAM531lviRDlTBZqHYaq7x3HoKxEfFck6UyZWG9Wex6hk87HBESca1+ qUrwkJlSWrdlWxvF+uih7YpcVivN/CqZsA== X-Google-Smtp-Source: ABdhPJyZ+JiRqW3O3J7FxBnDjN5hQKwIKoTjNDuNLLINODEfsYexzR89o9DfWNELnhdTdIDzBm5IZA== X-Received: by 2002:a05:6808:2d2:: with SMTP id a18mr7116961oid.99.1632620629552; Sat, 25 Sep 2021 18:43:49 -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.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Sep 2021 18:43:48 -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 , Alexander Graf , Joe Hershberger , Marek Vasut , Masahiro Yamada Subject: [PATCH v5 00/29] image: Reduce #ifdefs and ad-hoc defines in image code (Part B) Date: Sat, 25 Sep 2021 19:43:13 -0600 Message-Id: <20210926014342.127913-1-sjg@chromium.org> X-Mailer: git-send-email 2.33.0.685.g46640cef36-goog 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 Much of the image-handling code predates the introduction of Kconfig and has quite a few #ifdefs in it. It also uses its own IMAGE_... defines to help reduce the #ifdefs, which is unnecessary now that we can use IS_ENABLED() et al. The image code is also where quite a bit of code is shared with the host tools. At present this uses a lot of checks of USE_HOSTCC. This series introduces more 'tools' Kconfig options and a way to use CONFIG_IS_ENABLED() to check them. This works in a similar way to SPL, so CONFIG_IS_ENABLED(FIT) will evaluate to true on the host build (USE_HOSTCC) if CONFIG_TOOLS_FIT is enabled. This allows quite a bit of clean-up of the image.h header file and many of the image C files. The 'tools' Kconfig options should help to solve a more general problem in that we mostly want the host tools to build with all features enabled, no matter which features the 'target' build actually uses. This is a pain to arrange at present, but with 'host' Kconfigs, we can just define them all to y. There are cases where the host tools do not have features which are present on the target, for example environment and physical addressing. To help with this, some of the core image code is split out into image-board.c and image-host.c files. Even with these changes, some #ifdefs remain (down from about 100 to about 40 in common/image*). But the code is somewhat easier to follow and there are fewer build paths. Note: The original version of this series met with resistance and resulted in another series that went in first. That did make some improvements but the fundamental problem of sharing code with tools remains. It seems like a good time to get this one in, before further refactoring happens. It was a significant effort to rebase this series on -next and I hope not to do it again. This series is available at u-boot-dm/host-working Changes in v5: - Add a new patch to rename host_build() to tools_build() - Add new patch to bring back SPL_ versions of SHA - Avoid preprocessor in a few more places - Drop I_WANT_MD5 - Drop changes to tools/Makefile since they already use TOOLS_ Kconfigs - Drop rd_load since it is not used - Fix up tools/Makefile to have the correct condition - Rebase to next - Update commit message - Update commit message to indicate that the code is in a separate file - Use TOOLS_ instead of HOST_ Changes in v2: - Add SPL_ Kconfigs also, since otherwise hashing algorithms drop from SPL - All patches rebased to -next - Consider selecting a raw FDT to be success - Correct comment about USE_HOSTCC being undefined in CONFIG_VAL() - Correct logic for the non-FIT case - Drop unnecessary setting of rd_len, etc. - Fix up comment to put an underscore after every CONFIG Simon Glass (29): compiler: Rename host_build() to tools_build() kconfig: Add tools support to CONFIG_IS_ENABLED() image: Add Kconfig options for FIT in the tools build spl: cypto: Bring back SPL_ versions of SHA hash: Use Kconfig to enable hashing in host tools and SPL hash: Drop some #ifdefs in hash.c image: Drop IMAGE_ENABLE_FIT image: Drop IMAGE_ENABLE_OF_LIBFDT image: Use Kconfig to enable CONFIG_FIT_VERBOSE on host image: Use Kconfig to enable FIT_RSASSA_PSS on host image: Use the correct checks for CRC32 image: Drop IMAGE_BOOT_GET_CMDLINE image: Drop IMAGE_OF_BOARD_SETUP image: Drop IMAGE_OF_SYSTEM_SETUP image: Drop IMAGE_ENABLE_IGNORE efi: Correct dependency on FIT_SIGNATURE image: Drop IMAGE_ENABLE_SIGN/VERIFY defines image: Drop IMAGE_ENABLE_EN/DECRYPT defines image: Tidy up fit_unsupported_reset() image: Drop unnecessary #ifdefs from image.h image: Drop #ifdefs for fit_print_contents() image: Drop most #ifdefs in image-board.c image: Reduce variable scope in boot_get_ramdisk() image: Split up boot_get_ramdisk() image: Remove #ifdefs from select_ramdisk() image: Remove some #ifdefs from image-fit and image-fit-sig image: Reduce variable scope in boot_get_fdt() image: Split up boot_get_fdt() image: Remove #ifdefs from select_fdt() arch/arc/lib/bootm.c | 2 +- arch/arm/lib/bootm.c | 4 +- arch/arm/mach-imx/hab.c | 2 +- arch/microblaze/lib/bootm.c | 2 +- arch/nds32/lib/bootm.c | 4 +- arch/riscv/lib/bootm.c | 4 +- board/synopsys/hsdk/hsdk.c | 2 +- common/Kconfig.boot | 10 + common/bootm.c | 14 +- common/bootm_os.c | 8 + common/hash.c | 108 +++++----- common/image-board.c | 359 +++++++++++++++++---------------- common/image-cipher.c | 6 +- common/image-fdt.c | 275 +++++++++++++------------ common/image-fit-sig.c | 7 +- common/image-fit.c | 36 ++-- common/image.c | 14 +- common/spl/Kconfig | 13 +- include/compiler.h | 5 +- include/fdt_support.h | 2 +- include/image.h | 127 ++---------- include/linux/kconfig.h | 13 +- include/u-boot/aes.h | 8 +- include/u-boot/hash-checksum.h | 5 +- include/u-boot/rsa.h | 2 - lib/Kconfig | 66 +++++- lib/Makefile | 4 +- lib/efi_loader/Kconfig | 2 +- lib/hash-checksum.c | 2 +- lib/lmb.c | 2 +- lib/rsa/rsa-sign.c | 5 +- lib/rsa/rsa-verify.c | 16 +- tools/Kconfig | 92 +++++++++ tools/Makefile | 2 +- tools/image-host.c | 6 +- 35 files changed, 675 insertions(+), 554 deletions(-) -- 2.33.0.685.g46640cef36-goog