From patchwork Fri Nov 3 14:34:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 740665 Delivered-To: patch@linaro.org Received: by 2002:a5d:538f:0:b0:32d:baff:b0ca with SMTP id d15csp1409405wrv; Fri, 3 Nov 2023 07:34:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqC4u98ya8g94nSBbBzkI3mFUjhq2dnhhDE9LosTaUl/DaGNtrGFx5HckvS/heBt7FaQzC X-Received: by 2002:a5d:47ac:0:b0:32f:86e7:9bef with SMTP id 12-20020a5d47ac000000b0032f86e79befmr3506112wrb.8.1699022079133; Fri, 03 Nov 2023 07:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022079; cv=none; d=google.com; s=arc-20160816; b=Z/OJY+gxuMXwDhYDT/VrTZ26CXF8ESRqwGuPKFm4a1D/9hOyeN1oNJlrc6ZAV9rW8/ Lmg41rsMypOszVF2OvAdwMgwow7sHbG0myP1i6n7YZkQxSEnIY6TkcPHIBWQthIW90g5 8ALOrI0sl/kTFocYYix7QwVD2CJds8HFhyNAy54yCApmRySaC3Tn3Kfn/mMK7ySoUzdU A8sAsZGBnPNWdG6Ov+OCLvjlbBQyAmfU8JoNn0xOFR3b00ttRDsTipUe+KTsM6gyy8aH knJf1pA+UNt2WSwnyqze6xWbOHs/lIWg4TI0DI1Re5uouQRT2RX5qNnedEKJI0NROjcf WmKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=i8AT4yHLx7myQHaXQEVevfvoarPJSKGzHdi2ADx9GYQ=; fh=SxtJ/epRulitkzJkf4rsOrPQu0de4WW7H8uG7cm8Fx0=; b=azxDXjMqpIQ7TL3r5yl2exf6ANIWU/X+JNs+hhPkRLGcF6Sq5dh3cm8MNvPVF1vmCJ GwTSnd4bZDbNwXuVwCDZUqd/6814qNmsOl7YxTlw0SVM7fmyVS96HbxI3aG+47zi0Xtu +rexl2txRrpbK0LIXJVuBsRLkuEGb+nwvxE4g8juwLp/sU3wbD/TbzlIFdLQKZ/pm6GC 2nwCxrTNMXfmkdXiw6F+ecc/jaIowuP4aNgDgpZH8428F6qefqNOduX9Pg+AsL4711Rj 8aoSzU74Xf5gHpeNByD+CY/u4TJqW3fUel2uF2IeMUlV0AFCU2EyNw1KtoWEZfiMMZng lppQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D46Y1fbu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id t4-20020a5d5344000000b0032d848207b5si1331045wrv.416.2023.11.03.07.34.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=D46Y1fbu; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BACF1871A2; Fri, 3 Nov 2023 15:34:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org 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=linaro.org header.i=@linaro.org header.b="D46Y1fbu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 332FC87142; Fri, 3 Nov 2023 15:34:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) (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 605AA87142 for ; Fri, 3 Nov 2023 15:34:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=loic.poulain@linaro.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40839807e82so13561965e9.0 for ; Fri, 03 Nov 2023 07:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699022072; x=1699626872; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=i8AT4yHLx7myQHaXQEVevfvoarPJSKGzHdi2ADx9GYQ=; b=D46Y1fbuV9j8PfnVmtukz1Xy7UAvX7ZsGIefOhzrp1hD0Kpfmy6KUVLJ98GCC7t83+ u8zVOA1X7BQyNIT1omc/Y+R6fcIfYFb8SZ54Db68fGTWlbp8rT570SML/nDrpWuGfetI G8Dy09hPZbVlpPplkdW8kWCAMpRPuxJy1csRYEePv7dkdK1W30opb2StYmXbHV8GLmEx FE0SeIajeZsaORIk54pHXvunFtW3Pc8DXhJqRKx3eY/jLhhuYYNYg93sJpWO9gHlaGVi MZ4DWMfJq5P0WKnX58iShQEVmv5J+n7LV4OSu63ZwvLs5pN2/cKhNmgtA+apRUAJqTK4 +/pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699022072; x=1699626872; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=i8AT4yHLx7myQHaXQEVevfvoarPJSKGzHdi2ADx9GYQ=; b=ZuKdVHXKAvnBJVz5GDXl4kExPu4ilVf7SWE8yGsg94DW+T2jquGvsq45Kru0M/dQdv zW9yr0z5mpTjZ9honDtJ/vl8v39fZaKtDztK3jXKiVEvcAMurgsPC5oTUfkAZJDabqXb PJ/5Ylc7IhBrS2EeaPgqMEg0WqKPxYQEfVVcq53c0tA/iHSWmmhShc4xuEKB5eTgp5do /Cucq3btMqG1I70S7gG0oRz0TzGbOlylhoJTzKDC1K3RPD76V9SaCy1mQys8kq3Em9Ad T1ex1PHFG+Je/5urb22v6HDAMaoPvoc1fACV6Mr5tmLIsT9CK//IfPpCnS7B9PLxSGYF cGjQ== X-Gm-Message-State: AOJu0Yzr5+ZxKbxgawFfzv+uJMCtTbZdQBP8OSIm2aL0cwPiJ5oQWrP8 hdoT6ASSc9y5sjBwNSpYGtRGpQ== X-Received: by 2002:a05:600c:21cf:b0:401:b92f:eec5 with SMTP id x15-20020a05600c21cf00b00401b92feec5mr3047168wmj.9.1699022071745; Fri, 03 Nov 2023 07:34:31 -0700 (PDT) Received: from loic-ThinkPad-T470p.. ([2a01:e0a:82c:5f0:bd3f:e301:dcee:2fff]) by smtp.gmail.com with ESMTPSA id 12-20020a05600c020c00b004063ea92492sm2683598wmi.22.2023.11.03.07.34.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:34:30 -0700 (PDT) From: Loic Poulain To: sjg@chromium.org, marex@denx.de Cc: u-boot@lists.denx.de, abbaraju.manojsai@amarulasolutions.com, seanga2@gmail.com, Loic Poulain Subject: [PATCH 1/3] spl: fit: Discard decompression if not supported Date: Fri, 3 Nov 2023 15:34:24 +0100 Message-Id: <20231103143426.3643712-1-loic.poulain@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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 And simplify further decompression testing. Signed-off-by: Loic Poulain --- common/spl/spl_fit.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 70d8d5942d..1d42cb1d10 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -208,6 +208,20 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size, return (data_size + info->bl_len - 1) / info->bl_len; } +static inline bool spl_fit_decompression_supported(uint8_t comp) +{ + switch (comp) { + case IH_COMP_GZIP: + return IS_ENABLED(CONFIG_SPL_GZIP); + case IH_COMP_LZMA: + return IS_ENABLED(CONFIG_SPL_LZMA); + case IH_COMP_NONE: + return true; + } + + return false; +} + /** * load_simple_fit(): load the image described in a certain FIT node * @info: points to information about the device to load data from @@ -235,7 +249,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector, void *src; ulong overhead; int nr_sectors; - uint8_t image_comp = -1, type = -1; + uint8_t image_comp, type = -1; const void *data; const void *fit = ctx->fit; bool external_data = false; @@ -248,9 +262,11 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector, debug("%s ", genimg_get_type_name(type)); } - if (spl_decompression_enabled()) { - fit_image_get_comp(fit, node, &image_comp); - debug("%s ", genimg_get_comp_name(image_comp)); + fit_image_get_comp(fit, node, &image_comp); + if (!spl_fit_decompression_supported(image_comp)) { + debug("Discard unsupported compression %s ", + genimg_get_comp_name(image_comp)); + image_comp = IH_COMP_NONE; } if (fit_image_get_load(fit, node, &load_addr)) { @@ -283,8 +299,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector, return 0; } - if (spl_decompression_enabled() && - (image_comp == IH_COMP_GZIP || image_comp == IH_COMP_LZMA)) + if (image_comp != IH_COMP_NONE) src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len); else src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len);