Hi,

 

I’m working on a change, which is solve your problem, please check:

https://review.trustedfirmware.org/c/TF-M/trusted-firmware-m/+/16356/2

In the updated startup files psp, psplim and msplim are set to the main stack top and bottom.

This formula is coming from the official CMSIS repo, for the M55 core please check:

https://github.com/ARM-software/CMSIS_5/blob/5.9.0/Device/ARM/ARMCM55/Source/startup_ARMCM55.c#L128..L129

 

David

 

From: Antonio De Angelis via TF-M <tf-m@lists.trustedfirmware.org>
Sent: 05 October 2022 14:31
To: tf-m@lists.trustedfirmware.org
Subject: [TF-M] Re: Enable stack protection in the regression tests

 

Hi,

 

Currently TF-M tests or the reference NS app don’t set the MSPLIM, but I think that it wouldn’t be a big change to implement that.

 

You could use CMSIS-CORE and in particular __set_MSPLIM(uint32_t MainStackPtrLimit), where the value of MainStackPtrLimit could be platform-dependent. You could call this function from the NS main, before triggering the test threads.

CMSIS-CORE reference is here: Core Register Access (keil.com)

 

Thanks,

Antonio

 

From: Andersson, Joakim via TF-M <tf-m@lists.trustedfirmware.org>
Sent: Wednesday, October 5, 2022 08:36
To: Swarowsky, Markus <Markus.Swarowsky@nordicsemi.no>; tf-m@lists.trustedfirmware.org
Subject: [TF-M] Re: Enable stack protection in the regression tests

 

Can anyone confirm or deny if enabling stack protection in the TF-M non-secure application is possible?

 

-Joakim Andersson

 

From: Swarowsky, Markus via TF-M <tf-m@lists.trustedfirmware.org>
Sent: torsdag 29. september 2022 16:49
To: tf-m@lists.trustedfirmware.org
Subject: [TF-M] Enable stack protection in the regression tests

 

Hey,


While trying to debug a crash in the TF-M regression tests, I noticed that the msplim_ns register is set to 0x0, leaving the non-secure application without any stack to protection, sadly I wasn't able to figure out how to enable the stack protection, which would be nice as we suspect that a stack overflow could cause the crash.

Therefore, I would be interested if it possible to enable stack protection for the non-secure application of the TF-M regression tests and if so, how?



Thanks for the help

Markus Swarowsky | R & D Engineer
M +47 404 66 922 | Trondheim, Norway

nordicsemi.com | devzone.nordicsemi.com

Facebook | LinkedIn | Twitter | YouTube | Instagram

 

Nordic_logo_signature