Skip to content

Commit

Permalink
aarch64: Increase size of EFI payload
Browse files Browse the repository at this point in the history
In order to support the requirements of a larger GRUB binary extend the
size of the memory used for loading the payload. Since the payload
address is hardcoded to a location in RAM below that of where the RHF
binary is loaded increase adjust the ram_min constant to handle that.
This does not require any VMM changes as the load address in the PE
binary will reflect this change.

Fixes: cloud-hypervisor#261

Signed-off-by: Jianyong Wu <[email protected]>
  • Loading branch information
jongwu authored and rbradford committed Jul 20, 2023
1 parent 9308ff7 commit 2391a65
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 14 deletions.
17 changes: 14 additions & 3 deletions aarch64-unknown-none.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ ENTRY(ram64_start)
DRAM: [0x4000_0000-0xfc00_0000]
FDT: [0x4000_0000-0x401f_ffff)
ACPI: [0x4020_0000-0x403f_ffff)
kernel: [0x4048_0000-]
The stack start is at the end of the DRAM region. */
ram_min = 0x40480000;
payload:[0x4040_0000-0x405f_ffff)
RHF: [0x40600000-]
Assuming 2MB is enough to load payload.
The stack start is at the end of the RHF region. */
ram_min = 0x40600000;

/* This value must be identical with arch::aarch64::layout::map::dram::KERNEL_START. */
PAYLOAD_START = 0x40400000;

efi_image_size = rhf_end - ram_min;
efi_image_offset = ram_min - PAYLOAD_START;

SECTIONS
{
Expand Down Expand Up @@ -41,4 +49,7 @@ SECTIONS
*(.symtab)
*(.strtab)
}

. = ALIGN(4K);
rhf_end = .;
}
24 changes: 13 additions & 11 deletions src/arch/aarch64/ram64.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

.section .text.boot, "ax"
.global ram64_start
.global efi_image_size
.global efi_image_offset

ram64_start:
/*
Expand All @@ -11,18 +13,18 @@ ram64_start:
*
* [1] https://docs.kernel.org/arm64/booting.html#call-the-kernel-image
*/
add x13, x18, #0x16 /* code0: UEFI "MZ" signature magic instruction */
b jump_to_rust /* code1 */
add x13, x18, #0x16 /* code0: UEFI "MZ" signature magic instruction */
b jump_to_rust /* code1 */

.quad 0 /* text_offset */
.quad 0 /* image_size */
.quad 0 /* flags */
.quad 0 /* res2 */
.quad 0 /* res3 */
.quad 0 /* res4 */
.quad efi_image_offset /* text_offset */
.quad efi_image_size /* image_size */
.quad 0 /* flags */
.quad 0 /* res2 */
.quad 0 /* res3 */
.quad 0 /* res4 */

.long 0x644d5241 /* "ARM\x64" magic number */
.long 0 /* res5 */
.long 0x644d5241 /* "ARM\x64" magic number */
.long 0 /* res5 */
.align 3

jump_to_rust:
Expand All @@ -34,4 +36,4 @@ jump_to_rust:
mov sp, x30

/* x0: pointer to device tree */
b rust64_start
b rust64_start
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ use core::panic::PanicInfo;
#[cfg(target_arch = "x86_64")]
use x86_64::instructions::hlt;

#[cfg(target_arch = "aarch64")]
use crate::arch::aarch64::layout::code_range;

#[macro_use]
mod serial;

Expand Down Expand Up @@ -132,6 +135,12 @@ fn boot_from_device(device: &mut block::VirtioBlockDevice, info: &dyn bootinfo::
}
};

#[cfg(target_arch = "aarch64")]
if code_range().start < (info.kernel_load_addr() + size) as usize {
log!("Error Boot Image is too large");
return false;
}

log!("Executable loaded");
efi::efi_exec(entry_addr, load_addr, size, info, &f, device);
true
Expand Down

0 comments on commit 2391a65

Please sign in to comment.