mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
setup: Switch to unprivileged execution
This commit is contained in:
parent
a00ac050e5
commit
e3a0b6e7b4
@ -102,13 +102,13 @@ int main(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
timer_init();
|
||||
|
||||
#ifdef APPVER
|
||||
// enable MPU (Memory Protection Unit)
|
||||
mpu_config();
|
||||
#endif
|
||||
|
||||
timer_init();
|
||||
|
||||
#if DEBUG_LINK
|
||||
oledSetDebugLink(1);
|
||||
storage_wipe();
|
||||
|
3
setup.c
3
setup.c
@ -193,4 +193,7 @@ void mpu_config(void)
|
||||
|
||||
__asm__ volatile("dsb");
|
||||
__asm__ volatile("isb");
|
||||
|
||||
// Switch to unprivileged software execution to prevent access to MPU
|
||||
set_mode_unprivileged();
|
||||
}
|
||||
|
6
util.h
6
util.h
@ -66,6 +66,12 @@ static inline void __attribute__((noreturn)) load_vector_table(const vector_tabl
|
||||
// Prevent compiler from generating stack protector code (which causes CPU fault because the stack is moved)
|
||||
for (;;);
|
||||
}
|
||||
|
||||
static inline void set_mode_unprivileged(void)
|
||||
{
|
||||
// http://infocenter.arm.com/help/topic/com.arm.doc.dui0552a/CHDBIBGJ.html
|
||||
__asm__ volatile("msr control, %0" :: "r" (0x1));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user