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

   # NuttX PR Description
   
   ## Title
   
   arm64/smp: skip PSCI CPU_ON when running as TrustZone secure OS
   
   ## Description
   
   This PR updates ARM64 secondary CPU startup for TrustZone secure-world 
builds.
   When `CONFIG_ARCH_TRUSTZONE_SECURE` is enabled, NuttX runs in the secure 
world
   at EL1-S and the higher-level firmware, such as TF-A BL31, is responsible for
   releasing secondary CPUs.
   
   The secure OS therefore skips the PSCI `CPU_ON` request instead of issuing an
   unnecessary secure-side call that would transition to EL3 and bounce back.
   
   ## Changes
   
   - Guard the PSCI-based secondary CPU startup path with:
   
     ```c
     #ifndef CONFIG_ARCH_TRUSTZONE_SECURE
     ```
   
   - Guard the `cpu_mpid` local variable with the same condition because it is 
only
     needed by the PSCI `CPU_ON` path.
   - Preserve the existing PSCI CPU startup behavior for non-secure and normal
     ARM64 configurations.
   
   ## Motivation
   
   Avoid unnecessary PSCI calls from the TrustZone secure OS. Secondary CPUs are
   already released by the higher-level firmware in this boot flow, so invoking
   `psci_cpu_on()` from secure EL1 is redundant and may cause an unnecessary EL3
   round trip.
   
   ## Runtime Testing
   
   The following runtime log was captured from the Vela QEMU ARM64 TrustZone
   environment using four Cortex-A53 CPUs and Trusted Firmware-A.
   
   ### Trusted Firmware-A and BL32 initialization
   
   ```text
   NOTICE:  Booting Trusted Firmware
   NOTICE:  BL1: v2.14.0(debug):fb1381d84
   INFO:    BL2: Loading image id 4
   INFO:    Handoff to BL32
   NOTICE:  BL1: Booting BL31
   INFO:    NUTTXSPD: BL32 ep=0xe100000
   INFO:    BL31: Initializing BL32
   INFO:    NUTTXSPD: BL32 CPU0 entry done
   INFO:    NUTTXSPD: BL32 CPU1 entry done
   INFO:    NUTTXSPD: BL32 CPU2 entry done
   INFO:    NUTTXSPD: BL32 CPU3 entry done
   INFO:    Entry point address = 0x40280000
   ```
   
   The log shows that BL31 released and entered all four BL32 CPUs without a
   secure-world `psci_cpu_on()` request.
   
   ### AP and TEE initialization
   
   ```text
   0.382308  8 I 0 ap pci_sdhci_probe: SDHCI controller at 10001000 irq=37
   0.383143  8 I 0 ap pci_ivshmem_probe: shmem addr=0x8000400000 size=4194304 
reg=0x10001100
   NuttX  12.7.2 49d23ab02201-dirty Nov 10 2026 13:39:07 arm64 ap
   
   21 I 0 tee D/TC:0 21 call_initcalls:40 level 1 register_time_source()
   21 I 0 tee D/TC:0 21 call_initcalls:40 level 3 tee_cryp_init()
   21 I 0 tee D/TC:0 21 call_initcalls:40 level 4 host_fs_init()
   21 I 0 tee D/TC:0 21 host_fs_init:162 host fs init success
   21 I 0 tee D/TC:0 21 call_initcalls:40 level 6 default_mobj_init()
   ```
   
   ### AP-side `ostest`
   
   ```text
   qemu-armv8a-ap> ostest
   ...
   user_main: smp call test
   cpu_call_test: Call cpu 0, wait
   cpu_call_test: Call cpu 1, wait
   cpu_call_test: Call cpu 2, wait
   cpu_call_test: Call cpu 3, wait
   cpu_call_test: Call multi cpu, wait
   cpu_call_test: Test success
   user_main: Exiting
   ostest_main: Exiting with status 0
   ```
   
   ### TEE-side `ostest`
   
   ```text
   tee> ostest
   ...
   user_main: smp call test
   cpu_call_test: Call cpu 0, wait
   cpu_call_test: Call cpu 1, wait
   cpu_call_test: Call cpu 2, wait
   cpu_call_test: Call cpu 3, wait
   cpu_call_test: Call multi cpu, wait
   cpu_call_test: Test success
   user_main: Exiting
   ostest_main: Exiting with status 0
   ```
   
   ## Testing Status
   
   - [x] Runtime-tested on Vela QEMU ARM64 TrustZone
   - [x] All four CPUs entered BL32 successfully
   - [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]

Reply via email to