diff --git a/04_zero_overhead_abstraction/README.md b/04_zero_overhead_abstraction/README.md index c7ff8a5f..ca679c52 100644 --- a/04_zero_overhead_abstraction/README.md +++ b/04_zero_overhead_abstraction/README.md @@ -53,7 +53,7 @@ diff -uNr 03_hacky_hello_world/src/_arch/aarch64/cpu/smp.rs 04_zero_overhead_abs diff -uNr 03_hacky_hello_world/src/_arch/aarch64/cpu.rs 04_zero_overhead_abstraction/src/_arch/aarch64/cpu.rs --- 03_hacky_hello_world/src/_arch/aarch64/cpu.rs +++ 04_zero_overhead_abstraction/src/_arch/aarch64/cpu.rs -@@ -4,8 +4,34 @@ +@@ -4,8 +4,35 @@ //! Architectural processor code. @@ -72,8 +72,9 @@ diff -uNr 03_hacky_hello_world/src/_arch/aarch64/cpu.rs 04_zero_overhead_abstrac +/// +/// # Safety +/// -+/// - Linker script must ensure to place this function at `0x80_000`. -+#[naked] ++/// - Linker script must ensure to place this function where it is expected by the target machine. ++/// - We have to hope that the compiler omits any stack pointer usage before the stack pointer is ++/// actually set (`SP.set()`). +#[no_mangle] +pub unsafe fn _start() -> ! { + use crate::runtime_init; @@ -90,7 +91,7 @@ diff -uNr 03_hacky_hello_world/src/_arch/aarch64/cpu.rs 04_zero_overhead_abstrac //-------------------------------------------------------------------------------------------------- // Public Code -@@ -14,13 +40,7 @@ +@@ -14,13 +41,7 @@ /// Pause execution on the core. #[inline(always)] pub fn wait_forever() -> ! { diff --git a/04_zero_overhead_abstraction/src/_arch/aarch64/cpu.rs b/04_zero_overhead_abstraction/src/_arch/aarch64/cpu.rs index d49c8aba..64c5397f 100644 --- a/04_zero_overhead_abstraction/src/_arch/aarch64/cpu.rs +++ b/04_zero_overhead_abstraction/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage before the stack pointer is +/// actually set (`SP.set()`). #[no_mangle] pub unsafe fn _start() -> ! { use crate::runtime_init; diff --git a/05_safe_globals/src/_arch/aarch64/cpu.rs b/05_safe_globals/src/_arch/aarch64/cpu.rs index d49c8aba..64c5397f 100644 --- a/05_safe_globals/src/_arch/aarch64/cpu.rs +++ b/05_safe_globals/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage before the stack pointer is +/// actually set (`SP.set()`). #[no_mangle] pub unsafe fn _start() -> ! { use crate::runtime_init; diff --git a/06_drivers_gpio_uart/README.md b/06_drivers_gpio_uart/README.md index 1bd8b26a..08568cf5 100644 --- a/06_drivers_gpio_uart/README.md +++ b/06_drivers_gpio_uart/README.md @@ -183,7 +183,7 @@ diff -uNr 05_safe_globals/Makefile 06_drivers_gpio_uart/Makefile diff -uNr 05_safe_globals/src/_arch/aarch64/cpu.rs 06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs --- 05_safe_globals/src/_arch/aarch64/cpu.rs +++ 06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs -@@ -37,6 +37,17 @@ +@@ -38,6 +38,17 @@ // Public Code //-------------------------------------------------------------------------------------------------- diff --git a/06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs b/06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs index 53f131f8..1d5190ee 100644 --- a/06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs +++ b/06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage before the stack pointer is +/// actually set (`SP.set()`). #[no_mangle] pub unsafe fn _start() -> ! { use crate::runtime_init; diff --git a/07_uart_chainloader/README.md b/07_uart_chainloader/README.md index 378b6eb5..0b48ef90 100644 --- a/07_uart_chainloader/README.md +++ b/07_uart_chainloader/README.md @@ -179,8 +179,8 @@ diff -uNr 06_drivers_gpio_uart/Makefile 07_uart_chainloader/Makefile diff -uNr 06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs 07_uart_chainloader/src/_arch/aarch64/cpu.rs --- 06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs +++ 07_uart_chainloader/src/_arch/aarch64/cpu.rs -@@ -21,12 +21,12 @@ - #[naked] +@@ -22,12 +22,12 @@ + /// actually set (`SP.set()`). #[no_mangle] pub unsafe fn _start() -> ! { - use crate::runtime_init; @@ -194,7 +194,7 @@ diff -uNr 06_drivers_gpio_uart/src/_arch/aarch64/cpu.rs 07_uart_chainloader/src/ } else { // If not core0, infinitely wait for events. wait_forever() -@@ -55,3 +55,19 @@ +@@ -56,3 +56,19 @@ asm::wfe() } } diff --git a/07_uart_chainloader/src/_arch/aarch64/cpu.rs b/07_uart_chainloader/src/_arch/aarch64/cpu.rs index 3121e75e..bd974d4d 100644 --- a/07_uart_chainloader/src/_arch/aarch64/cpu.rs +++ b/07_uart_chainloader/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage before the stack pointer is +/// actually set (`SP.set()`). #[no_mangle] pub unsafe fn _start() -> ! { use crate::relocate; diff --git a/08_timestamps/README.md b/08_timestamps/README.md index b1244dce..3148aa3a 100644 --- a/08_timestamps/README.md +++ b/08_timestamps/README.md @@ -115,8 +115,8 @@ diff -uNr 07_uart_chainloader/Makefile 08_timestamps/Makefile diff -uNr 07_uart_chainloader/src/_arch/aarch64/cpu.rs 08_timestamps/src/_arch/aarch64/cpu.rs --- 07_uart_chainloader/src/_arch/aarch64/cpu.rs +++ 08_timestamps/src/_arch/aarch64/cpu.rs -@@ -21,12 +21,12 @@ - #[naked] +@@ -22,12 +22,12 @@ + /// actually set (`SP.set()`). #[no_mangle] pub unsafe fn _start() -> ! { - use crate::relocate; @@ -130,7 +130,7 @@ diff -uNr 07_uart_chainloader/src/_arch/aarch64/cpu.rs 08_timestamps/src/_arch/a } else { // If not core0, infinitely wait for events. wait_forever() -@@ -39,15 +39,6 @@ +@@ -40,15 +40,6 @@ pub use asm::nop; @@ -146,7 +146,7 @@ diff -uNr 07_uart_chainloader/src/_arch/aarch64/cpu.rs 08_timestamps/src/_arch/a /// Pause execution on the core. #[inline(always)] pub fn wait_forever() -> ! { -@@ -55,19 +46,3 @@ +@@ -56,19 +47,3 @@ asm::wfe() } } diff --git a/08_timestamps/src/_arch/aarch64/cpu.rs b/08_timestamps/src/_arch/aarch64/cpu.rs index 3f502ee0..eac29d8d 100644 --- a/08_timestamps/src/_arch/aarch64/cpu.rs +++ b/08_timestamps/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage before the stack pointer is +/// actually set (`SP.set()`). #[no_mangle] pub unsafe fn _start() -> ! { use crate::runtime_init; diff --git a/09_hw_debug_JTAG/src/_arch/aarch64/cpu.rs b/09_hw_debug_JTAG/src/_arch/aarch64/cpu.rs index 3f502ee0..eac29d8d 100644 --- a/09_hw_debug_JTAG/src/_arch/aarch64/cpu.rs +++ b/09_hw_debug_JTAG/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage before the stack pointer is +/// actually set (`SP.set()`). #[no_mangle] pub unsafe fn _start() -> ! { use crate::runtime_init; diff --git a/10_privilege_level/README.md b/10_privilege_level/README.md index c1e16287..a9035cec 100644 --- a/10_privilege_level/README.md +++ b/10_privilege_level/README.md @@ -225,8 +225,14 @@ Minipush 1.0 diff -uNr 09_hw_debug_JTAG/src/_arch/aarch64/cpu.rs 10_privilege_level/src/_arch/aarch64/cpu.rs --- 09_hw_debug_JTAG/src/_arch/aarch64/cpu.rs +++ 10_privilege_level/src/_arch/aarch64/cpu.rs -@@ -21,18 +21,59 @@ - #[naked] +@@ -18,22 +18,65 @@ + /// # Safety + /// + /// - Linker script must ensure to place this function where it is expected by the target machine. +-/// - We have to hope that the compiler omits any stack pointer usage before the stack pointer is +-/// actually set (`SP.set()`). ++/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up ++/// a stack for EL2. #[no_mangle] pub unsafe fn _start() -> ! { - use crate::runtime_init; @@ -252,6 +258,8 @@ diff -uNr 09_hw_debug_JTAG/src/_arch/aarch64/cpu.rs 10_privilege_level/src/_arch +/// - The HW state of EL1 must be prepared in a sound way. +/// - Exception return from EL2 must must continue execution in EL1 with +/// `runtime_init::runtime_init()`. ++/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up ++/// a stack for EL2. +#[inline(always)] +unsafe fn el2_to_el1_transition() -> ! { + use crate::runtime_init; diff --git a/10_privilege_level/src/_arch/aarch64/cpu.rs b/10_privilege_level/src/_arch/aarch64/cpu.rs index 3e5e5753..e546dd60 100644 --- a/10_privilege_level/src/_arch/aarch64/cpu.rs +++ b/10_privilege_level/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[no_mangle] pub unsafe fn _start() -> ! { // Expect the boot core to start in EL2. @@ -39,6 +40,8 @@ pub unsafe fn _start() -> ! { /// - The HW state of EL1 must be prepared in a sound way. /// - Exception return from EL2 must must continue execution in EL1 with /// `runtime_init::runtime_init()`. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[inline(always)] unsafe fn el2_to_el1_transition() -> ! { use crate::runtime_init; diff --git a/11_virtual_mem_part1_identity_mapping/src/_arch/aarch64/cpu.rs b/11_virtual_mem_part1_identity_mapping/src/_arch/aarch64/cpu.rs index 3e5e5753..e546dd60 100644 --- a/11_virtual_mem_part1_identity_mapping/src/_arch/aarch64/cpu.rs +++ b/11_virtual_mem_part1_identity_mapping/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[no_mangle] pub unsafe fn _start() -> ! { // Expect the boot core to start in EL2. @@ -39,6 +40,8 @@ pub unsafe fn _start() -> ! { /// - The HW state of EL1 must be prepared in a sound way. /// - Exception return from EL2 must must continue execution in EL1 with /// `runtime_init::runtime_init()`. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[inline(always)] unsafe fn el2_to_el1_transition() -> ! { use crate::runtime_init; diff --git a/12_exceptions_part1_groundwork/src/_arch/aarch64/cpu.rs b/12_exceptions_part1_groundwork/src/_arch/aarch64/cpu.rs index 3e5e5753..e546dd60 100644 --- a/12_exceptions_part1_groundwork/src/_arch/aarch64/cpu.rs +++ b/12_exceptions_part1_groundwork/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[no_mangle] pub unsafe fn _start() -> ! { // Expect the boot core to start in EL2. @@ -39,6 +40,8 @@ pub unsafe fn _start() -> ! { /// - The HW state of EL1 must be prepared in a sound way. /// - Exception return from EL2 must must continue execution in EL1 with /// `runtime_init::runtime_init()`. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[inline(always)] unsafe fn el2_to_el1_transition() -> ! { use crate::runtime_init; diff --git a/13_integrated_testing/README.md b/13_integrated_testing/README.md index 755576f9..e9509fd7 100644 --- a/13_integrated_testing/README.md +++ b/13_integrated_testing/README.md @@ -935,7 +935,7 @@ diff -uNr 12_exceptions_part1_groundwork/Makefile 13_integrated_testing/Makefile diff -uNr 12_exceptions_part1_groundwork/src/_arch/aarch64/cpu.rs 13_integrated_testing/src/_arch/aarch64/cpu.rs --- 12_exceptions_part1_groundwork/src/_arch/aarch64/cpu.rs +++ 13_integrated_testing/src/_arch/aarch64/cpu.rs -@@ -87,3 +87,20 @@ +@@ -90,3 +90,20 @@ asm::wfe() } } diff --git a/13_integrated_testing/src/_arch/aarch64/cpu.rs b/13_integrated_testing/src/_arch/aarch64/cpu.rs index 7d146d23..3e3ac706 100644 --- a/13_integrated_testing/src/_arch/aarch64/cpu.rs +++ b/13_integrated_testing/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[no_mangle] pub unsafe fn _start() -> ! { // Expect the boot core to start in EL2. @@ -39,6 +40,8 @@ pub unsafe fn _start() -> ! { /// - The HW state of EL1 must be prepared in a sound way. /// - Exception return from EL2 must must continue execution in EL1 with /// `runtime_init::runtime_init()`. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[inline(always)] unsafe fn el2_to_el1_transition() -> ! { use crate::runtime_init; diff --git a/14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/cpu.rs b/14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/cpu.rs index 7d146d23..3e3ac706 100644 --- a/14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/cpu.rs +++ b/14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[no_mangle] pub unsafe fn _start() -> ! { // Expect the boot core to start in EL2. @@ -39,6 +40,8 @@ pub unsafe fn _start() -> ! { /// - The HW state of EL1 must be prepared in a sound way. /// - Exception return from EL2 must must continue execution in EL1 with /// `runtime_init::runtime_init()`. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[inline(always)] unsafe fn el2_to_el1_transition() -> ! { use crate::runtime_init; diff --git a/15_virtual_mem_part2_mmio_remap/README.md b/15_virtual_mem_part2_mmio_remap/README.md index 44a9eebd..6dd7d630 100644 --- a/15_virtual_mem_part2_mmio_remap/README.md +++ b/15_virtual_mem_part2_mmio_remap/README.md @@ -311,7 +311,7 @@ Minipush 1.0 diff -uNr 14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/cpu.rs 15_virtual_mem_part2_mmio_remap/src/_arch/aarch64/cpu.rs --- 14_exceptions_part2_peripheral_IRQs/src/_arch/aarch64/cpu.rs +++ 15_virtual_mem_part2_mmio_remap/src/_arch/aarch64/cpu.rs -@@ -68,7 +68,7 @@ +@@ -71,7 +71,7 @@ ELR_EL2.set(runtime_init::runtime_init as *const () as u64); // Set up SP_EL1 (stack pointer), which will be used by EL1 once we "return" to it. diff --git a/15_virtual_mem_part2_mmio_remap/src/_arch/aarch64/cpu.rs b/15_virtual_mem_part2_mmio_remap/src/_arch/aarch64/cpu.rs index c68f1817..d8bcc895 100644 --- a/15_virtual_mem_part2_mmio_remap/src/_arch/aarch64/cpu.rs +++ b/15_virtual_mem_part2_mmio_remap/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[no_mangle] pub unsafe fn _start() -> ! { // Expect the boot core to start in EL2. @@ -39,6 +40,8 @@ pub unsafe fn _start() -> ! { /// - The HW state of EL1 must be prepared in a sound way. /// - Exception return from EL2 must must continue execution in EL1 with /// `runtime_init::runtime_init()`. +/// - We have to hope that the compiler omits any stack pointer usage, because we are not setting up +/// a stack for EL2. #[inline(always)] unsafe fn el2_to_el1_transition() -> ! { use crate::runtime_init; diff --git a/X1_JTAG_boot/jtag_boot_rpi3.img b/X1_JTAG_boot/jtag_boot_rpi3.img index 064b41a4..6d23c37d 100755 Binary files a/X1_JTAG_boot/jtag_boot_rpi3.img and b/X1_JTAG_boot/jtag_boot_rpi3.img differ diff --git a/X1_JTAG_boot/jtag_boot_rpi4.img b/X1_JTAG_boot/jtag_boot_rpi4.img index 44e2fb79..7517a699 100755 Binary files a/X1_JTAG_boot/jtag_boot_rpi4.img and b/X1_JTAG_boot/jtag_boot_rpi4.img differ diff --git a/X1_JTAG_boot/src/_arch/aarch64/cpu.rs b/X1_JTAG_boot/src/_arch/aarch64/cpu.rs index 3f502ee0..eac29d8d 100644 --- a/X1_JTAG_boot/src/_arch/aarch64/cpu.rs +++ b/X1_JTAG_boot/src/_arch/aarch64/cpu.rs @@ -17,8 +17,9 @@ use cortex_a::{asm, regs::*}; /// /// # Safety /// -/// - Linker script must ensure to place this function at `0x80_000`. -#[naked] +/// - Linker script must ensure to place this function where it is expected by the target machine. +/// - We have to hope that the compiler omits any stack pointer usage before the stack pointer is +/// actually set (`SP.set()`). #[no_mangle] pub unsafe fn _start() -> ! { use crate::runtime_init; diff --git a/rust-toolchain b/rust-toolchain index 9c4710ce..23eb5681 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2020-12-08" +channel = "nightly-2020-12-09" components = ["llvm-tools-preview"] targets = ["aarch64-unknown-none-softfloat"]