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); From patchwork Fri Nov 3 14:34:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 740666 Delivered-To: patch@linaro.org Received: by 2002:a5d:538f:0:b0:32d:baff:b0ca with SMTP id d15csp1409495wrv; Fri, 3 Nov 2023 07:34:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGCb58rdOIBSabCtCa3uXUMUAtMvbUR4JYBLHeNdP+EVy+m7cJyQtcglLHBm5mc6pu1Ic/v X-Received: by 2002:ac2:5308:0:b0:500:a3be:1ab6 with SMTP id c8-20020ac25308000000b00500a3be1ab6mr16702852lfh.6.1699022089080; Fri, 03 Nov 2023 07:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022089; cv=none; d=google.com; s=arc-20160816; b=Sf90NxkdThW6FkC5ILcNc0/8k9kjDLXTsdAbknXY27+ML7iHwrICPXD0j6Zc2tDzyz qZttkGYWHbxFdK16sMOXfRRF05FYluA2pqZ4jSb0DOJMCaHkddZ3dcqn3QPrYYAP/sZ7 nVvX3ubxKkcqrP4fIrnARKweLV+isnww/QrmV6Zqhve5z1KSi72HMApcTPZqUpQSURwH Mnno6HP3d9bes7MmkdC1ax6EnsSJvPrrWfAnVdWFxVMy5k5dMF+mX+0A6R1O8Vp8nEP5 7Ed8qhoGmaLEKGRGpOBJLfF3IzpX1cLoFNNa5cHUxrJDvOpZUYHsIOe29BUcpr4rTTx3 +R/A== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cJhhyMenV7+iux6HdJl6SCGZhk9zr2Y8OMnHhWQG64E=; fh=SxtJ/epRulitkzJkf4rsOrPQu0de4WW7H8uG7cm8Fx0=; b=ZuD1FzLtojbBQyqd5HvsD3S2ePAC597NnkuOqPpyDIxVD1OYEwLix83Z9DcP99kRo0 bToB/OBiSc6uzJDCf4D5NLdUvclc09urar/Co0gfGZl9quqh0netgtzmTaNtrCFapqvF wyVGHPWNsKmv1pRSS34+8je0SpRoJs5K8k6QNAhAKvEdNyv2ibSXCiFPm1vNPghpCTMy 62mM0dOCmqMyWbhv8NoLRIVq5t9fCuTfY6hBfzGHFrAmcAqIJOEe9TUYHa47w2VfhCwy 57gi3npHPPZEB3K/d1cmcj+Nzw9NemoY50W+wyoSsQo+WjluXQFH9X16l+d+J7dseReD 2mVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J3Q1frg3; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id h9-20020a05600c314900b0040902c4fbb8si1564165wmo.81.2023.11.03.07.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:34:49 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J3Q1frg3; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 4F1E1871D7; Fri, 3 Nov 2023 15:34:40 +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="J3Q1frg3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E9FBF871F8; Fri, 3 Nov 2023 15:34:39 +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-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (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 47A57871BC for ; Fri, 3 Nov 2023 15:34:34 +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-x32b.google.com with SMTP id 5b1f17b1804b1-409299277bbso15340125e9.2 for ; Fri, 03 Nov 2023 07:34:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699022074; x=1699626874; darn=lists.denx.de; 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=cJhhyMenV7+iux6HdJl6SCGZhk9zr2Y8OMnHhWQG64E=; b=J3Q1frg3uwRI0h4O3lLQV6HHr0I4pTRRn3Dc1t1YCcuV3xkPCMHxNgCB6BkglGnELE Y6MkCRm8ostFVw2VOwWdTicaxrl//VEAO1jXgm7tK9f62cZ2WVQ/68Iletz2VgobFqGE aQtWNBBSYA+lrsgWBewyoauXJ36AfOfN2IBDKTVTGUcalvSeYpTfH3YX9t8bSjItdw6u jbwerhPk68wKui3dAQA513GTP7o7wncR0KiLuh80r+Em1To417dP8IiMrK8SzaoKL8ce C3biUHCfM08LkUDECQZj3qK3fUVO+7J2GG6gOuT70pKYgQE0V3WIBNnqgaGYG4GTgrxt FASw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699022074; x=1699626874; 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=cJhhyMenV7+iux6HdJl6SCGZhk9zr2Y8OMnHhWQG64E=; b=McOJx5KbpSq5E2wmhOnai5zQv6lvTvWpMaTsmur6eL7zeCsUiCN9BuFY+fNlPbcZLN b36EHQxRay1MXeuTEodtiZZRPy6H+LXAh0L8PPGqdNIenxC8dq3RfmxOPRnCVzyzZxri adoTjiyT3Yca10WHatwlI0bRfv2uv4ZkwoRJe6d4Oi7n8+ISCP/1kFxXjiQ8uVJsi9MD r6uoZxi+cwVThqItRBMK5xlYukKPNXUB6cika9FcVgxfozGM6JL+qA1JPbV7KBGHQcMW Z8jrjg1pMXbgoToPmpozj8BamU5SfWbgtlKKad5vh3I5YAJoHrMUKdjuqLs99rfIamZG Evgg== X-Gm-Message-State: AOJu0Yxldp+pTUapQQ+MWZB/ajcFlHA/j30MNE2LBguiFjha9gFqGjxY mB7LztPhY6Y6ph5spsAsCGUw3Q== X-Received: by 2002:a05:600c:4f92:b0:402:f55c:faee with SMTP id n18-20020a05600c4f9200b00402f55cfaeemr17245326wmq.26.1699022073657; Fri, 03 Nov 2023 07:34:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:34:33 -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 2/3] spl: fit: Add support for LZO compressed images Date: Fri, 3 Nov 2023 15:34:25 +0100 Message-Id: <20231103143426.3643712-2-loic.poulain@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231103143426.3643712-1-loic.poulain@linaro.org> References: <20231103143426.3643712-1-loic.poulain@linaro.org> 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 Signed-off-by: Loic Poulain --- common/spl/spl_fit.c | 10 ++++++++++ include/spl.h | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 1d42cb1d10..08428660b0 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -18,6 +18,7 @@ #include #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -215,6 +216,8 @@ static inline bool spl_fit_decompression_supported(uint8_t comp) return IS_ENABLED(CONFIG_SPL_GZIP); case IH_COMP_LZMA: return IS_ENABLED(CONFIG_SPL_LZMA); + case IH_COMP_LZO: + return IS_ENABLED(CONFIG_SPL_LZO); case IH_COMP_NONE: return true; } @@ -357,6 +360,13 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector, return -EIO; } length = loadEnd - CONFIG_SYS_LOAD_ADDR; + } else if (IS_ENABLED(CONFIG_SPL_LZO) && image_comp == IH_COMP_LZO) { + size = CONFIG_SYS_BOOTM_LEN; + if (lzop_decompress(src, length, load_ptr, &size)) { + puts("Uncompressing error\n"); + return -EIO; + } + length = size; } else { memcpy(load_ptr, src, length); } diff --git a/include/spl.h b/include/spl.h index 8ff20adc28..e07092372a 100644 --- a/include/spl.h +++ b/include/spl.h @@ -1016,6 +1016,8 @@ int spl_load_fit_image(struct spl_image_info *spl_image, */ static inline bool spl_decompression_enabled(void) { - return IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA); + return IS_ENABLED(CONFIG_SPL_GZIP) || IS_ENABLED(CONFIG_SPL_LZMA) || + IS_ENABLED(CONFIG_SPL_LZO); } + #endif From patchwork Fri Nov 3 14:34:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 740667 Delivered-To: patch@linaro.org Received: by 2002:a5d:538f:0:b0:32d:baff:b0ca with SMTP id d15csp1409600wrv; Fri, 3 Nov 2023 07:34:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwuPj1nr3Eo42Z8ipGyXmhLDm1p8n5g9y8qeGobXLzXliRtaUd9+gYQVCaThLv+Kww7yxy X-Received: by 2002:a05:600c:46cb:b0:408:54be:d961 with SMTP id q11-20020a05600c46cb00b0040854bed961mr18327267wmo.35.1699022099411; Fri, 03 Nov 2023 07:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699022099; cv=none; d=google.com; s=arc-20160816; b=sNkf0cdrRwvyRym+FN9FYwOtlcxUia9rnYyOtc3RjJ+z+QFn9joxg4pdmq08YTZa+4 qFQVgaByilrpFoiqAkMuLhiuRzRxsdV96fIw440OEv4j4Lyeq9qH255R4SMV2/0liwPD 4JDMY+WfOV6Ca5pqryRu8LaX4/99xfYbNjcYDl5y3INn8jyXjHVkQ70GZ+/TicZyxTMn W65EjzH0o9/Ie/a2OBTXTXeU2PRc7HC3Sxbmw8NW8ttPV37nwc2cdOB3sKqxiVCO+eWg dHetG+uFezJyOWCQV1Z+A8B7sxYpNGxRgfbpBJqCYZDKjEZYY0NhfyPtT6A/CukhPCUC 4Ang== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d1blHmjAjkOpfB5rtWBv7BqFpGVriQg1Lyul871M1W4=; fh=SxtJ/epRulitkzJkf4rsOrPQu0de4WW7H8uG7cm8Fx0=; b=AjLP8bOGfA7VYqZIwqAPX8BswcdqPdNFkzz1o8JkvmUaKMi0xuj4aA1nqepPftYNJ9 7o141SZBWsumtmPVKLWTn8r6R9TjvNy364Ev2h3XxaAwu2wl2ilAnQYINkvj1f3Ijtsx fyaXkLopyLGYzD7Sq2dBQSPTd3soW5xdkkGdLaOZPi9pjFTeZvh5PgXpzfeEMHbOn5lB 7TFNASM370WO+6SgfY22AXQcAdaOlK3/0DPpYq4cxGTakXgiS73mSxtwMHgihZxqp5ze EUb49w62fgrzSMFOTZsYR95CH8E8nLVK4v6tJlHpgparHSRXd2GN3SihMt09wX0KYa+5 iomg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zR6M2tlM; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 12-20020a05600c240c00b00404fbc95010si3301591wmp.85.2023.11.03.07.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:34:59 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zR6M2tlM; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 BF47D871CD; Fri, 3 Nov 2023 15:34:40 +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="zR6M2tlM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F1E8E871BC; Fri, 3 Nov 2023 15:34:39 +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-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) (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 293CC871E1 for ; Fri, 3 Nov 2023 15:34:36 +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-lf1-x12c.google.com with SMTP id 2adb3069b0e04-507a29c7eefso2645163e87.1 for ; Fri, 03 Nov 2023 07:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699022075; x=1699626875; darn=lists.denx.de; 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=d1blHmjAjkOpfB5rtWBv7BqFpGVriQg1Lyul871M1W4=; b=zR6M2tlMzQd8fqG+LPRioMEZ4gAWe0bBhY2bdHops45nkpCAQkswttDqavMgtb7gkv LjmpmlYDwad7AHwDTUreyK0B7dXavLCrnjzT4KN416w6nAVXpZbMLkUUsJ5vRqdUlXMe CXASTvCCrt621S7lMO3rZzbVzf5uIJ2WrIlQT7iqWCiTI+AQKHSLjH6aGhUx0LnmWji6 srVqY2BqIIe05a3rjr46GncPO8MmpQg2jlieHj7DC/nwDPyHrj1b3elwSnC3S/GPAXzT Gut3bL+CyHlvJhTqXFE20+C7kpIz22kHSN6mbbhYug3GhoC0rXm4rpZZrCqwEjHW5kk7 cu+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699022075; x=1699626875; 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=d1blHmjAjkOpfB5rtWBv7BqFpGVriQg1Lyul871M1W4=; b=GO00YPriL0+4Jw8zTUlyRzDs2cXnh0JzZ9QWMJEwaLPu2ndV7RxaRpX6y4ntzpigdj lfRx42WxDXWmEzHBQ++6N0yx66GUhYulj/3KtUNJLoLICuOlDqIhfS2U1v4BsHK+3QxV 7SJxMazPMNdybCe7JDoQbI7c09NZ+vuAVMRLgLua5RWIwWpKnu3HiPyqOk8nB986yata fACC9RG5xSoZOVwG7KjMlwlHou9oGQ1+vQtkgp6khS2+1THcWvirtAPhzaGPbanfozYU ykQDZvKqzQGMZuT386GRBQ7vrb7SyGnHmppTB3Ke5kbH88unmkb9rrQziii4cioshFn+ rGCw== X-Gm-Message-State: AOJu0Yxwox4MCfFal4jkkuhFa+iWqYTP2zSF+QHHWCp1I4Z6hIfWW30b 8mE8MfymQUexm9IcfgbIrkBIGg== X-Received: by 2002:ac2:4c3c:0:b0:509:44bc:8596 with SMTP id u28-20020ac24c3c000000b0050944bc8596mr4680469lfq.58.1699022075299; Fri, 03 Nov 2023 07:34:35 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 07:34:34 -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 3/3] spl: fit: Load compressed blob to heap buffer Date: Fri, 3 Nov 2023 15:34:26 +0100 Message-Id: <20231103143426.3643712-3-loic.poulain@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231103143426.3643712-1-loic.poulain@linaro.org> References: <20231103143426.3643712-1-loic.poulain@linaro.org> 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 CONFIG_SYS_LOAD_ADDR is usually configured as the address where the kernel should be loaded at. It can be problematic to use it as a generic temporary buffer for FIT compressed blobs. An example is when the image is a compressed kernel with load address equal to CONFIG_SYS_LOAD_ADDR, this causes (inplace) decompression to fail. Instead we can simply allocate a temporary buffer in the heap Signed-off-by: Loic Poulain --- common/spl/spl_fit.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 08428660b0..8a807db5ba 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -249,7 +249,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector, ulong size; ulong load_addr; void *load_ptr; - void *src; + void *src, *src_ptr; ulong overhead; int nr_sectors; uint8_t image_comp, type = -1; @@ -289,8 +289,6 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector, } if (external_data) { - void *src_ptr; - /* External data */ if (fit_image_get_data_size(fit, node, &len)) return -ENOENT; @@ -302,10 +300,13 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector, return 0; } - if (image_comp != IH_COMP_NONE) - src_ptr = map_sysmem(ALIGN(CONFIG_SYS_LOAD_ADDR, ARCH_DMA_MINALIGN), len); - else + if (image_comp != IH_COMP_NONE) { + src_ptr = malloc_cache_aligned(len + 2 * info->bl_len); + if (!src_ptr) + return -ENOMEM; + } else { src_ptr = map_sysmem(ALIGN(load_addr, ARCH_DMA_MINALIGN), len); + } length = len; overhead = get_aligned_image_overhead(info, offset); @@ -383,6 +384,9 @@ static int load_simple_fit(struct spl_load_info *info, ulong sector, image_info->entry_point = FDT_ERROR; } + if (external_data && image_comp != IH_COMP_NONE) + free(src_ptr); + return 0; }