|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| agent_rpmb/ | | 12-May-2024 | - | 1,194 | 843 |
| auth/ | | 12-May-2024 | - | 1,238 | 1,005 |
| core/ | | 12-May-2024 | - | 14,143 | 11,182 |
| figures/ | | 12-May-2024 | - | | |
| include/ | | 12-May-2024 | - | 112 | 89 |
| ion/ | | 12-May-2024 | - | 1,292 | 1,032 |
| tlogger/ | | 12-May-2024 | - | 1,856 | 1,454 |
| tui/ | | 12-May-2024 | - | 2,359 | 1,947 |
| whitelist/ | | 12-May-2024 | - | 88 | 65 |
| CMakeLists.txt | D | 12-May-2024 | 79 | 2 | 2 |
| Kconfig | D | 12-May-2024 | 877 | 38 | 31 |
| Makefile | D | 12-May-2024 | 388 | 15 | 11 |
| README.md | D | 12-May-2024 | 3.4 KiB | 79 | 54 |
| README_zh.md | D | 12-May-2024 | 2.9 KiB | 79 | 54 |
| agent.h | D | 12-May-2024 | 4.4 KiB | 133 | 105 |
| apply_tzdriver.sh | D | 12-May-2024 | 569 | 29 | 17 |
| dynamic_mem.h | D | 12-May-2024 | 3.7 KiB | 150 | 120 |
| ko_adapt.c | D | 12-May-2024 | 4.4 KiB | 165 | 130 |
| ko_adapt.h | D | 12-May-2024 | 2 KiB | 79 | 50 |
| tc_ns_client.h | D | 12-May-2024 | 5 KiB | 198 | 162 |
| tc_ns_log.h | D | 12-May-2024 | 1.7 KiB | 68 | 39 |
| teek_client_api.h | D | 12-May-2024 | 4.8 KiB | 184 | 122 |
| teek_client_constants.h | D | 12-May-2024 | 6.2 KiB | 215 | 182 |
| teek_client_ext.h | D | 12-May-2024 | 785 | 27 | 7 |
| teek_client_id.h | D | 12-May-2024 | 2.5 KiB | 140 | 113 |
| teek_client_type.h | D | 12-May-2024 | 3 KiB | 139 | 93 |
| teek_ns_client.h | D | 12-May-2024 | 6.2 KiB | 241 | 188 |
| tui.h | D | 12-May-2024 | 5.8 KiB | 275 | 220 |
README.md
1# Tzdriver driver
2
3## Introduction
4
5Tzdriver 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.
6
7Tzdriver includes the following main modules:
8
9smc: Send smc instructions to switch the CPU from the REE side to the TEE side for operation.
10
11session_manager: Manage communication sessions between REE and TEE.
12
13mailbox:Data is shared between REE and TEE through the mailbox.
14
15cmd_monitor:Monitor the operation of SMC instructions and provides a timeout detection mechanism.
16
17tzdebug:Create debugfs debugging nodes to facilitate developers in debugging TEE functionality
18
19tlogger:TEE log driver module, supporting TEE log recording and printing.
20
21Figure 1: Tzdriver architecture diagram
22
23
24
25## Directory
26
27```
28/kernel/linux/common_modules/tzdriver
29├── core
30│ ├── cmdmonitor.c # SMC instruction execution monitoring
31 ├── gp_ops.c # GP TEE specification processing logic
32 ├── mailbox_mempool.c # REE and TEE shared memory management
33 ├── session_manager.c # Session management for CA access to TA
34 ├── smc_smp.c # Send SMC command to switch to TEE
35 ├── tzdebug.c # Debugging module
36├── tlogger # TEE log driver
37```
38
39## Configuration Option
40
41If 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:
42
43```
44#
45# TEEOS
46#
47CONFIG_TZDRIVER=y
48CONFIG_CPU_AFF_NR=1
49CONFIG_KERNEL_CLIENT=y
50CONFIG_TEELOG=y
51CONFIG_PAGES_MEM=y
52CONFIG_THIRDPARTY_COMPATIBLE=y
53```
54
55The meanings of each option are shown in the table below:
56
57**Table 1** Configuration Options Description
58
59| Parameters | Description |
60| ---------------------------- | ------------------------------------------------------------ |
61| CONFIG_TZDRIVER | Tzdriver module switch. |
62| 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. |
63| CONFIG_KERNEL_CLIENT | Support the kernel CA option. |
64| CONFIG_TEELOG | TEE log switch, it is recommended to enable. |
65| CONFIG_PAGES_MEM | TEE log memory management, it is recommended to enable. |
66| CONFIG_THIRDPARTY_COMPATIBLE | Used for compatibility with third-party optee, such as the RK3568 chip, which requires this option to be enabled. |
67
68## Compile Command
69
70Tzdriver 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
71
72```
73./build.sh --product-name rk3568 --ccache --build-target kernel --gn-args linux_kernel_version=\"linux-5.10\"
74```
75
76## Related code repository
77
78[tee_client](https://gitee.com/openharmony/tee_tee_client)
79
README_zh.md
1# Tzdriver驱动
2
3## 简介
4
5Tzdriver是部署在REE侧的内核驱动,支持REE和TEE之间通信。Tzdriver处理来自于Tee Client的命令,发送指令从REE切换到TEE。Tzdriver通过管理共享内存,支持REE和TEE之间共享数据。
6
7Tzdriver驱动包含如下主要模块:
8
9smc:发送smc指令,将CPU从REE侧切换到TEE侧运行。
10
11session_manager:管理REE与TEE之间的通信会话。
12
13mailbox:REE和TEE之间通过mailbox共享数据。
14
15cmd_monitor:监控smc指令的运行,提供超时检测机制。
16
17tzdebug:创建debugfs调试节点,方便开发人员调试TEE功能。
18
19tlogger:TEE日志驱动模块,支持TEE日志记录和打印。
20
21图1 Tzdriver驱动架构图
22
23
24
25## 目录
26
27```
28/kernel/linux/common_modules/tzdriver
29├── core
30│ ├── cmdmonitor.c # smc指令执行监控
31 ├── gp_ops.c # GP TEE规范处理逻辑
32 ├── mailbox_mempool.c # REE和TEE共享内存管理
33 ├── session_manager.c # CA访问TA的session管理
34 ├── smc_smp.c # 发送smc指令切换到TEE
35 ├── tzdebug.c # 调试模块
36├── tlogger # TEE日志驱动
37```
38
39## 配置选项
40
41如果要使能Tzdriver驱动,需要修改linux内核代码仓中设备的defconfig文件,增加Tzdriver的配置选项:
42
43```
44#
45# TEEOS
46#
47CONFIG_TZDRIVER=y
48CONFIG_CPU_AFF_NR=1
49CONFIG_KERNEL_CLIENT=y
50CONFIG_TEELOG=y
51CONFIG_PAGES_MEM=y
52CONFIG_THIRDPARTY_COMPATIBLE=y
53```
54
55各选项其含义如下表所示:
56
57**表 1** 配置选项说明
58
59| 参数 | 说明 |
60| ---------------------------- | ------------------------------------------------------------ |
61| CONFIG_TZDRIVER | Tzdriver模块开关。 |
62| CONFIG_CPU_AFF_NR | CA绑核功能,非零值代表限制仅cpuid小于CONFIG_CPU_AFF_NR的CPU可以进入TEE,0代表无限制,当前只支持在0核运行,所以值为1。 |
63| CONFIG_KERNEL_CLIENT | 支持内核CA选项。 |
64| CONFIG_TEELOG | TEE日志开关,建议开启。 |
65| CONFIG_PAGES_MEM | TEE日志内存管理,建议开启。 |
66| CONFIG_THIRDPARTY_COMPATIBLE | 兼容第三方opteed的适配,例如适配RK3568芯片需要开启此选项。 |
67
68## 编译命令
69
70Tzdriver驱动跟随kernel一起编译,以rk3568为例,可以单独编译boot_linux.img,编译命令如下
71
72```
73./build.sh --product-name rk3568 --ccache --build-target kernel --gn-args linux_kernel_version=\"linux-5.10\"
74```
75
76## 相关仓
77
78[tee_client](https://gitee.com/openharmony/tee_tee_client)
79