Commit 58015ec6 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Will Deacon

arm64/efi: efistub: don't abort if base of DRAM is occupied

If we cannot relocate the kernel Image to its preferred offset of base of DRAM
plus TEXT_OFFSET, instead relocate it to the lowest available 2 MB boundary plus
TEXT_OFFSET. We may lose a bit of memory at the low end, but we can still
proceed normally otherwise.
Acked-by: default avatarMark Salter <msalter@redhat.com>
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Acked-by: default avatarLeif Lindholm <leif.lindholm@linaro.org>
Tested-by: default avatarLeif Lindholm <leif.lindholm@linaro.org>
Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent c16173fa
...@@ -28,20 +28,16 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table, ...@@ -28,20 +28,16 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
kernel_size = _edata - _text; kernel_size = _edata - _text;
if (*image_addr != (dram_base + TEXT_OFFSET)) { if (*image_addr != (dram_base + TEXT_OFFSET)) {
kernel_memsize = kernel_size + (_end - _edata); kernel_memsize = kernel_size + (_end - _edata);
status = efi_relocate_kernel(sys_table, image_addr, status = efi_low_alloc(sys_table, kernel_memsize + TEXT_OFFSET,
kernel_size, kernel_memsize, SZ_2M, reserve_addr);
dram_base + TEXT_OFFSET,
PAGE_SIZE);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err(sys_table, "Failed to relocate kernel\n"); pr_efi_err(sys_table, "Failed to relocate kernel\n");
return status; return status;
} }
if (*image_addr != (dram_base + TEXT_OFFSET)) { memcpy((void *)*reserve_addr + TEXT_OFFSET, (void *)*image_addr,
pr_efi_err(sys_table, "Failed to alloc kernel memory\n"); kernel_size);
efi_free(sys_table, kernel_memsize, *image_addr); *image_addr = *reserve_addr + TEXT_OFFSET;
return EFI_LOAD_ERROR; *reserve_size = kernel_memsize + TEXT_OFFSET;
}
*image_size = kernel_memsize;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment