fw/testfw: Use fw_ram for firmware stack

This means firmware's stack shouldn't be accessible to programs
running in app_mode.

It also means we don't need to take special care of secure_ctx which
can now be an ordinary stack variable.

Nonetheless we zero out secure_ctx after final use and inline some
assembler to zero out the entire fw_ram after use, just before
switching to app_mode.

Signed-off-by: Daniel Lublin <daniel@lublin.se>
This commit is contained in:
Michael Cardell Widerkrantz 2023-03-02 18:20:28 +01:00 committed by Daniel Lublin
parent d2240b3e0f
commit 56e34b3add
No known key found for this signature in database
GPG key ID: 75BD0FEB8D3E7830
3 changed files with 39 additions and 23 deletions

View file

@ -46,8 +46,10 @@ clear:
addi a0, a0, 4
blt a0, a1, clear
/* init stack below 0x40007000 (TK1_APP_ADDR) where we load app */
li sp, 0x40006ff0
/*
* Init stack at top of fw_ram. Leave 16 byte for entering our first function
*/
li sp, 0xd00003f0 // 1 kiB - 16 byte in FW_RAM
/* copy data section */
la a0, _sidata