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

@ -187,6 +187,13 @@ int main()
// Turn on application mode.
// -------------------------
// Set up another stack because fw_ram is not available
// anymore in app_mode.
asm volatile(
"li sp, 0x40006ff0"
);
*switch_app = 1;
sw = *switch_app;