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

   ## Summary
   
   This is the first of three parts of #19772, split as asked in review.
   
   It gives Xtensa `vfork()` and nothing else. No MMU, no address environment, 
no chip code.
   
   `up_fork(bool vfork)` is the architecture half of the primitive introduced 
by #19562. The child gets its own stack holding a relocated copy of the part of 
the parent's that is in use, and resumes where the caller would have returned.
   
   Two paths reach it. A flat build calls in directly, so the caller's 
registers are taken at the call. A build with system calls arrives through 
`xtensa_swint()`, which has already recorded the caller's frame in `xcp.sregs`; 
that frame is used instead, because the caller is on the far side of the 
boundary.
   
   The windowed ABI needs care in one place. A stack pointer has a base save 
area 16 bytes below it holding the caller's spilled `a0`–`a3`, and the frame 
chain runs through it. `SPILL_ALL_WINDOWS` puts the register file into memory 
first, and the chain is then walked and rebased onto the child's copy, because 
a frame pointer that still points into the parent's stack would send the child 
back into memory it does not own.
   
   ## Impact
   
   Xtensa gains `vfork()`. Nothing else changes, and no board configuration 
changes.
   
   `fork()` is not provided here. That needs an address environment and arrives 
in part three.
   
   ## Testing
   
   Board: ESP32-S3-DevKitC with an ESP32-S3-WROOM-1 N8R2, and an ESP32-DevKitC 
V4 with an ESP32-D0WD-V3 revision 3.1.
   
   Host: macOS 15 on Apple Silicon, `xtensa-esp32s3-elf-gcc` and 
`xtensa-esp32-elf-gcc`, both 12.2.0.
   
   | board | core | configuration | result |
   |---|---|---|---|
   | ESP32-S3-DevKitC | LX7 | `esp32s3-devkit:ostest` | `vfork()` passes, 
status 0 |
   | ESP32-DevKitC V4 | LX6 | `esp32-devkitc:ostest` | `vfork()` passes, status 
0 |
   
   ```
   user_main: vfork() test
   vfork_test: Started
   vfork_test: Child 5 ran and exited before the parent resumed
   ostest_main: Exiting with status 0
   ```
   
   Both Xtensa cores that NuttX supports are covered, and the LX6 has no MMU at 
all — which is the case this part is meant to serve.
   
   `tools/checkpatch.sh -c -u -m -g` reports no errors.
   
   depends-on: apache/nuttx-apps/pull/3685
   


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