You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "casaroli (via GitHub)" <gi...@apache.org> on 2026/10/13 16:27:17 UTC

[PR] arch/arm64: Start a user task with a fixed SPSR. [nuttx]

casaroli opened a new pull request, #20639:
URL: https://github.com/apache/nuttx/pull/20639

   ## Summary
   
   `arm64_jump_to_user()` built the SPSR of a new user task from `SPSR_EL1`, with only the mode bits cleared. `SPSR_EL1` holds the state of the last exception taken on that CPU. If the new task was switched out in a critical section before it reached user mode (for example, it waited for a lock), it resumes from an SVC taken with IRQs masked, and `SPSR_EL1` has the I bit set.
   
   The task then runs in EL0 with IRQs masked, for its whole life. Its system calls keep that state, and so do the children it creates with `fork()`. While it runs, its CPU takes no interrupt: a device interrupt routed to that CPU stays pending, and the timer cannot preempt the task.
   
   This PR sets a fixed SPSR: EL0t, with FIQ masked unless `CONFIG_ARM64_DECODEFIQ`, as `up_initial_state()` does for kernel threads.
   
   ## Impact
   
   arm64 protected and kernel builds. User tasks always start with IRQs enabled.
   
   ## Testing
   
   `qemu-armv8a:knsh` with 4 CPUs, with this change on a larger local branch, under a load that starts many processes in parallel:
   
   - Before: the system stopped. With gdb, 5 tasks had a saved user SPSR of `0x600000c0` (IRQs masked in EL0): 3 had started that way, 2 had inherited it from them by `fork()`. The virtio interrupt routed to the CPU of one of them stayed pending and enabled, and the threads waiting for it never woke up.
   - After: a debug check at the start of every system call found no caller in EL0 with IRQs masked, in a run of several hours.
   
   A simple test on the current master (100 processes started one after the other, on 1 and on 4 CPUs) does not trigger it: the new task must be switched out in a critical section before it reaches user mode.
   
   `ostest` on `qemu-armv8a:knsh` exits with status 0. Build: `qemu-armv8a:knsh`, `qemu-armv8a:knsh` with `CONFIG_ARM64_DECODEFIQ=y`, `imx93-evk:knsh` and `fvp-armv8r:pnsh`, no new warnings.
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm64: Start a user task with a fixed SPSR. [nuttx]

Posted by "casaroli (via GitHub)" <gi...@apache.org>.
casaroli closed pull request #20639: arch/arm64: Start a user task with a fixed SPSR.
URL: https://github.com/apache/nuttx/pull/20639


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm64: Start a user task with a fixed SPSR. [nuttx]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20639:
URL: https://github.com/apache/nuttx/pull/20639#issuecomment-6180144492

   <!-- nuttx-depends-on-bot run-38593975503 -->
   ### 🔗 Cross-repo PR dependencies
   
   The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
   
   - https://github.com/apache/nuttx/pull/20661 @ ccc733cf9a
   - https://github.com/apache/nuttx-apps/pull/3845 @ a088cd2b2e
   
   CI run: https://github.com/apache/nuttx/actions/runs/38593975503


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm64: Start a user task with a fixed SPSR. [nuttx]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20639:
URL: https://github.com/apache/nuttx/pull/20639#issuecomment-6158407332

   <!-- membrowse-pr-comment -->
   ## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
   
   *No memory changes detected for:*
   - [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=3f308e545f26095913cb4a4c4e0df11c2e278ef7&base=f6e5be7972fdbc2ca0a4bcaf4898907051858430)
   - [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=3f308e545f26095913cb4a4c4e0df11c2e278ef7&base=f6e5be7972fdbc2ca0a4bcaf4898907051858430)
   - [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=3f308e545f26095913cb4a4c4e0df11c2e278ef7&base=f6e5be7972fdbc2ca0a4bcaf4898907051858430)
   - [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=3f308e545f26095913cb4a4c4e0df11c2e278ef7&base=f6e5be7972fdbc2ca0a4bcaf4898907051858430)
   - [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=3f308e545f26095913cb4a4c4e0df11c2e278ef7&base=f6e5be7972fdbc2ca0a4bcaf4898907051858430)
   - [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=3f308e545f26095913cb4a4c4e0df11c2e278ef7&base=f6e5be7972fdbc2ca0a4bcaf4898907051858430)
   - [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=3f308e545f26095913cb4a4c4e0df11c2e278ef7&base=f6e5be7972fdbc2ca0a4bcaf4898907051858430)
   - [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=3f308e545f26095913cb4a4c4e0df11c2e278ef7&base=f6e5be7972fdbc2ca0a4bcaf4898907051858430)
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] arch/arm64: Start a user task with a fixed SPSR. [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #20639:
URL: https://github.com/apache/nuttx/pull/20639


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org