diff --git a/config/coreboot-qemu-tpm1.config b/config/coreboot-qemu-tpm1.config index 2aef8989b..13272f334 100644 --- a/config/coreboot-qemu-tpm1.config +++ b/config/coreboot-qemu-tpm1.config @@ -328,6 +328,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -451,7 +452,6 @@ CONFIG_ACPI_COMMON_MADT_IOAPIC=y CONFIG_HAVE_ACPI_TABLES=y CONFIG_BOOT_DEVICE_NOT_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-qemu-tpm2.config b/config/coreboot-qemu-tpm2.config index 971e39338..2d9dcbcbe 100644 --- a/config/coreboot-qemu-tpm2.config +++ b/config/coreboot-qemu-tpm2.config @@ -325,6 +325,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -444,7 +445,6 @@ CONFIG_ACPI_COMMON_MADT_IOAPIC=y CONFIG_HAVE_ACPI_TABLES=y CONFIG_BOOT_DEVICE_NOT_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-t420-maximized.config b/config/coreboot-t420-maximized.config index f6f3bc43c..c70b82ded 100644 --- a/config/coreboot-t420-maximized.config +++ b/config/coreboot-t420-maximized.config @@ -424,6 +424,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -583,7 +584,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-t430-maximized.config b/config/coreboot-t430-maximized.config index 72848287d..66bb73465 100644 --- a/config/coreboot-t430-maximized.config +++ b/config/coreboot-t430-maximized.config @@ -424,6 +424,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -583,7 +584,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-t440p.config b/config/coreboot-t440p.config index 58f7a1286..43de12474 100644 --- a/config/coreboot-t440p.config +++ b/config/coreboot-t440p.config @@ -422,6 +422,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -578,7 +579,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-t530-maximized.config b/config/coreboot-t530-maximized.config index 37bc8d57f..2a05f5659 100644 --- a/config/coreboot-t530-maximized.config +++ b/config/coreboot-t530-maximized.config @@ -427,6 +427,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -585,7 +586,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-w530-maximized.config b/config/coreboot-w530-maximized.config index b13cfcbef..0caf3cdb8 100644 --- a/config/coreboot-w530-maximized.config +++ b/config/coreboot-w530-maximized.config @@ -427,6 +427,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -586,7 +587,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-w541.config b/config/coreboot-w541.config index cdca1c07b..69dc970d8 100644 --- a/config/coreboot-w541.config +++ b/config/coreboot-w541.config @@ -422,6 +422,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -577,7 +578,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-x220-maximized.config b/config/coreboot-x220-maximized.config index 925ca104f..ba308ff7a 100644 --- a/config/coreboot-x220-maximized.config +++ b/config/coreboot-x220-maximized.config @@ -424,6 +424,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -582,7 +583,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-x230-legacy-flash.config b/config/coreboot-x230-legacy-flash.config index a28e11f50..54ba0eb69 100644 --- a/config/coreboot-x230-legacy-flash.config +++ b/config/coreboot-x230-legacy-flash.config @@ -413,6 +413,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -566,7 +567,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-x230-legacy.config b/config/coreboot-x230-legacy.config index a4ebf77e1..12be7c439 100644 --- a/config/coreboot-x230-legacy.config +++ b/config/coreboot-x230-legacy.config @@ -413,6 +413,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -567,7 +568,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-x230-maximized-fhd_edp.config b/config/coreboot-x230-maximized-fhd_edp.config index 5ea91786d..5f1af0fa0 100644 --- a/config/coreboot-x230-maximized-fhd_edp.config +++ b/config/coreboot-x230-maximized-fhd_edp.config @@ -425,6 +425,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -582,7 +583,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-x230-maximized.config b/config/coreboot-x230-maximized.config index 546fda2ad..8d238b7fe 100644 --- a/config/coreboot-x230-maximized.config +++ b/config/coreboot-x230-maximized.config @@ -424,6 +424,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -580,7 +581,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/config/coreboot-z220-cmt.config b/config/coreboot-z220-cmt.config index 054eb85a0..50e4fc974 100644 --- a/config/coreboot-z220-cmt.config +++ b/config/coreboot-z220-cmt.config @@ -403,6 +403,7 @@ CONFIG_NO_EARLY_GFX_INIT=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_BOOTSPLASH=y +CONFIG_HEAP_SIZE=0x400000 # end of Display CONFIG_PCI=y @@ -560,7 +561,6 @@ CONFIG_BOOT_DEVICE_SPI_FLASH=y CONFIG_BOOT_DEVICE_MEMORY_MAPPED=y CONFIG_BOOT_DEVICE_SUPPORTS_WRITES=y CONFIG_RTC=y -CONFIG_HEAP_SIZE=0x100000 # # Console diff --git a/patches/coreboot-24.02.01/0001-prevent_bootsplash_heap_allocation_failure_to_booting.patch b/patches/coreboot-24.02.01/0001-prevent_bootsplash_heap_allocation_failure_to_booting.patch new file mode 100644 index 000000000..3913ba10c --- /dev/null +++ b/patches/coreboot-24.02.01/0001-prevent_bootsplash_heap_allocation_failure_to_booting.patch @@ -0,0 +1,80 @@ +From 8b6fc3a877d8169091d034ea6ac6d15593cc69a0 Mon Sep 17 00:00:00 2001 +From: Jonathon Hall +Date: Mon, 15 Jul 2024 15:01:52 -0400 +Subject: [PATCH] src/lib/malloc.c: If allocation fails, leave the heap + unchanged + +If an allocation fails because it is too large for the rest of the heap, +don't consume the rest of the heap needlessly. + +This started occurring with the Heads bootsplash image in 24.02.01, +following the switch to the Wuffs JPEG decoder. The work area needed +was too large for the heap. The bootsplash failed to show, but worse, +the boot failed entirely because we were then out of heap space, even +though we did not actually use the large allocation that failed. + +With this change, that failure no longer prevents boot. + +The error message is improved slightly also: +* missing line break is added +* "Tried to round up" now shows the beginning of the allocation before + and after rounding instead of the unrounded beginning and rounded end + (misleading, looked like it was trying to align by 1 MB when it + was actually allocating 1 MB) + +Change-Id: Ie72814027d9daa517c0794f3ea7abec2b9a9d596 +Signed-off-by: Jonathon Hall +--- + src/lib/malloc.c | 25 ++++++++++++------------- + 1 file changed, 12 insertions(+), 13 deletions(-) + +diff --git a/src/lib/malloc.c b/src/lib/malloc.c +index 30298064d9..281792c3d5 100644 +--- a/src/lib/malloc.c ++++ b/src/lib/malloc.c +@@ -26,30 +26,29 @@ void *memalign(size_t boundary, size_t size) + MALLOCDBG("%s Enter, boundary %zu, size %zu, free_mem_ptr %p\n", + __func__, boundary, size, free_mem_ptr); + +- free_mem_ptr = (void *)ALIGN_UP((unsigned long)free_mem_ptr, boundary); ++ p = (void *)ALIGN_UP((unsigned long)free_mem_ptr, boundary); + +- p = free_mem_ptr; +- free_mem_ptr += size; +- /* +- * Store last allocation pointer after ALIGN, as malloc() will +- * return it. This may cause n bytes of gap between allocations +- * where n < boundary. +- */ +- free_last_alloc_ptr = p; +- +- if (free_mem_ptr >= free_mem_end_ptr) { ++ if (p + size >= free_mem_end_ptr) { + printk(BIOS_ERR, "%s(boundary=%zu, size=%zu): failed: ", + __func__, boundary, size); + printk(BIOS_ERR, "Tried to round up free_mem_ptr %p to %p\n", +- p, free_mem_ptr); ++ free_mem_ptr, p); + printk(BIOS_ERR, "but free_mem_end_ptr is %p\n", + free_mem_end_ptr); + printk(BIOS_ERR, "Error! %s: Out of memory " +- "(free_mem_ptr >= free_mem_end_ptr)", ++ "(free_mem_ptr >= free_mem_end_ptr)\n", + __func__); + return NULL; + } + ++ free_mem_ptr = p + size; ++ /* ++ * Store last allocation pointer after ALIGN, as malloc() will ++ * return it. This may cause n bytes of gap between allocations ++ * where n < boundary. ++ */ ++ free_last_alloc_ptr = p; ++ + MALLOCDBG("%s %p\n", __func__, p); + + return p; +-- +2.39.2 + diff --git a/patches/coreboot-24.02.01/0002-increase_heap_from1mb_to4mb_when_bootpslash_enabled.patch b/patches/coreboot-24.02.01/0002-increase_heap_from1mb_to4mb_when_bootpslash_enabled.patch new file mode 100644 index 000000000..a31118c14 --- /dev/null +++ b/patches/coreboot-24.02.01/0002-increase_heap_from1mb_to4mb_when_bootpslash_enabled.patch @@ -0,0 +1,44 @@ +From 00d695849a5fb503d87203e3515f761fa8dac850 Mon Sep 17 00:00:00 2001 +From: Jonathon Hall +Date: Mon, 15 Jul 2024 16:37:40 -0400 +Subject: [PATCH] bootsplash: Increase heap from 1 MB to 4 MB when bootsplash + is enabled + +Since commit 1d029b40c9de ("lib/jpeg: Replace decoder with Wuffs' +implementation"), a relatively large heap allocation is needed to +decode many JPEGs for use as work area. The prior decoder did not need +this, but also had many limitations in the JPEGs it could decode. + +A 1024x768 non-progressive JPEG used in Heads needs 1179648 bytes of +work area; about 1.2 MB. While the work area will also depend on the +subsampling of each channel, it's generally proportional to the image +size. + +Increasing the heap size to 4 MB when bootsplash is enabled should be +enough to decode bootsplashes up to 1920x1080 with some headroom. + +Change-Id: Ia4348d39effbc16c1b42ab01bcf1e4ec5d652fa9 +Signed-off-by: Jonathon Hall +--- + src/device/Kconfig | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/src/device/Kconfig b/src/device/Kconfig +index 243e23e52a..4dd03eba21 100644 +--- a/src/device/Kconfig ++++ b/src/device/Kconfig +@@ -501,6 +501,11 @@ config BOOTSPLASH + image in the 'General' section or add it manually to CBFS, using, + for example, cbfstool. + ++# The bootsplash JPEG decoder requires heap space approximately proportional to ++# the image size. This usually needs a larger heap. ++config HEAP_SIZE ++ default 0x400000 if BOOTSPLASH ++ + config LINEAR_FRAMEBUFFER_MAX_WIDTH + int "Maximum width in pixels" + depends on LINEAR_FRAMEBUFFER && MAINBOARD_USE_LIBGFXINIT +-- +2.39.2 +