]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
bootm: increase kernel_noload decompression headroom from 4x to 8x
authorAristo Chen <aristo.chen@canonical.com>
Fri, 5 Jun 2026 15:42:50 +0000 (15:42 +0000)
committerTom Rini <trini@konsulko.com>
Wed, 17 Jun 2026 18:47:33 +0000 (12:47 -0600)
For a compressed kernel_noload image, bootm_load_os() allocates a buffer
of ALIGN(image_len * 4, SZ_1M). The 4x factor is at the edge of what
modern compressors (zstd, xz) achieve on real kernels, so a
well-compressed vendor kernel can fail to boot at runtime with no
intervening warning.

Bump the headroom to 8x. The buffer is still bounded by the compressed
image size, and the SZ_1M alignment keeps the overhead below 1 MiB on
small kernels.

Suggested-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Aristo Chen <aristo.chen@canonical.com>
boot/bootm.c

index d0656fbdf08501e97f170c54d27b55a26a3f8d79..4c260a5f5cedb1edf6838876f4a612cbab5744c2 100644 (file)
@@ -626,14 +626,14 @@ static int bootm_load_os(struct bootm_headers *images, int boot_progress)
        /*
         * For a "noload" compressed kernel we need to allocate a buffer large
         * enough to decompress in to and use that as the load address now.
-        * Assume that the kernel compression is at most a factor of 4 since
-        * zstd almost achieves that.
+        * Allow up to 8x compression: this comfortably covers what zstd and xz
+        * achieve on real kernels, with headroom for well-compressed payloads.
         * Use an alignment of 2MB since this might help arm64
         */
        if (os.type == IH_TYPE_KERNEL_NOLOAD && os.comp != IH_COMP_NONE) {
                phys_addr_t addr;
 
-               decomp_len = ALIGN(image_len * 4, SZ_1M);
+               decomp_len = ALIGN(image_len * 8, SZ_1M);
                err = lmb_alloc_mem(LMB_MEM_ALLOC_ANY, SZ_2M, &addr,
                                    decomp_len, LMB_NONE);
                if (err)