diff --git a/aarch64-unknown-none.ld b/aarch64-unknown-none.ld index 31d1b681..3666049c 100644 --- a/aarch64-unknown-none.ld +++ b/aarch64-unknown-none.ld @@ -6,7 +6,7 @@ ENTRY(ram64_start) ACPI: [0x4020_0000-0x403f_ffff) kernel: [0x4048_0000-] The stack start is at the end of the DRAM region. */ -ram_min = 0x40480000; +ram_min = 0x40600000; SECTIONS { diff --git a/src/arch/aarch64/ram64.s b/src/arch/aarch64/ram64.s index 93e28e63..18eb484f 100644 --- a/src/arch/aarch64/ram64.s +++ b/src/arch/aarch64/ram64.s @@ -14,8 +14,8 @@ ram64_start: add x13, x18, #0x16 /* code0: UEFI "MZ" signature magic instruction */ b jump_to_rust /* code1 */ - .quad 0 /* text_offset */ - .quad 0 /* image_size */ + .quad 0x200000 /* text_offset */ + .quad 0x8000 /* image_size */ .quad 0 /* flags */ .quad 0 /* res2 */ .quad 0 /* res3 */ @@ -34,4 +34,4 @@ jump_to_rust: mov sp, x30 /* x0: pointer to device tree */ - b rust64_start \ No newline at end of file + b rust64_start diff --git a/src/main.rs b/src/main.rs index ed37984f..1a17bee5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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; @@ -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