aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYing-Chun Liu <liupa@google.com>2024-03-31 23:14:57 +0000
committerYing-Chun Liu <liupa@google.com>2024-04-19 17:41:08 +0000
commit8dd12a48fe002a47ecf144940ecbc3d23050f0a3 (patch)
treeae744d80ba5b5c5f5ffdada248c12b557871ee23
parent838d1740bcf5a983d31fa070e38dbb222cd0af3b (diff)
downloadu-boot-8dd12a48fe002a47ecf144940ecbc3d23050f0a3.tar.gz
ANDROID: fix overwrite and increase the memory gap for kernel and initramfs
This is a redo for commit 2095a16d14fb8f050bb34684ac70683af6274f37 and commit 317b196d4f4c6670f1482a6945fcf47ae009af62. Let all the architecture uses the same setup. And the gap is calculated by the size of the kernel. Change-Id: I13ef858451ec6d72553a2d172864e3d789e753e6 Signed-off-by: Ying-Chun Liu <liupa@google.com>
-rw-r--r--boot/android_bootloader.c4
-rw-r--r--boot/image-android.c14
2 files changed, 13 insertions, 5 deletions
diff --git a/boot/android_bootloader.c b/boot/android_bootloader.c
index f4a1ab4d0e..614d92cdb4 100644
--- a/boot/android_bootloader.c
+++ b/boot/android_bootloader.c
@@ -423,10 +423,10 @@ static int do_avb_verify(const char *iface,
data->slot_suffix = slot_suffix;
data->boot.addr = kernel_address;
data->boot.size = 0; // 0 indicates that it hasn't yet been preloaded.
- data->vendor_boot.addr = data->boot.addr + (packed ? boot_size : SZ_64M);
+ data->vendor_boot.addr = data->boot.addr + (packed ? boot_size : ALIGN(boot_size, SZ_64M));
data->vendor_boot.size = 0;
if (init_boot_size != 0) {
- data->init_boot.addr = data->vendor_boot.addr + (packed ? vendor_boot_size : SZ_64M);
+ data->init_boot.addr = data->vendor_boot.addr + (packed ? vendor_boot_size : ALIGN(vendor_boot_size, SZ_64M));
data->init_boot.size = 0;
ret = avb_verify(ops, slot_suffix, out_data, out_cmdline);
} else {
diff --git a/boot/image-android.c b/boot/image-android.c
index 3350ee1ab3..4016208cd4 100644
--- a/boot/image-android.c
+++ b/boot/image-android.c
@@ -289,9 +289,17 @@ static void _populate_boot_info(const struct boot_img_hdr_v4* boot_hdr,
sizeof(vboot_hdr->cmdline));
boot_info->kernel_addr = (ulong)load_addr;
- /* The "kernel_addr" is already aligned to 2MB */
- boot_info->vendor_ramdisk_addr = boot_info->kernel_addr +
- ALIGN(boot_info->kernel_size, SZ_64M);
+ /* The "kernel_addr" is already aligned to 2MB. */
+ if (IS_ENABLED(CONFIG_X86))
+ /*
+ We multiple the kernel_size by 3 to let it leave
+ some spaces if the kernel is self-decompressed in-place.
+ */
+ boot_info->vendor_ramdisk_addr = boot_info->kernel_addr +
+ ALIGN(boot_info->kernel_size, SZ_64M) * 3;
+ else
+ boot_info->vendor_ramdisk_addr = boot_info->kernel_addr +
+ ALIGN(boot_info->kernel_size, SZ_64M);
boot_info->boot_ramdisk_addr = boot_info->vendor_ramdisk_addr
+ boot_info->vendor_ramdisk_size;