mirror of
https://github.com/openharmony/tee_tee_tzdriver.git
synced 2026-07-01 06:41:57 -04:00
@@ -1,52 +1,78 @@
|
||||
# Tzdriver Module Introduction<a name="ZH-CN_TOPIC_0000001078530726"></a>
|
||||
# Tzdriver driver
|
||||
|
||||
- [Introduction](#section469617221261)
|
||||
- [tzdriver project Structure](#section15884114210197)
|
||||
- [secondary Directories structure](#section1464106163817)
|
||||
## Introduction
|
||||
|
||||
## Introduction<a name="section469617221261"></a>
|
||||
Tzdriver is a kernel driver deployed on the REE side, supporting communication between REE and TEE. Tzdriver processes commands from Tee Client and sends instructions to switch from REE to TEE. Tzdriver supports data sharing between REE and TEE by managing shared memory.
|
||||
|
||||
tzdriver is a part of REE. The REE module provides a set of rich execution environment \(REE\) API components for interacting with TEEOS, including tzdriver \(driver\), libteec \(API library\), and teecd \(agent service\). This module tzdriver normally is a part of kernel, sometimes could be ko(kernel module).
|
||||
Tzdriver includes the following main modules:
|
||||
|
||||
## Tzdriver project Structure<a name="section15884114210197"></a>
|
||||
smc: Send smc instructions to switch the CPU from the REE side to the TEE side for operation.
|
||||
|
||||
tee_tzdriver:project directory
|
||||
- README.md&README_zh.md:Introduction file
|
||||
- LICENSE:GPL v2 LICENSE
|
||||
- linux:tzdriver for linux kernel
|
||||
- liteos:tzdriver for liteos_a kernel
|
||||
session_manager: Manage communication sessions between REE and TEE.
|
||||
|
||||
## Secondary Directories structure<a name="section1464106163817"></a>
|
||||
mailbox:Data is shared between REE and TEE through the mailbox.
|
||||
|
||||
**Table 1** tzdriver main secondary source code structure
|
||||
cmd_monitor:Monitor the operation of SMC instructions and provides a timeout detection mechanism.
|
||||
|
||||
<a name="table2977131081412"></a>
|
||||
<table><thead align="left"><tr id="row7977610131417"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p18792459121314"><a name="p18792459121314"></a><a name="p18792459121314"></a>main secondary directory</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p77921459191317"><a name="p77921459191317"></a><a name="p77921459191317"></a>description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row17977171010144"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1836912441194"><a name="p1836912441194"></a><a name="p1836912441194"></a>core</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p2549609105"><a name="p2549609105"></a><a name="p2549609105"></a>core function code, include:smc, agent...</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row6978161091412"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p64006181102"><a name="p64006181102"></a><a name="p64006181102"></a>tlogger</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p7456843192018"><a name="p7456843192018"></a><a name="p7456843192018"></a>for tee log</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row6978201031415"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1978910485104"><a name="p1978910485104"></a><a name="p1978910485104"></a>auth</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1059035912204"><a name="p1059035912204"></a><a name="p1059035912204"></a>for authentication</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1897841071415"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p182586363119"><a name="p182586363119"></a><a name="p182586363119"></a>include</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p19278126102113"><a name="p19278126102113"></a><a name="p19278126102113"></a>export header files</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
tzdebug:Create debugfs debugging nodes to facilitate developers in debugging TEE functionality
|
||||
|
||||
tlogger:TEE log driver module, supporting TEE log recording and printing.
|
||||
|
||||
Figure 1: Tzdriver architecture diagram
|
||||
|
||||

|
||||
|
||||
## Directory
|
||||
|
||||
```
|
||||
base/tee/tee_tzdriver
|
||||
├── core
|
||||
│ ├── cmdmonitor.c # SMC instruction execution monitoring
|
||||
├── gp_ops.c # GP TEE specification processing logic
|
||||
├── mailbox_mempool.c # REE and TEE shared memory management
|
||||
├── session_manager.c # Session management for CA access to TA
|
||||
├── smc_smp.c # Send SMC command to switch to TEE
|
||||
├── tzdebug.c # Debugging module
|
||||
├── tlogger # TEE log driver
|
||||
```
|
||||
|
||||
## Configuration Option
|
||||
|
||||
If you want to enable the Tzdriver driver, you need to modify the defconfig file of the device in the Linux kernel code repository and add configuration options for Tzdriver:
|
||||
|
||||
```
|
||||
#
|
||||
# TEEOS
|
||||
#
|
||||
CONFIG_TZDRIVER=y
|
||||
CONFIG_CPU_AFF_NR=1
|
||||
CONFIG_KERNEL_CLIENT=y
|
||||
CONFIG_TEELOG=y
|
||||
CONFIG_PAGES_MEM=y
|
||||
CONFIG_THIRDPARTY_COMPATIBLE=y
|
||||
```
|
||||
|
||||
The meanings of each option are shown in the table below:
|
||||
|
||||
**Table 1** Configuration Options Description
|
||||
|
||||
| Parameters | Description |
|
||||
| ---------------------------- | ------------------------------------------------------------ |
|
||||
| CONFIG_TZDRIVER | Tzdriver module switch. |
|
||||
| CONFIG_CPU_AFF_NR | CA binding core function, non-zero values represent restrictions on CPUID less than CONFIG_ CPU_ AFF_ NR's CPU can enter TEE, where 0 represents unlimited. Currently, Tzdriver only supports running on 0 cores, so the value is 1. |
|
||||
| CONFIG_KERNEL_CLIENT | Support the kernel CA option. |
|
||||
| CONFIG_TEELOG | TEE log switch, it is recommended to enable. |
|
||||
| CONFIG_PAGES_MEM | TEE log memory management, it is recommended to enable. |
|
||||
| CONFIG_THIRDPARTY_COMPATIBLE | Used for compatibility with third-party optee, such as the RK3568 chip, which requires this option to be enabled. |
|
||||
|
||||
## Compile Command
|
||||
|
||||
Tzdriver is compiled together with the kernel. Taking the rk3568 chip as an example, the "boot_linux.img" can be compiled separately. The compilation command is as follows
|
||||
|
||||
```
|
||||
./build.sh --product-name rk3568 --ccache --build-target kernel --gn-args linux_kernel_version=\"linux-5.10\"
|
||||
```
|
||||
|
||||
## Related code repository
|
||||
|
||||
[tee_client](https://gitee.com/openharmony-sig/tee_tee_client)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
Reference in New Issue
Block a user