xiaoxiang781216 commented on code in PR #19123:
URL: https://github.com/apache/nuttx/pull/19123#discussion_r3410754766


##########
arch/arm/src/armv8-m/Kconfig:
##########
@@ -155,3 +155,15 @@ config ARMV8M_CMSE
        bool "ARMv8-M Security Extensions"
        ---help---
                Enable ARMv8-M Security Extensions.
+
+config ARMV8M_SP_CONTEXT_RESTORE

Review Comment:
   this behavior isn't specific to cortex-m arch, it's better to move into 
nuttx/sched/Kconfig after line 1596 and depend on ENABLE_ALL_SIGNALS



##########
arch/arm/src/armv8-m/arm_exception.S:
##########
@@ -237,6 +235,78 @@ exception_common:
        ldmia           r0!, {r1}               /* Get psplim/msplim */
 #endif
 
+#ifdef CONFIG_ARMV8M_SP_CONTEXT_RESTORE
+       /* Check if the desired SP (r2) differs from the implied SP.
+        * The implied SP after exception return = r0 + hw_frame_size,
+        * where hw_frame_size depends on whether the frame includes FPU
+        * state (determined by EXC_RETURN bit 4 in r14).
+        * If they differ, we must relocate the HW frame so that the final
+        * SP after hardware pop equals the desired value (r2).
+        */
+
+       push            {r1, r3}                                /* Save psplim 
+ basepri on MSP */

Review Comment:
   it's more simple to do the context copy in c code(after `case 
SYS_signal_handler_return:`.



##########
arch/arm/src/armv8-m/arm_exception.S:
##########
@@ -237,6 +235,78 @@ exception_common:
        ldmia           r0!, {r1}               /* Get psplim/msplim */
 #endif
 
+#ifdef CONFIG_ARMV8M_SP_CONTEXT_RESTORE
+       /* Check if the desired SP (r2) differs from the implied SP.
+        * The implied SP after exception return = r0 + hw_frame_size,
+        * where hw_frame_size depends on whether the frame includes FPU
+        * state (determined by EXC_RETURN bit 4 in r14).
+        * If they differ, we must relocate the HW frame so that the final
+        * SP after hardware pop equals the desired value (r2).
+        */
+
+       push            {r1, r3}                                /* Save psplim 
+ basepri on MSP */
+
+#ifdef CONFIG_ARCH_FPU
+       /* Determine actual HW frame size from EXC_RETURN:
+        *   bit 4 set (STD_CONTEXT): 8 words = 32 bytes (no FPU)
+        *   bit 4 clear:            26 words = 104 bytes (with FPU)
+        */
+
+       tst             r14, #EXC_RETURN_STD_CONTEXT
+       ite             ne

Review Comment:
   use tab in all places to keep the alignment



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to