I have created the patch for this issue:
https://review.trustedfirmware.org/c/trusted-firmware-m/+/3359

The non-secure entry thread re-uses the same context and stack of initial booting thread, while initial booting thread would update the context in stack while SVC to SPM initialization. The context needs to be reset after SPM initialized all threads, and the EXC_RETURN is missed during the reset process.
If initial thread is executed with FP active, the EXC_RETURN generated by SVC would be 0xFFFFFFED, and cause extra 0x48 bytes to be popped while exiting from exception which causes the error. This patch resets the EXC_RETURN to 0xFFFFFFFD.

Please help to comment, thanks.

/Ken

From: TF-M <tf-m-bounces@lists.trustedfirmware.org> on behalf of Ken Liu via TF-M <tf-m@lists.trustedfirmware.org>
Sent: Wednesday, January 22, 2020 10:29 AM
To: tf-m@lists.trustedfirmware.org <tf-m@lists.trustedfirmware.org>
Cc: nd <nd@arm.com>
Subject: Re: [TF-M] Stuck in tfm_nspm_thread_entry() after "Initialize IPC SPM in handler mode"
 

Hi Andrej,

 

I double checked in my platforms and looks fine, so you are porting them to your board, right?

I have created a task for detailed description, let’s discuss the details there:

 

https://developer.trustedfirmware.org/T652

 

Thanks.

 

/Ken

 

From: Andrej Butok <andrey.butok@nxp.com>
Sent: Tuesday, January 21, 2020 11:19 PM
To: Ken Liu <Ken.Liu@arm.com>
Cc: tf-m@lists.trustedfirmware.org
Subject: RE: Stuck in tfm_nspm_thread_entry() after "Initialize IPC SPM in handler mode"

 

Hi Ken,

 

Yes, we are using L2.

I have just switched to the latest commit which includes the suggested fix.

But tfm_nspm_thread_entry() still goes to the MemManage_Handler() fault a bit later on "push     {r0, r1}       \n"

 

Thanks,

Andrej

 

From: TF-M <tf-m-bounces@lists.trustedfirmware.org> On Behalf Of Ken Liu via TF-M
Sent: Tuesday, January 21, 2020 6:05 AM
To: tf-m@lists.trustedfirmware.org
Cc: nd <nd@arm.com>
Subject: Re: [TF-M] Stuck in tfm_nspm_thread_entry() after "Initialize IPC SPM in handler mode"

 

Hi Andrej,

 

I guess you are using the level2 configuration. This fault was caused by tfm_nspm_thread_entry is trying to call a function in the privileged area.

 

This commit ‘cba90782908626f955fe361f803558181a85c6fc’ fixes this problem.

 

/Ken

 

From: TF-M <tf-m-bounces@lists.trustedfirmware.org> On Behalf Of Andrej Butok via TF-M
Sent: Tuesday, January 21, 2020 12:14 AM
To: tf-m@lists.trustedfirmware.org
Subject: [TF-M] Stuck in tfm_nspm_thread_entry() after "Initialize IPC SPM in handler mode"

 

Hello,

 

Just want to check if this is a known issue.

 

During synchronization to the latest TFM, TFM applications are stuck in the exception handler tfm_nspm_thread_entry ()=>MemManage_Handler().

 

This issue has been caused by commits (3.1.2020):

  1. Revision: 5248af2d7b86775364a0e131eb80ac0330bc81fb

Message: Core: Use naked function for ns jumping

  1. Revision: 490281df3736b11b62e25bc98d3e2c6e4e10478c  

Message: Core: Initialize IPC SPM in handler mode

 

The previous commit is fully OK (committed 2.1.2020):

Revision: 93dabfd3a35faf9ed88285e09997491e93cefa5c

Message: Core: Trigger a system reset for programmer error

 

The commits do not have any changes in the linker files and no changes in target files, only the common and ARMv8 code.

 

It’s good to know if this is something known or met before.

 

Thank you,

Andrej