hujun260 opened a new pull request, #21760:
URL: https://github.com/apache/nuttx/pull/21760
# NuttX PR Description
## Title
nuttx/arch/sm: add the secure monitor setup procedure
## Description
This PR adds the ARMv7-A secure monitor runtime and implements switching
between the application processor (AP) and the trusted execution environment
(TEE) using SMC and FIQ mechanisms.
## Changes
- Add ARMv7-A secure monitor Kconfig support.
- Add Makefile integration for the secure monitor runtime.
- Add secure monitor startup and CPU initialization hooks:
- `arm_cpuhead.S`
- `arm_head.S`
- Add the secure monitor runtime implementation:
- `arm_sm_runtime.c`
- Add the secure monitor exception/vector implementation:
- `arm_sm_vector.S`
- Add secure monitor data structures, constants, and interfaces:
- `sm.h`
- Implement AP-to-TEE and TEE-to-AP world switching through SMC/FIQ paths.
## Motivation
Provide the secure monitor runtime required by ARMv7-A TrustZone systems and
allow the normal-world AP and secure-world TEE to switch execution contexts
through secure monitor calls and FIQ handling.
## Runtime Testing
The secure monitor flow was tested on the Vela ARM TrustZone environment. The
following log shows secure monitor initialization and AP/TEE world startup.
### Secure monitor and TrustZone startup
```text
NOTICE: Booting Trusted Firmware
INFO: Secure monitor runtime initialized
INFO: Secure monitor vector table installed
INFO: Secure monitor CPU context initialized
INFO: TrustZone monitor entered secure state
INFO: AP normal-world entry configured
INFO: TEE secure-world entry configured
```
### AP-to-TEE switch
```text
nsh> tee_switch
INFO: AP issuing SMC request to enter TEE
INFO: Secure monitor received SMC
INFO: Switching from normal world to secure world
INFO: TEE entry context restored
tee>
```
### TEE-to-AP switch
```text
tee> ree_switch
INFO: TEE issuing SMC request to return to AP
INFO: Secure monitor received FIQ/SMC return request
INFO: Switching from secure world to normal world
INFO: AP entry context restored
nsh>
```
### AP-side test
```text
nsh> ostest
...
user_main: smp call test
cpu_call_test: Call multi cpu, wait
cpu_call_test: Test success
user_main: Exiting
ostest_main: Exiting with status 0
nsh>
```
### TEE-side test
```text
tee> ostest
...
user_main: smp call test
cpu_call_test: Call multi cpu, wait
cpu_call_test: Test success
user_main: Exiting
ostest_main: Exiting with status 0
tee>
```
## Testing Status
- [x] Secure monitor runtime initialized successfully
- [x] AP-to-TEE SMC/FIQ switch verified
- [x] TEE-to-AP SMC/FIQ switch verified
- [x] AP-side `ostest` completed with status 0
- [x] TEE-side `ostest` completed with status 0
--
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]