From 2e15e18237f50ba61acc861a4bd23560d973e943 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Sat, 16 Nov 2019 13:16:39 +0100 Subject: [PATCH] bootloader: Sanitize global interrupt handling. We now disable interrupts before jumping to application, as overwriting the VTOR with interrupts enabled is rather risky. Also don't assume that interrupts are enabled when the bootloader is run -- enable them explicitly when we need them. --- src/bootloader/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/bootloader/main.rs b/src/bootloader/main.rs index ca459fd..afd28dc 100644 --- a/src/bootloader/main.rs +++ b/src/bootloader/main.rs @@ -40,6 +40,9 @@ use common::usb_serial; type Reg32 = register::Register; extern { + fn enable_interrupts(); + fn disable_interrupts(); + fn jump_to_application(address: u32); } @@ -84,6 +87,8 @@ pub unsafe extern fn main() { port::set_af(port::PORTE, 24, 1); port::set_pull(port::PORTE, 24, port::Pull::Up); + enable_interrupts(); + if application_missing() || bootloader_requested() { usb_serial::init(0xf055, USB_PID); @@ -95,5 +100,7 @@ pub unsafe extern fn main() { usb_serial::shutdown(); } + disable_interrupts(); + jump_to_application(APPLICATION_ADDR); } -- 2.30.2