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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B444CC43458 for ; Sun, 5 Jul 2026 19:42:07 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 40F3D846F8; Sun, 5 Jul 2026 21:42:06 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (4096-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.b="INB77Gfs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 176A4846F8; Sun, 5 Jul 2026 16:56:01 +0200 (CEST) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EE84B83314 for ; Sun, 5 Jul 2026 16:55:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=canonical.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=aristo.chen@canonical.com Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 75D1B3F1F4 for ; Sun, 5 Jul 2026 14:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20251003; t=1783263358; bh=O2pzYYWiHcShaqwLIbGpBClWrBJ5BZCcPxARsOq9X3Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=INB77Gfs7mhS+kGhvHJ2cMZbG08RN5xryqwkKxByYFzq8FukKid7PbXkxL+CT3xnF LLg7gPB+EaE9dAVEZFFEl9PgzivMvvhJYiSJbCypMkfvn7AZRTiKqfpo/Vv7lj0l5Y 65T8PT8npPdxYQ0PLRd25jp4IMu9tQY+HI6aBzTBae6Ew3AoQjDnDT5LPOjxoueKrC wub05jNTD62vfblRjYrHfdB+SCbStIZCXTF6bBkb/Am0wkQLVjf7/HcbdZf5is40/f UmgPRgAYnoE+084fPV2AB7aQz3TRWvmhwxfwDQprYhSTztcQRoHmkuy5P7+5VwEcfF opEGKFCLiXMRKeXJXDoYtHXyriWnP5Q5dQKBuunbFQrDurWn/1piACWkSpW8xQe/DU 1ojFftRLfLkLHy1Ti/LxO7ncbifEngBNN7+AEHNwTm4cGI6rAzmwQfLDIMsDeUTvm1 x0k1aca8WrB1+vMdBvbVK6oR+DhmlpG/2ddIovsdKZ1pRTDR4P5Ql0hnpejQvTF/PR HjDZ3vGvOzuKmwKJfzz2KxeHo6KNBq7Gc4H0LPvdLTZrjow1gO57QLKklI86ZF/iY+ iJcVglCDe02vIBB9l9u0OPbr639liNXx/PQESIFomxp+p7oUDk3IvSM6ouiA3RPW0H +onixWmec/nsvk2EldlCA+7g= Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-8479cc04d8fso3692392b3a.2 for ; Sun, 05 Jul 2026 07:55:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783263357; x=1783868157; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=O2pzYYWiHcShaqwLIb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:3a3b:d6e7 with SMTP id d2e1a72fcca58-847f6dd586emr5929981b3a.23.1783263356867; Sun, 05 Jul 2026 07:55:56 -0700 (PDT) X-Received: by 2002:a05:6a00:893:b0:842:3a3b:d6e7 with SMTP id d2e1a72fcca58-847f6dd586emr5929966b3a.23.1783263356399; Sun, 05 Jul 2026 07:55:56 -0700 (PDT) Received: from noble-uboot.tail872496.ts.net (124-218-37-86.cm.dynamic.apol.com.tw. [124.218.37.86]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c9e91b06f0esm4657856a12.15.2026.07.05.07.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jul 2026 07:55:55 -0700 (PDT) From: Aristo Chen To: u-boot@lists.denx.de Cc: Aristo Chen , Simon Glass , Tom Rini , Nora Schiffer , Ludwig Nussel , Daniel Golle Subject: [PATCH v1] bootm: teach handle_decomp_error() about the noload decompression buffer Date: Sun, 5 Jul 2026 14:51:22 +0000 Message-ID: <20260705145445.2339-1-aristo.chen@canonical.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Sun, 05 Jul 2026 21:42:05 +0200 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 For a compressed kernel_noload image, bootm_load_os() allocates a per-image decompression buffer of ALIGN(image_len * 8, SZ_1M) rather than the global CONFIG_SYS_BOOTM_LEN. When decompression fails on that path, handle_decomp_error() still prints Image too large: increase CONFIG_SYS_BOOTM_LEN which is misleading: increasing CONFIG_SYS_BOOTM_LEN does not help because the smaller per-image buffer is the actual bound. Commit 2ff26c1e378d ("bootm: fix overflow of the noload kernel decompression buffer") worked around this by printing a follow-up note right after handle_decomp_error() returned, but the boot log then reads as two contradictory sentences. Introduce enum bootm_decomp_limit and pass it into handle_decomp_error() so the helper picks the right message in one place. For the noload path it now prints Image too large for the kernel_noload buffer (0x100000 bytes) quoting the actual buffer size; the global path is unchanged. Drop the trailing note in bootm_load_os() so only one line is printed. Suggested-by: Simon Glass Signed-off-by: Aristo Chen --- boot/bootm.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/boot/bootm.c b/boot/bootm.c index 803d6406be4..a727bfea079 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -575,6 +575,19 @@ static int bootm_find_other(ulong img_addr, const char *conf_ramdisk, #endif /* USE_HOSTC */ #if !defined(USE_HOSTCC) || defined(CONFIG_FIT_SIGNATURE) +/** + * enum bootm_decomp_limit - What bounded the decompression buffer. + * @BOOTM_DECOMP_LIMIT_GLOBAL: Global CONFIG_SYS_BOOTM_LEN limit. + * @BOOTM_DECOMP_LIMIT_PER_IMAGE: Per-image buffer sized from the + * compressed image (e.g. the + * kernel_noload noload decompression + * buffer). + */ +enum bootm_decomp_limit { + BOOTM_DECOMP_LIMIT_GLOBAL, + BOOTM_DECOMP_LIMIT_PER_IMAGE, +}; + /** * handle_decomp_error() - display a decompression error * @@ -585,11 +598,14 @@ static int bootm_find_other(ulong img_addr, const char *conf_ramdisk, * @comp_type: Compression type being used (IH_COMP_...) * @uncomp_size: Number of bytes uncompressed * @buf_size: Number of bytes the decompresion buffer was + * @limit: Which allocation actually bounded the buffer, so the + * hint points at the knob the reader can act on * @ret: errno error code received from compression library * Return: Appropriate BOOTM_ERR_ error code */ static int handle_decomp_error(int comp_type, size_t uncomp_size, - size_t buf_size, int ret) + size_t buf_size, + enum bootm_decomp_limit limit, int ret) { const char *name = genimg_get_comp_name(comp_type); @@ -598,10 +614,15 @@ static int handle_decomp_error(int comp_type, size_t uncomp_size, return BOOTM_ERR_UNIMPLEMENTED; if ((comp_type == IH_COMP_GZIP && ret == Z_BUF_ERROR) || - uncomp_size >= buf_size) - printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n"); - else + uncomp_size >= buf_size) { + if (limit == BOOTM_DECOMP_LIMIT_PER_IMAGE) + printf("Image too large for the kernel_noload buffer (%#lx bytes)\n", + (ulong)buf_size); + else + printf("Image too large: increase CONFIG_SYS_BOOTM_LEN\n"); + } else { printf("%s: uncompress error %d\n", name, ret); + } /* * The decompression routines are now safe, so will not write beyond @@ -628,6 +649,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress) ulong image_start = os.image_start; ulong image_len = os.image_len; ulong decomp_len = CONFIG_SYS_BOOTM_LEN; + enum bootm_decomp_limit decomp_limit = BOOTM_DECOMP_LIMIT_GLOBAL; ulong flush_start; bool no_overlap; void *load_buf, *image_buf; @@ -644,6 +666,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress) phys_addr_t addr; decomp_len = ALIGN(image_len * 8, SZ_1M); + decomp_limit = BOOTM_DECOMP_LIMIT_PER_IMAGE; err = lmb_alloc_mem(LMB_MEM_ALLOC_ANY, SZ_2M, &addr, decomp_len, LMB_NONE); if (err) @@ -663,10 +686,7 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress) decomp_len, &load_end); if (err) { err = handle_decomp_error(os.comp, load_end - load, - decomp_len, err); - if (os.type == IH_TYPE_KERNEL_NOLOAD && os.comp != IH_COMP_NONE) - printf("Note: noload decompression buffer is %#lx bytes (not CONFIG_SYS_BOOTM_LEN)\n", - decomp_len); + decomp_len, decomp_limit, err); bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE); return err; } @@ -1288,7 +1308,8 @@ static int bootm_host_load_image(const void *fit, int req_image_type, free(load_buf); if (ret) { - ret = handle_decomp_error(image_comp, load_end - 0, buf_size, ret); + ret = handle_decomp_error(image_comp, load_end - 0, buf_size, + BOOTM_DECOMP_LIMIT_GLOBAL, ret); if (ret != BOOTM_ERR_UNIMPLEMENTED) return ret; } -- 2.43.0