hujun260 opened a new pull request, #22460:
URL: https://github.com/apache/nuttx/pull/22460
# arm64: support BMP SMP calls and secure-world doorbells
## Summary
Enable the ARM64 FVP BMP configuration to use the SMP-call infrastructure
and make `rptun_bmp` doorbell interrupts work correctly across CPU and
security-world boundaries.
## Problem
The ARM64 BMP configuration uses one NuttX instance per CPU/security world,
but the existing implementation assumed a conventional SMP configuration:
- The SMP-call source was not built for BMP/UP-style configurations.
- The FVP BMP configuration did not explicitly set `CONFIG_SMP_NCPUS=1`.
- The selected FVP SGIs overlapped with the NuttX SMP-call interrupt.
- Per-CPU SGI enable state was updated only on the calling CPU.
- Doorbell notification always targeted the configured CPU mask, which is
wrong when the peer runs in the other security state on the same physical core.
- Secure SGI forwarding did not pass the destination CPU mask through the
SMC call.
- ARM and ARM64 maintained separate SMCCC interfaces, making TrustZone
support harder to share and maintain.
## Changes
### BMP SMP-call support
- Build `arm64_smpcall.c` whenever the target is not an UP build, allowing
BMP to provide the SMP-call entry points.
- Attach the SMP-call handler in the ARM64 GICv3 initialization path for BMP.
- Enable the SMP-call interrupt for non-UP configurations.
- Guard the scheduler-specific handler with `CONFIG_SMP` so BMP can reuse
the common SMP-call path without requiring the full SMP scheduler configuration.
- Set `CONFIG_SMP_NCPUS=1` in the FVP `nsh_bmp` configuration.
### FVP SGI allocation
Move the FVP BMP/rptun SGIs away from the NuttX SMP-call SGI range, avoiding
interrupt-number overlap and allowing the scheduler SMP-call interrupt to
remain available.
### rptun doorbell routing
- Dispatch rptun BMP IRQ enable/disable operations to CPU0 through
`nxsched_cpu_call_single()` where required by the GIC per-CPU enable semantics.
- Enable the doorbell SGI on every CPU because each CPU may receive or send
the doorbell.
- When `remote_cpu` is empty, trigger the SGI on the current CPU so a peer
in the other security state can receive the doorbell on the corresponding
physical core.
- Preserve the configured CPU mask for non-empty `remote_cpu` values.
- Pass the destination CPU mask as the second argument when forwarding a
secure SGI through the monitor.
### TrustZone and SMCCC changes
- Add the foreign-interrupt SMC path used to yield from the secure-world
interrupt handling flow back to the non-secure world.
- Enable the secure FIQ path and associated FIQ stack setup for TrustZone
builds to avoid SMP scheduler deadlocks caused by asynchronous non-secure
interrupt routing.
- Add a panic notifier to switch back to the non-secure world before panic
handling.
- Consolidate shared SMCCC types, macros, declarations, and NuttX SPD
function IDs under the architecture-neutral ARM interface.
- Rename ARM64-specific SMCCC symbols to the shared `arm_`/`ARM_` form and
update callers.
- Remove obsolete `REG_EXE_DEPTH` handling and fix the related compile/link
issues.
## Testing
The following checks were run against the current `apache_20261127` branch
relative to `apache/master`.
### Diff whitespace check
```text
$ git diff --check apache/master..HEAD
[no output]
```
Result: **PASS** (`diff_check_rc=0`).
### Checkpatch
```text
$ ./tools/checkpatch.sh -g apache/master..HEAD
/home/hujun5/work/ssd/online_nuttx/nuttx/arch/arm/include/syscall.h:200:1:
error: Too many blank lines
Some checks failed. For contributing guidelines, see:
https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md
```
Result: **FAIL** (`checkpatch_rc=1`). The checkpatch failure is an existing
formatting issue in `arch/arm/include/syscall.h` at line 200 and should be
fixed before submission.
### Build/runtime validation
No clean FVP BMP build or runtime boot test was run in this workspace. The
existing `pr-22295-error-job-d07ed1ed.txt` contains CMake generation failures
and is not treated as validation for this change.
Recommended follow-up checks:
```text
$ ./tools/checkpatch.sh -g apache/master..HEAD
$ ./tools/configure.sh fvp-v8r:fvp-armv8r:nsh_bmp
$ make -j
```
The exact FVP configuration and runtime test should be recorded after the
checkpatch issue is corrected.
## Commit range
The requested change set starts at:
```text
8247618a6d0 fvp: change SGI int number avoid smp_call overlap
```
and the supplied log ends at:
```text
f545bc8ed43 rptun/arm64: let the doorbell follow the core that waits for it
```
The current local branch contains the corresponding rebased range through:
```text
2bed75ac10c arch/arm: unify SMCCC interface across arm and arm64
```
The range contains 31 modified files, with 364 insertions and 135 deletions
relative to `8247618a6d0^` through `f545bc8ed43`.
## Commits
```text
8247618a6d0 fvp: change SGI int number avoid smp_call overlap
107978a5e5e arch/arm64: support smp call in BMP
f0601bebcb4 fvp: we shoulde set CONFIG_SMP_NCPUS=1 in bmp
e79b6202934 fix compile error
29548010033 arm64: remove REG_EXE_DEPTH
d2d3e6335f7 arm64: avoid SMP deadlock in TrustZone interrupt yield
f412fe240d2 rptun/bmp: dispatch IRQ enable/disable to CPU0 via cpu_call
f827155af4a arch/arm: unify SMCCC interface across arm and arm64
f545bc8ed43 rptun/arm64: let the doorbell follow the core that waits for it
```
--
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]