aarch64: fix the potential memory overlapping bug of bootloader

toolchain_update
equation314 6 years ago
parent f3d47f4b02
commit 681c0be801

@ -25,7 +25,7 @@ fn gen_payload_asm() -> Result<std::path::PathBuf> {
write!(f, "# generated by build.rs - do not edit")?;
write!(f, r#"
.section .rodata
.section .payload,"a"
.align 12
.global _kernel_payload_start, _kernel_payload_end
_kernel_payload_start:

@ -27,5 +27,9 @@ SECTIONS {
_ebss = .;
}
.payload : {
*(.payload)
}
/DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
}

@ -5,3 +5,4 @@ _start:
ldr x0, =bootstacktop
mov sp, x0
bl rust_main
1: b 1b

@ -2,7 +2,6 @@ ENTRY(_start)
SECTIONS {
. = 0xffff000000100000; /* Load the kernel at this address. It's also kernel stack top address */
bootstacktop = .;
.text : {
stext = .;
@ -35,12 +34,15 @@ SECTIONS {
ebss = .;
}
.stack : {
. = ALIGN(4K);
bootstack = .;
. += 0x100000;
bootstacktop = .;
}
/* end of the binary */
_end = ALIGN(8);
/* number of bytes in BSS section and complete binary */
__bss_length = (ebss - sbss);
__binary_length = (_end - _start);
/DISCARD/ : { *(.comment) *(.gnu*) *(.note*) *(.eh_frame*) }
}

@ -47,11 +47,11 @@ static mut KERNEL_MEMORY_SET: Option<MemorySet> = None;
fn remap_the_kernel() {
let offset = -(KERNEL_OFFSET as isize);
let mut ms = MemorySet::new_bare();
ms.push(KERNEL_OFFSET, bootstacktop as usize, Linear::new(offset, MemoryAttr::default()), "kstack");
ms.push(stext as usize, etext as usize, Linear::new(offset, MemoryAttr::default().execute().readonly()), "text");
ms.push(sdata as usize, edata as usize, Linear::new(offset, MemoryAttr::default()), "data");
ms.push(srodata as usize, erodata as usize, Linear::new(offset, MemoryAttr::default().readonly()), "rodata");
ms.push(sbss as usize, ebss as usize, Linear::new(offset, MemoryAttr::default()), "bss");
ms.push(bootstack as usize, bootstacktop as usize, Linear::new(offset, MemoryAttr::default()), "kstack");
use super::board::{IO_REMAP_BASE, IO_REMAP_END};
ms.push(IO_REMAP_BASE, IO_REMAP_END, Linear::new(offset, MemoryAttr::default().mmio(MMIOType::Device as u8)), "io_remap");
@ -73,7 +73,6 @@ pub fn ioremap(paddr: usize, len: usize, name: &'static str) -> usize {
}
extern "C" {
fn bootstacktop();
fn stext();
fn etext();
fn sdata();
@ -82,6 +81,8 @@ extern "C" {
fn erodata();
fn sbss();
fn ebss();
fn bootstack();
fn bootstacktop();
fn _start();
fn _end();
}

Loading…
Cancel
Save