Documentation/driver-api/tee.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API

TEE Driver API

Trusted Application의 UUID 기반 TEE bus matching·uevent와 client driver 등록 예제를 설명하는 한국어 전문 번역입니다.

Source pathDocumentation/driver-api/tee.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

tee.rst:1-66

TEE bus는 Trusted Application을 UUID device로 표현하고 client UUID table과 match하여 probe합니다. Uevent는 module autoload를 지원하며, 예제는 UUID table부터 `tee_client_driver`, register·unregister까지 완전한 client module registration 흐름을 보여 줍니다.

문서 구성
원문 줄핵심 내용
1-29TEE bus UUID matching, uevent와 client API
30-66Trusted Application client driver 등록 코드

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ===============================================
4 TEE (Trusted Execution Environment) driver API
5 ===============================================
6
7 Kernel provides a TEE bus infrastructure where a Trusted Application is
8 represented as a device identified via Universally Unique Identifier (UUID) and
9 client drivers register a table of supported device UUIDs.
10
11 TEE bus infrastructure registers following APIs:
12
13 match():
14 iterates over the client driver UUID table to find a corresponding
15 match for device UUID. If a match is found, then this particular device is
16 probed via corresponding probe API registered by the client driver. This
17 process happens whenever a device or a client driver is registered with TEE
18 bus.
19
20 uevent():
21 notifies user-space (udev) whenever a new device is registered on
22 TEE bus for auto-loading of modularized client drivers.
23
24 TEE bus device enumeration is specific to underlying TEE implementation, so it
25 is left open for TEE drivers to provide corresponding implementation.
26
27 Then TEE client driver can talk to a matched Trusted Application using APIs
28 listed in include/linux/tee_drv.h.
29
30 TEE client driver example
31 -------------------------
32
33 Suppose a TEE client driver needs to communicate with a Trusted Application
34 having UUID: ``ac6a4085-0e82-4c33-bf98-8eb8e118b6c2``, so driver registration
35 snippet would look like::
36
37 static const struct tee_client_device_id client_id_table[] = {
38 {UUID_INIT(0xac6a4085, 0x0e82, 0x4c33,
39 0xbf, 0x98, 0x8e, 0xb8, 0xe1, 0x18, 0xb6, 0xc2)},
40 {}
41 };
42
43 MODULE_DEVICE_TABLE(tee, client_id_table);
44
45 static struct tee_client_driver client_driver = {
46 .id_table = client_id_table,
47 .driver = {
48 .name = DRIVER_NAME,
49 .bus = &tee_bus_type,
50 .probe = client_probe,
51 .remove = client_remove,
52 },
53 };
54
55 static int __init client_init(void)
56 {
57 return driver_register(&client_driver.driver);
58 }
59
60 static void __exit client_exit(void)
61 {
62 driver_unregister(&client_driver.driver);
63 }
64
65 module_init(client_init);
66 module_exit(client_exit);
67

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

TEE driver API와 bus infrastructure

1-29

이 문서는 `GPL-2.0` SPDX license를 사용하는 TEE(Trusted Execution Environment) driver API guide입니다.

Kernel은 Trusted Application을 UUID(Universally Unique Identifier)로 식별되는 device로 표현하는 TEE bus infrastructure를 제공합니다. Client driver는 자신이 지원하는 device UUID table을 등록합니다.

TEE bus의 `match()` API는 client driver UUID table을 순회해 device UUID와 대응하는 항목을 찾습니다. Match가 있으면 client driver가 등록한 probe API로 해당 device를 probe합니다.

이 matching·probe 과정은 TEE bus에 device 또는 client driver가 등록될 때마다 수행됩니다.

`uevent()` API는 새 device가 TEE bus에 등록될 때 userspace의 udev에 알려 modular client driver가 자동으로 load되게 합니다.

TEE bus device enumeration 방식은 기반 TEE implementation에 따라 다르므로, 각 TEE driver가 대응 구현을 제공하도록 열어 둡니다.

