libpayload/arm64: Round fb_size up to a multiple of GRANULE_SIZE

If a framebuffer is already configured by coreboot, we need to ensure
that the framebuffer size is a multiple of GRANULE_SIZE before passing
to `mmu_add_memrange`. Otherwise, we would fail to allocate memory
region due to `sanity_check`.

Change-Id: Ia6a6400733ca10a61220087e87022f68c28e4789
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/79451
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Yidi Lin 2023-12-08 23:52:05 +08:00 committed by Felix Held
parent 933e50702e
commit e78ea98bb2
1 changed files with 3 additions and 2 deletions

View File

@ -575,8 +575,6 @@ static struct mmu_memrange *_mmu_add_fb_range(
prop.type = TYPE_DMA_MEM; prop.type = TYPE_DMA_MEM;
/* make sure to allocate a size of multiple of GRANULE_SIZE */
size = ALIGN_UP(size, GRANULE_SIZE);
prop.size = size; prop.size = size;
prop.lim_excl = MIN_64_BIT_ADDR; prop.lim_excl = MIN_64_BIT_ADDR;
prop.align = MB_SIZE; prop.align = MB_SIZE;
@ -634,6 +632,9 @@ static void mmu_add_fb_range(struct mmu_ranges *mmu_ranges)
if (!fb_size) if (!fb_size)
return; return;
/* make sure to allocate a size of multiple of GRANULE_SIZE */
fb_size = ALIGN_UP(fb_size, GRANULE_SIZE);
/* framebuffer address has been set already, so just add it as DMA */ /* framebuffer address has been set already, so just add it as DMA */
if (framebuffer->physical_address) { if (framebuffer->physical_address) {
if (mmu_add_memrange(mmu_ranges, if (mmu_add_memrange(mmu_ranges,