mirror of
https://github.com/apache/nuttx.git
synced 2026-10-04 04:38:10 +00:00
When an unprivileged task takes a fault the system cannot recover from, it now gets a fatal SIGSEGV and only that task ends. A fault in privileged code still panics. What decides it is the interrupted context, not the cause: the saved PS says whether the fault was taken in User Mode. A list of causes would leave every cause off the list as a way for a user task to stop the machine, and there are many -- a divide by zero, a privileged instruction, a load/store error, and an illegal instruction, which is how a refused fetch from kernel text arrives on this chip (TRM v1.8 p.699: a denied external-memory access is answered with 0xdeadbeaf instead of trapping). PS.UM is clear in a kernel thread, in a system call made on the user's behalf and in an interrupt handler, so those still panic. If the recoverable-fault dispatcher is enabled it still gets first refusal on causes 28, 29 and 20, the only ones re-executing can help. esp32s3_userfault_abort() records the exception frame as the task's context, dispatches SIGSEGV, and returns the redirected frame, so the vector's RFE resumes the task in the signal trampoline, whose default action exits it. CONFIG_ESP32S3_USERFAULT_ABORT enables it, default y wherever there is an unprivileged world, and selects SIG_DEFAULT and SIG_SIGKILL_ACTION. Verified on an ESP32-S3 DevKitC with a WROOM-2 module, esp32s3-devkit:kernel_oct: a user task that writes through NULL, reads a wild address, divides by zero, calls into a buffer of garbage or branches into kernel text is terminated on its own, while an unrelated task keeps running. Stack overflow is not contained. On the windowed ABI it faults inside the window overflow handler and arrives as a double exception with PS.UM already clear; guard pages are the answer, and separate work. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com> |
||
|---|---|---|
| .. | ||
| cmake | ||
| common | ||
| esp32 | ||
| esp32s2 | ||
| esp32s3 | ||
| lx6 | ||
| lx7 | ||
| .gitignore | ||
| CMakeLists.txt | ||
| Makefile | ||