Match된 뒤 TEE client driver는 `include/linux/tee_drv.h`에 나열된 API를 사용해 Trusted Application과 통신할 수 있습니다.

TEE bus device binding
TEE implementationEnumerate Trusted ApplicationTEE bus device with UUID
Client driverSupported UUID table`match()`Matched device
Matched deviceClient `probe()`Communicate via `include/linux/tee_drv.h`
New TEE device`uevent()`udevAutoload modular client driver

UUID table matching에서 client probe와 userspace module autoload로 이어집니다.

.. SPDX-License-Identifier: GPL-2.0

===============================================
TEE (Trusted Execution Environment) driver API
===============================================

Kernel provides a TEE bus infrastructure where a Trusted Application is
represented as a device identified via Universally Unique Identifier (UUID) and
client drivers register a table of supported device UUIDs.

TEE bus infrastructure registers following APIs:

match():
  iterates over the client driver UUID table to find a corresponding
  match for device UUID. If a match is found, then this particular device is
  probed via corresponding probe API registered by the client driver. This
  process happens whenever a device or a client driver is registered with TEE
  bus.

uevent():
  notifies user-space (udev) whenever a new device is registered on
  TEE bus for auto-loading of modularized client drivers.

TEE bus device enumeration is specific to underlying TEE implementation, so it
is left open for TEE drivers to provide corresponding implementation.

Then TEE client driver can talk to a matched Trusted Application using APIs
listed in include/linux/tee_drv.h.

TEE client driver 등록 예제

30-66

예제는 UUID `ac6a4085-0e82-4c33-bf98-8eb8e118b6c2`인 Trusted Application과 통신할 TEE client driver를 등록합니다.

`client_id_table`은 `struct tee_client_device_id` array이며 `UUID_INIT()`으로 UUID를 구성하고 빈 sentinel entry로 끝냅니다.

`MODULE_DEVICE_TABLE(tee, client_id_table)`은 module device table을 TEE bus용으로 내보냅니다.

`struct tee_client_driver client_driver`는 `id_table`을 연결하고 내장 `driver`에 `DRIVER_NAME`, `tee_bus_type`, `client_probe`, `client_remove`를 설정합니다.

Module init function `client_init()`은 `driver_register(&client_driver.driver)`를 호출하고, exit function `client_exit()`은 `driver_unregister(&client_driver.driver)`를 호출합니다. 마지막으로 `module_init()`과 `module_exit()`이 두 function을 module lifecycle에 연결합니다.

TEE client driver 예제 구성
구성 요소역할
`tee_client_device_id[]`지원 Trusted Application UUID table
`UUID_INIT(...)`대상 UUID 초기화
`MODULE_DEVICE_TABLE(tee, ...)`TEE modalias table export
`tee_client_driver.id_table`Bus matching table
`tee_bus_type`Driver를 TEE bus에 연결
`client_probe` / `client_remove`Bind·unbind callback
`driver_register` / `driver_unregister`Module lifecycle 등록·해제

TEE client driver example
-------------------------

Suppose a TEE client driver needs to communicate with a Trusted Application
having UUID: ``ac6a4085-0e82-4c33-bf98-8eb8e118b6c2``, so driver registration
snippet would look like::

        static const struct tee_client_device_id client_id_table[] = {
                {UUID_INIT(0xac6a4085, 0x0e82, 0x4c33,
                           0xbf, 0x98, 0x8e, 0xb8, 0xe1, 0x18, 0xb6, 0xc2)},
                {}
        };

        MODULE_DEVICE_TABLE(tee, client_id_table);

        static struct tee_client_driver client_driver = {
                .id_table        = client_id_table,
                .driver                = {
                        .name                = DRIVER_NAME,
                        .bus                = &tee_bus_type,
                        .probe                = client_probe,
                        .remove                = client_remove,
                },
        };

        static int __init client_init(void)
        {
                return driver_register(&client_driver.driver);
        }

        static void __exit client_exit(void)
        {
                driver_unregister(&client_driver.driver);
        }

        module_init(client_init);
        module_exit(client_exit);