From 9a3a1271a503b7037c6e8afdbd6ebb75084465d9 Mon Sep 17 00:00:00 2001 From: Janne Grunau Date: Sat, 4 Nov 2023 19:27:40 +0100 Subject: [PATCH] kboot: Align segment sizes to 16k in dt_reserve_asc_firmware() The segment for the dcp firmware text is inexplicably only aligned to 4k. Signed-off-by: Janne Grunau --- src/kboot.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/kboot.c b/src/kboot.c index 6ceafd7b..15787a9d 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -1610,12 +1610,18 @@ static int dt_reserve_asc_firmware(const char *adt_path, const char *adt_path_al char node_name[64]; snprintf(node_name, sizeof(node_name), "asc-firmware@%lx", seg->phys); - int mem_node = dt_get_or_add_reserved_mem(node_name, "apple,asc-mem", seg->phys, seg->size); + size_t seg_size = seg->size; + if (seg->size & (SZ_16K - 1)) { + printf("ADT: segment %s uses non 16k aligned size: 0x%06zx\n", node_name, seg_size); + seg_size = ALIGN_UP(seg_size, SZ_16K); + } + + int mem_node = dt_get_or_add_reserved_mem(node_name, "apple,asc-mem", seg->phys, seg_size); if (mem_node < 0) return ret; uint32_t mem_phandle = fdt_get_phandle(dt, mem_node); - ret = dt_device_set_reserved_mem(mem_node, node_name, dev_phandle, iova, seg->size); + ret = dt_device_set_reserved_mem(mem_node, node_name, dev_phandle, iova, seg_size); if (ret < 0) return ret;