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

   ## Summary
   
     * Why change is necessary (fix, update, new feature)?
       * Update/New capability: introduce `ARCH_HAVE_SYSCALL` Kconfig option to 
guard syscall-related compilation.
       * Fix/Improve: make `up_assert()` trigger `_assert` via a syscall path, 
so the assert can run on IRQ stack after IRQ stops tasks, reducing dependence 
on thread task context.
   
     * What functional part of the code is being changed?
       * Kconfig: add `ARCH_HAVE_SYSCALL` option.
       * Assertion / syscall path: `up_assert()` uses syscall to trigger 
`_assert`.
   
     * How does the change exactly work (what will change and how)?
       * Add `ARCH_HAVE_SYSCALL` to allow conditional compilation of 
syscall-related code paths.
       * Route `up_assert()` through a syscall to enter an assert handler 
(`_assert`) in a controlled context (IRQ can stop all tasks; using IRQ stack to 
do assert reduces thread task involvement).
       * Related commits:
         * `Kconfig:add ARCH_HAVE_SYSCALL option`
         * `add up_assert using syscall to trigger _assert`
   
     * Related NuttX Issue reference if applicable.
       * N/A
   
     * Related NuttX Apps Issue / Pull Request reference if applicable.
       * N/A
   
   ## Impact
   
     * Is new feature added? Is existing feature changed? NO / YES (please 
describe if yes).
       * YES: new Kconfig option `ARCH_HAVE_SYSCALL`; assert flow changed to 
support syscall-triggered `_assert`.
   
     * Impact on user (will user need to adapt to change)? NO / YES (please 
describe if yes).
       * NO (expected transparent), unless an architecture/board relies on a 
different assert flow and has special constraints around syscalls.
   
     * Impact on build (will build process change)? NO / YES (please describe 
if yes).
       * NO.
   
     * Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO / 
YES (please describe if yes).
       * YES: affects architectures/boards that enable syscall support and use 
`up_assert()`.
   
     * Impact on documentation (is update required / provided)? NO / YES 
(please describe if yes).
       * NO.
   
     * Impact on security (any sort of implications)? NO / YES (please describe 
if yes).
       * NO.
   
     * Impact on compatibility (backward/forward/interoperability)? NO / YES 
(please describe if yes).
       * YES: behavior change in assert handling on syscall-capable 
