From 13be52133da4825c9430f3f40bbd8cc8a7cfe6e2 Mon Sep 17 00:00:00 2001 From: equation314 Date: Tue, 20 Nov 2018 18:32:26 +0800 Subject: [PATCH] aarch64: move kernel stack top to 0x100000 --- kernel/src/arch/aarch64/boot/boot.S | 14 +++++++++----- kernel/src/arch/aarch64/boot/linker.ld | 9 ++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/kernel/src/arch/aarch64/boot/boot.S b/kernel/src/arch/aarch64/boot/boot.S index b8a142e9..e525340d 100644 --- a/kernel/src/arch/aarch64/boot/boot.S +++ b/kernel/src/arch/aarch64/boot/boot.S @@ -2,8 +2,7 @@ .section .text.boot -.global _start -_start: +boot: # read cpu affinity, start core 0, halt rest mrs x1, mpidr_el1 and x1, x1, #3 @@ -16,7 +15,7 @@ halt: setup: # store the desired EL1 stack pointer in x1 - adr x1, _start + ldr x1, =_start # use SP_ELx for Exception level ELx msr SPsel, #1 @@ -99,12 +98,17 @@ zero_bss: zero_bss_loop: # zero out the BSS section, 64-bits at a time - cbz x2, go_kmain + cbz x2, zero_bss_loop_end str xzr, [x1], #8 sub x2, x2, #8 cbnz x2, zero_bss_loop -go_kmain: +zero_bss_loop_end: + b _start + +.section .text.entry +.globl _start +_start: # jump to rust_main, which shouldn't return. halt if it does bl rust_main b halt diff --git a/kernel/src/arch/aarch64/boot/linker.ld b/kernel/src/arch/aarch64/boot/linker.ld index ce4c0c2a..34858e39 100644 --- a/kernel/src/arch/aarch64/boot/linker.ld +++ b/kernel/src/arch/aarch64/boot/linker.ld @@ -3,11 +3,14 @@ ENTRY(_start) SECTIONS { . = 0x80000; /* Raspbery Pi 3 Aarch64 (kernel8.img) load address */ - /* start of the binary */ - _start = .; + .boot : { + KEEP(*(.text.boot)) /* from boot.S */ + } + + . = 0x100000; /* Load the kernel at this address. It's also kernel stack top address */ .text : { - KEEP(*(.text.boot)) /* from boot.S */ + *(.text.entry) *(.text .text.* .gnu.linkonce.t*) }