coreboot 24.02.01: add upstream pending patches for heap allocation failure on bootsplash and defaulting to 4mb of heap when bootsplash

Add upstreeam patches to downstream:
git fetch https://review.coreboot.org/coreboot refs/changes/75/83475/1 && git format-patch -1 --stdout FETCH_HEAD > 0001-prevent_bootsplash_heap_allocation_failure_to_booting.patch
git fetch https://review.coreboot.org/coreboot refs/changes/76/83476/2 && git format-patch -1 --stdout FETCH_HEAD > 0002-increase_heap_from1mb_to4mb_when_bootpslash_enabled.patch

Rebuilding coreboot version with patches applied:
docker run -e DISPLAY=$DISPLAY --network host --rm -ti -v $(pwd):$(pwd) -w $(pwd) tlaurion/heads-dev-env:v0.2.0 -- make BOARD=qemu-coreboot-whiptail-tpm1 real.remove_canary_files-extract_patch_rebuild_what_changed
Remove file added by patch when patching fails:
sudo rm build/x86/libgpg-error-1.46/src/syscfg/lock-obj-pub.powerpc64le-unknown-linux-musl.h

Applying patches touching coreboot version 24.02.01 defiend in board config to all boards:
grep -R 24.02.01 boards/ | awk -F "/" {'print $2'} | while read board; do sudo make BOARD=$board coreboot.save_in_oldconfig_format_in_place; done

Adding added/modified files to git tracked files for commit:
git status | grep -e modified -e added | awk -F ":" {'print $2'}| xargs git add

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
This commit is contained in:
Thierry Laurion 2024-07-16 09:44:38 -04:00
parent 60ec2b9b45
commit 119cebc44f
No known key found for this signature in database
GPG Key ID: 9A53E1BB3FF00461
16 changed files with 138 additions and 0 deletions

View File

@ -326,6 +326,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -323,6 +323,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -423,6 +423,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -423,6 +423,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -420,6 +420,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -426,6 +426,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -426,6 +426,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -420,6 +420,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -423,6 +423,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -412,6 +412,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -412,6 +412,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -424,6 +424,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -423,6 +423,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -402,6 +402,7 @@ CONFIG_NO_EARLY_GFX_INIT=y
CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y CONFIG_GENERIC_LINEAR_FRAMEBUFFER=y
CONFIG_LINEAR_FRAMEBUFFER=y CONFIG_LINEAR_FRAMEBUFFER=y
CONFIG_BOOTSPLASH=y CONFIG_BOOTSPLASH=y
CONFIG_HEAP_SIZE=0x400000
# end of Display # end of Display
CONFIG_PCI=y CONFIG_PCI=y

View File

@ -0,0 +1,80 @@
From 8b6fc3a877d8169091d034ea6ac6d15593cc69a0 Mon Sep 17 00:00:00 2001
From: Jonathon Hall <jonathon.hall@puri.sm>
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 <jonathon.hall@puri.sm>
---
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

View File

@ -0,0 +1,44 @@
From 00d695849a5fb503d87203e3515f761fa8dac850 Mon Sep 17 00:00:00 2001
From: Jonathon Hall <jonathon.hall@puri.sm>
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 <jonathon.hall@puri.sm>
---
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