architectures; should remain compatible but needs review on affected targets.
   
     * Anything else to consider or add?
       * N/A
   
   ## Testing
   
     I confirm that changes are verified on local setup and works as intended:
     * Build Host(s): Ubuntu 24.04
     * Compiler: N/A (not captured)
     * Target(s): mps3-an547:nsh (QEMU)
     * Run command:
   
     ```
     qemu-system-arm -M mps3-an547 -m 2G -nographic -kernel build/nuttx.bin 
-gdb tcp::1127
     ```
   
     Testing logs before change:
   
     ```
     N/A (baseline log not captured)
     ```
   
     Testing logs after change:
   
     ```
     ➜ qemu-system-arm -M mps3-an547 -m 2G -nographic -kernel build/nuttx.bin 
-gdb tcp::1127
     ERROR: Failed to mount romfs at /mnt: -22
   
     NuttShell (NSH) NuttX-12.7.2
     nsh>
     nsh>
     nsh>
     nsh>
     nsh> ostest
     stdio_test: write fd=1
     stdio_test: Standard I/O Check: printf
     stdio_test: write fd=2
     ostest_main: putenv(Variable1=BadValue3)
     ostest_main: setenv(Variable1, GoodValue1, TRUE)
     ostest_main: setenv(Variable2, BadValue1, FALSE)
     ostest_main: setenv(Variable2, GoodValue2, TRUE)
     ostest_main: setenv(Variable3, GoodValue3, FALSE)
     ostest_main: setenv(Variable3, BadValue2, FALSE)
     show_variable: Variable=Variable1 has value=GoodValue1
     show_variable: Variable=Variable2 has value=GoodValue2
     show_variable: Variable=Variable3 has value=GoodValue3
     ostest_main: Started user_main at PID=4
   
     user_main: Begin argument test
     user_main: Started with argc=5
     user_main: argv[0]="ostest"
     user_main: argv[1]="Arg1"
     user_main: argv[2]="Arg2"
     user_main: argv[3]="Arg3"
     user_main: argv[4]="Arg4"
   
     End of test memory usage:
     VARIABLE  BEFORE   AFTER
     ======== ======== ========
     arena    801fb964 801fb964
     ordblks         2        2
     mxordblk 7ffffff0 7ffffff0
     uordblks     6434     6434
     fordblks 801f5530 801f5530
   
     user_main: getopt() test
     getopt():  Simple test
     getopt():  Invalid argument
     getopt():  Missing optional argument
     getopt_long():  Simple test
     getopt_long():  No short options
     getopt_long():  Argument for --option=argument
     getopt_long():  Invalid long option
     getopt_long():  Mixed long and short options
     getopt_long():  Invalid short option
     getopt_long():  Missing optional arguments
     getopt_long_only():  Mixed long and short options
     getopt_long_only():  Single hyphen long options
   
     End of test memory usage:
     VARIABLE  BEFORE   AFTER
     ======== ======== ========
     arena    801fb964 801fb964
     ordblks         2        2
     mxordblk 7ffffff0 7ffffff0
     uordblks     6434     6434
     fordblks 801f5530 801f5530
   
     user_main: libc tests
   
     End of test memory usage:
     VARIABLE  BEFORE   AFTER
     ======== ======== ========
     arena    801fb964 801fb964
     ordblks         2        2
     mxordblk 7ffffff0 7ffffff0
     uordblks     6434     6434
     fordblks 801f5530 801f5530
     show_variable: Variable=Variable1 has value=GoodValue1
     show_variable: Variable=Variable2 has value=GoodValue2
     show_variable: Variable=Variable3 has value=GoodValue3
     show_variable: Variable=Variable1 has no value
     show_variable: Variable=Variable2 has value=GoodValue2
     show_variable: Variable=Variable3 has value=GoodValue3
   
     End of test memory usage:
     VARIABLE  BEFORE   AFTER
     ======== ======== ========
     arena    801fb964 801fb964
     ordblks         2        3
     mxordblk 7ffffff0 7ffffff0
     uordblks     6434     6414
     fordblks 801f5530 801f5550
     show_variable: Variable=Variable1 has no value
     show_variable: Variable=Variable2 has no value
     show_variable: Variable=Variable3 has no value
   
     End of test memory usage:
     VARIABLE  BEFORE   AFTER
     ======== ======== ========
     arena    801fb964 801fb964
     ordblks         3        3
     mxordblk 7ffffff0 7ffffff0
     uordblks     6414     639c
     fordblks 801f5550 801f55c8
   
     user_main: setvbuf test
     setvbuf_test: Test NO buffering
     setvbuf_test: Using NO buffering
     setvbuf_test: Test default FULL buffering
     setvbuf_test: Using default FULL buffering
     setvbuf_test: Test FULL buffering, buffer size 64
     setvbuf_test: Using FULL buffering, buffer size 64
     setvbuf_test: Test FULL buffering, pre-allocated buffer
     setvbuf_test: Using FULL buffering, pre-allocated buffer
     setvbuf_test: Test LINE buffering, buffer size 64
     setvbuf_test: Using LINE buffering, buffer size 64
     setvbuf_test: Test FULL buffering, pre-allocated buffer
     setvbuf_test: Using FULL buffering, pre-allocated buffer
   
     End of test memory usage:
     VARIABLE  BEFORE   AFTER
     ======== ======== ========
     arena    801fb964 801fb964
     ordblks         3        3
     mxordblk 7ffffff0 7ffffff0
     uordblks     639c     639c
     fordblks 801f55c8 801f55c8
   
     user_main: /dev/null test
     dev_null: Read 0 bytes from /dev/null
     dev_null: Wrote 1024 bytes to /dev/null
   
     End of test memory usage:
     VARIABLE  BEFORE   AFTER
     ======== ======== ========
     arena    801fb964 801fb964
     ordblks         3        3
     mxordblk 7ffffff0 7ffffff0
     uordblks     639c     639c
     fordblks 801f55c8 801f55c8
   
     user_main: FPU test
     Starting task FPU#1
     fpu_test: Started task FPU#1 at PID=5
     FPU#1: pass 1
     Starting task FPU#2
     fpu_test: Started task FPU#2 at PID=6
     FPU#2: pass 1
     FPU#1: pass 2
     FPU#2: pass 2
     FPU#1: pass 3
     FPU#2: pass 3
     FPU#1: pass 4
     FPU#2: pass 4
     FPU#1: pass 5
     FPU#2: pass 5
     FPU#1: pass 6
     FPU#2: pass 6
     FPU#1: pass 7
     FPU#2: pass 7
     FPU#1: pass 8
     FPU#2: pass 8
     FPU#1: pass 9
     FPU#2: pass 9
     FPU#1: pass 10
     FPU#2: pass 10
     FPU#1: pass 11
     FPU#2: pass 11
     FPU#1: pass 12
     FPU#2: pass 12
     FPU#1: pass 13
     FPU#2: pass 13
     FPU#1: pass 14
     FPU#2: pass 14
     FPU#1: pass 15
     FPU#2: pass 15
     FPU#1: pass 16
     FPU#2: pass 16
     FPU#1: Succeeded
     FPU#2: Succeeded
     fpu_test: Returning
   
     End of test memory usage:
     VARIABLE  BEFORE   AFTER
     ======== ======== ========
     arena    801fb964 801fb964
     ordblks         3        5
     mxordblk 7ffffff0 7ffffff0
     uordblks     639c     854c
     fordblks 801f55c8 801f3418
   
     user_main: task_restart test
   
     Test task_restart()
     restart_main: setenv(VarName, VarValue, TRUE)
     restart_main: Started restart_main at PID=7
     restart_main: Started with argc=4
     restart_main: argv[0]="ostest"
     restart_main: argv[1]="This is argument 1"
     restart_main: argv[2]="Argument 2 here"
     restart_main: argv[3]="Lastly, the 3rd argument"
     restart_main: Variable=VarName has value=VarValue
     restart_main: I am still here
     restart_main: I am still here
     restart_main: Started restart_main at PID=7
     restart_main: Started with argc=4
     restart_main: argv[0]="ostest"
     restart_main: argv[1]="This is argument 1"
     restart_main: argv[2]="Argument 2 here"
     restart_main: argv[3]="Lastly, the 3rd argument"
     restart_main: Variable=VarName has value=VarValue
     restart_main: Started with argc=4
     restart_main: argv[0]="ostest"
     restart_main: argv[1]="This is argument 1"
     restart_main: argv[2]="Argument 2 here"
     restart_main: argv[3]="Lastly, the 3rd argument"
     restart_main: Variable=VarName has value=VarValue
     restart_main: Exiting
   
     End of test memory usage:
     VARIABLE  BEFORE   AFTER
     ======== ======== ========
     arena    801fb964 801fb964
     ordblks         5        4
     mxordblk 7ffffff0 7ffffff0
     uordblks     854c     84ac
     fordblks 801f3418 801f34b8
   
     user_main: waitpid test
     ...
     user_main: Exiting
     ostest_main: Exiting with status 0
     stdio_test: Standard I/O Check: fprintf to stderr
     nsh>
     ```
   
   ## PR verification Self-Check
   
     * [X] This PR introduces only one functional change.
     * [X] I have updated all required description fields above.
     * [X] My PR adheres to Contributing Guidelines and Documentation (git 
commit title and message, coding standard, etc).
     * [ ] My PR is still work in progress (not ready for review).
     * [X] My PR is ready for review and can be safely merged into a codebase.


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