coreboot/payloads/libpayload/arch/arm64
Yu-Ping Wu b4f2a51533 libpayload/arch/arm64/mmu: Fix missing CBMEM in used ranges
We use mmu_ranges to track the list of memory ranges and their types for
MMU initialization. We also keep track of used memory ranges in
usedmem_ranges, to avoid them from being re-allocated in
mmu_alloc_range().

The problem is, the CBMEM range (CB_MEM_TABLE) is added to mmu_ranges,
but is never marked as "used" in usedmem_ranges. This potentially causes
any allocation (for example the framebuffer) to overlap with CBMEM. This
issue is observed when DMA_DEFAULT_SIZE is reduced from 32MB to 1MB [1].
Prior to that change, because there isn't enough space above the
coreboot table (with the 4GB upper limit) to fit the 32MB requested
region, the DMA heap is always allocated *below* the coreboot table. And
because the coreboot table is usually the lowest within CBMEM, the DMA
heap region is allocated *below* the whole CBMEM, which happens the
avoid the issue.

Fix the bug by adding CB_MEM_TABLE ranges to usedmem_ranges. The ranges
in usedmem_ranges don't need to be combined because they are not for MMU
initialization (and there's only one CB_MEM_TABLE range).

[1] commit aedc177f00 ("libpayload: arm64: Reduce DMA allocator space to 1MB")

BUG=b:424107889
TEST=emerge-skywalker libpayload
BRANCH=none

Change-Id: Ie9ecafc17546e524253c60ab684ec10ff3495998
Signed-off-by: Yu-Ping Wu <yupingso@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88063
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Bartłomiej Grzesik <bgrzesik@google.com>
Reviewed-by: Jakub "Kuba" Czapiga <czapiga@google.com>
2025-06-13 15:23:09 +00:00
..
cache.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
coreboot.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
cpu.S libpayload/arm64: Support FEAT_CCIDX 2024-06-05 11:09:16 +00:00
exception.c libpayload: arm64: silence libpayload main entry 2020-07-08 07:25:38 +00:00
exception_asm.S treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
gdb.c libpayload: arm64: Add GDB support 2018-10-12 20:17:48 +00:00
head.S libpayload: Fix the stack and data labels 2023-12-01 02:20:29 +00:00
Kconfig libpayload: Use Kconfig for architecture memcpy, not weak symbols 2025-05-22 19:27:24 +00:00
libpayload.ldscript libpayload: Move back the ttb_buffer section 2024-01-11 21:02:30 +00:00
main.c libpayload/arch/x86: Update API handling of CBTABLE handoff 2023-05-24 11:49:51 +00:00
Makefile.mk libpayload: Unify selfboot() implementations 2025-02-11 20:59:57 +00:00
memcpy.S libpayload: Add support for arm64 in libpayload 2015-01-09 07:04:28 +01:00
memmove.S libpayload: Add support for arm64 in libpayload 2015-01-09 07:04:28 +01:00
memset.S libpayload arm64: Remove the DONT_USE_DC macro 2015-03-21 13:35:58 +01:00
mmu.c libpayload/arch/arm64/mmu: Fix missing CBMEM in used ranges 2025-06-13 15:23:09 +00:00
sysinfo.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
timer.c treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
util.S treewide: Remove "this file is part of" lines 2020-05-11 17:11:40 +00:00
virtual.c payloads: Drop unneeded empty lines 2020-09-21 16:20:57 +00:00