cshung opened a new pull request, #3536:
URL: https://github.com/apache/nuttx-apps/pull/3536

   ## Summary
   
   Add a test application that verifies modifying `REG_R13` (SP) in saved 
register context during a signal handler is honored on exception return.
   
   **Test scenario** (simulates a managed runtime unwinding past a trampoline):
   1. Push values 1 and 2 onto the stack (simulating trampoline pushes)
   2. Wait for `SIGALRM` (async delivery from timer interrupt)
   3. Handler advances SP by 4 (emulates "pop" / unwind past one frame)
   4. Handler redirects PC to a resume function
   5. Resume function pops one value — verifies it equals 1 (not 2)
   
   This exercises the HW exception frame relocation fix in `arm_exception.S`.
   
   **Dependencies:**
   - Requires `CONFIG_ARMV7M_SP_CONTEXT_RESTORE=y` or 
`CONFIG_ARMV8M_SP_CONTEXT_RESTORE=y`
   - Flat build only (`BUILD_FLAT`) — accesses `nxsched_self()` for `saved_regs`
   - ARM architecture only
   
   Companion OS fix PR: https://github.com/apache/nuttx/pull/19123
   
   ## Impact
   
   - New test application only, no impact on existing code
   - Gated by Kconfig dependencies (will not appear unless SP context restore 
is enabled)
   
   ## Testing
   
   **Host:** Ubuntu 22.04 x86_64, arm-none-eabi-gcc 13.3, QEMU 8.2.2 (via 
Docker)
   
   **Targets tested:**
   - `lm3s6965-ek:qemu-flat` (ARMv7-M, Cortex-M3)
   - `mps2-an521:nsh` (ARMv8-M, Cortex-M33)
   
   **Test log (ARMv7-M):**
   ```
   nsh> sig_sp_test
   sig_sp_test: Signal SP restore test
   sig_sp_test: push 1, push 2, alarm, handler SP+=4, pop => 1
   sig_sp_test: handler - PC=0x00022770 SP=0x2000a9a8
   sig_sp_test: handler - new SP=0x2000a9ac PC=0x000226ac
   sig_sp_test: popped value = 1 (expected 1)
   sig_sp_test: PASS
   ```
   
   **Test log (ARMv8-M):**
   ```
   nsh> sig_sp_test
   sig_sp_test: Signal SP restore test
   sig_sp_test: push 1, push 2, alarm, handler SP+=4, pop => 1
   sig_sp_test: handler - PC=0x1002b2b8 SP=0x38007b08
   sig_sp_test: handler - new SP=0x38007b0c PC=0x1002b1fc
   sig_sp_test: popped value = 1 (expected 1)
   sig_sp_test: PASS
   ```
   
   **Sanity check (without SP adjustment in handler):**
   ```
   sig_sp_test: popped value = 2 (expected 1)
   sig_sp_test: FAIL - expected 1, got 2
   ```


-- 
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