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

   # drivers/tee: add dummy OP-TEE server driver
   
   ## Summary
   
   Add a dummy OP-TEE driver for the server side of an OP-TEE deployment where 
the TEE shares memory with a Rich Execution Environment (REE) through RPMsg.
   
   The driver announces the OP-TEE RPMsg service channel so that the REE-side 
TEE backend can bind to it. It does not create a TEE character device and does 
not implement the OP-TEE request protocol itself.
   
   ## Changes
   
   - Add `drivers/tee/optee_dummy.c`.
   - Add the `CONFIG_DEV_OPTEE_DUMMY` configuration option.
   - Exclude the client implementations when the dummy server implementation is 
selected.
   - Add the source to both Make and CMake builds.
   - Register the RPMsg endpoint from the `device_created` callback, after an 
RPMsg device becomes available.
   - Allocate one endpoint context per RPMsg device.
   - Release endpoint contexts through the RPMsg endpoint release callback.
   - Keep `optee_register()` as the common registration entry point used by the 
existing caller.
   - Document the server-side dummy driver in the OP-TEE guide.
   
   ## Design
   
   The server-side driver only announces this RPMsg service channel:
   
   ```text
   OPTEE_RPMSG_SERVICE
   ```
   
   The requests continue to travel through the OP-TEE service socket. The RPMsg 
endpoint is therefore a sink and uses a no-op callback because 
`rpmsg_create_ept()` requires a non-NULL callback.
   
   Endpoint lifetime is tied to the RPMsg device. The release callback is 
installed only after endpoint creation succeeds, avoiding a second free if 
endpoint creation fails after taking a reference.
   
   ## Configuration
   
   Enable the server-side implementation with:
   
   ```text
   CONFIG_DEV_OPTEE_DUMMY=y
   ```
   
   This option is part of the same implementation choice as the local, RPMsg, 
and SMC client drivers. It does not register `/dev/tee0`; it only announces the 
RPMsg channel used by the REE-side client.
   
   ## Testing
   
   The change was checked for both build-system paths:
   
   - `drivers/tee/Make.defs`
   - `drivers/tee/CMakeLists.txt`
   
   ### Checkpatch
   
   ```text
   $ git diff --check
   
   $ tools/checkpatch.sh -g apache/master..HEAD
   ✔️ All checks pass.
   ```
   
   ### Build and runtime log
   
   The OP-TEE REE image and RPMsg kernel modules were built successfully:
   
   ```text
   BUILD OK
   Vela RPMsg modules ready for kernel 6.12.23-gdf11e17b7af2-dirty
   rootfs.cpio.gz: 2280977 bytes, 345 entries
   ```
   
   The QEMU OP-TEE/REE image then booted successfully with four CPUs:
   
   ```text
   INFO:    NUTTXSPD: BL32 CPU0 entry done
   INFO:    NUTTXSPD: BL32 CPU1 entry done
   INFO:    NUTTXSPD: BL32 CPU2 entry done
   INFO:    NUTTXSPD: BL32 CPU3 entry done
   [    0.088753] smp: Brought up 1 node, 4 CPUs
   [    0.088784] SMP: Total of 4 processors activated.
   ```
   
   The REE discovered the RPMsg services, including the OP-TEE channel:
   
   ```text
   [    1.251222] virtio_rpmsg_bus virtio5: rpmsg_ns: creating channel 
rpmsg-syslog addr 0x400
   [    1.252491] virtio_rpmsg_bus virtio5: rpmsg_ns: creating channel 
rpmsg-ttyTEE addr 0x401
   [    1.253411] virtio_rpmsg_bus virtio5: rpmsg_ns: creating channel 
rpmsg-tee addr 0x402
   [    1.489939] rpmsg-tee virtio5.rpmsg-tee.-1.1026: registered, shm 
allocated on demand
   ```
   
   The REE-side OP-TEE client and RPMsg character devices were present in the
   integration run:
   
   ```text
   /dev/rpmsg-ping-rt-tee  /dev/rpmsg-ping-tee
   crw-------    1 root     root      247,   0 Nov 14 04:40 /dev/tee0
   ```
   
   The `/dev/tee0` device belongs to the REE-side OP-TEE client. The dummy
   server driver in this PR does not create `/dev/tee0`; it announces the RPMsg
   service channel used by that client.
   
   OP-TEE regression tests completed with zero failures:
   
   ```text
   xtest(4001) exit=0
   356 subtests of which 0 failed
   regression_4001 OK
   
   xtest(4002) exit=0
   2176 subtests of which 0 failed
   regression_4002 OK
   
   xtest(5006) exit=0
   33 subtests of which 0 failed
   regression_5006 OK
   
   TEE test application done!
   QEMU: Terminated
   ```
   
   Some OP-TEE subcases were skipped as reported by `xtest` (`103 test cases
   were skipped`), and the complete run also printed expected teardown messages
   for dynamically created `s:optee:<id>` RPMsg channels.
   
   ## Commit
   
   ```text
   0b981452a56 drivers/tee: add dummy OP-TEE server driver
   ```
   


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