← Documents Documentation/tee/qtee.rst GitHub 원문 ↗

Linux 6.18.37 · TEE

QTEE (Qualcomm Trusted Execution Environment)

QTEE object의 direct invocation과 callback request, SCM 함수, inbound·outbound transport buffer와 component 구조를 설명합니다.

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

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

1. 요약·해설

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

요약·해설

qtee.rst:1-96

QTEE object의 direct invocation과 callback request, SCM 함수, inbound·outbound transport buffer와 component 구조를 설명합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 =============================================
4 QTEE (Qualcomm Trusted Execution Environment)
5 =============================================
6
7 The QTEE driver handles communication with Qualcomm TEE [1].
8
9 The lowest level of communication with QTEE builds on the ARM SMC Calling
10 Convention (SMCCC) [2], which is the foundation for QTEE's Secure Channel
11 Manager (SCM) [3] used internally by the driver.
12
13 In a QTEE-based system, services are represented as objects with a series of
14 operations that can be called to produce results, including other objects.
15
16 When an object is hosted within QTEE, executing its operations is referred
17 to as "direct invocation". QTEE can also invoke objects hosted in the non-secure
18 world using a method known as "callback request".
19
20 The SCM provides two functions to support direct invocation and callback requests:
21
22 - QCOM_SCM_SMCINVOKE_INVOKE: Used for direct invocation. It can return either
23 a result or initiate a callback request.
24 - QCOM_SCM_SMCINVOKE_CB_RSP: Used to submit a response to a callback request
25 triggered by a previous direct invocation.
26
27 The QTEE Transport Message [4] is stacked on top of the SCM driver functions.
28
29 A message consists of two buffers shared with QTEE: inbound and outbound
30 buffers. The inbound buffer is used for direct invocation, and the outbound
31 buffer is used to make callback requests. This picture shows the contents of
32 a QTEE transport message::
33
34 +---------------------+
35 | v
36 +-----------------+-------+-------+------+--------------------------+
37 | qcomtee_msg_ |object | buffer | |
38 | object_invoke | id | offset, size | | (inbound buffer)
39 +-----------------+-------+--------------+--------------------------+
40 <---- header -----><---- arguments ------><- in/out buffer payload ->
41
42 +-----------+
43 | v
44 +-----------------+-------+-------+------+----------------------+
45 | qcomtee_msg_ |object | buffer | |
46 | callback | id | offset, size | | (outbound buffer)
47 +-----------------+-------+--------------+----------------------+
48
49 Each buffer is started with a header and array of arguments.
50
51 QTEE Transport Message supports four types of arguments:
52
53 - Input Object (IO) is an object parameter to the current invocation
54 or callback request.
55 - Output Object (OO) is an object parameter from the current invocation
56 or callback request.
57 - Input Buffer (IB) is (offset, size) pair to the inbound or outbound region
58 to store parameter to the current invocation or callback request.
59 - Output Buffer (OB) is (offset, size) pair to the inbound or outbound region
60 to store parameter from the current invocation or callback request.
61
62 Picture of the relationship between the different components in the QTEE
63 architecture::
64
65 User space Kernel Secure world
66 ~~~~~~~~~~ ~~~~~~ ~~~~~~~~~~~~
67 +--------+ +----------+ +--------------+
68 | Client | |callback | | Trusted |
69 +--------+ |server | | Application |
70 /\ +----------+ +--------------+
71 || +----------+ /\ /\
72 || |callback | || ||
73 || |server | || \/
74 || +----------+ || +--------------+
75 || /\ || | TEE Internal |
76 || || || | API |
77 \/ \/ \/ +--------+--------+ +--------------+
78 +---------------------+ | TEE | QTEE | | QTEE |
79 | libqcomtee [5] | | subsys | driver | | Trusted OS |
80 +-------+-------------+--+----+-------+----+-------------+--------------+
81 | Generic TEE API | | QTEE MSG |
82 | IOCTL (TEE_IOC_*) | | SMCCC (QCOM_SCM_SMCINVOKE_*) |
83 +-----------------------------+ +---------------------------------+
84
85 References
86 ==========
87
88 [1] https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-11/qualcomm-trusted-execution-environment.html
89
90 [2] http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
91
92 [3] drivers/firmware/qcom/qcom_scm.c
93
94 [4] drivers/tee/qcomtee/qcomtee_msg.h
95
96 [5] https://github.com/quic/quic-teec
97

3. 한국어 전문 번역

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

Object invocation과 SCM

1-27

QTEE driver는 Qualcomm TEE `[1]`와의 통신을 처리한다. 최하위 통신 계층은 ARM SMC Calling Convention(SMCCC) `[2]`이며, 이를 바탕으로 driver 내부의 QTEE Secure Channel Manager(SCM) `[3]`가 동작한다.

QTEE 기반 system에서 service는 호출 가능한 operation 집합을 가진 object로 표현되며 operation 결과로 다른 object가 반환될 수도 있다.

QTEE 내부에 host된 object의 operation을 실행하는 것을 direct invocation이라고 한다. 반대로 QTEE가 non-secure world에 host된 object를 호출하는 방식은 callback request라고 한다.

SCM의 `QCOM_SCM_SMCINVOKE_INVOKE`는 direct invocation에 사용되며 결과를 반환하거나 callback request를 시작할 수 있다. `QCOM_SCM_SMCINVOKE_CB_RSP`는 앞선 direct invocation이 유발한 callback request의 response를 제출한다. QTEE Transport Message `[4]`는 이 두 SCM 함수 위에 놓인다.

QTEE SCM 함수
함수역할
QCOM_SCM_SMCINVOKE_INVOKEdirect invocation 실행; 결과 또는 callback request 반환
QCOM_SCM_SMCINVOKE_CB_RSPcallback request에 대한 response 제출

direct invocation과 callback 왕복을 구성한다.

QTEE object 호출
Non-secure clientQCOM_SCM_SMCINVOKE_INVOKEQTEE object
QTEE objectResult
QTEE objectCallback requestNon-secure callback server
Non-secure callback serverQCOM_SCM_SMCINVOKE_CB_RSPQTEE object

secure object 호출과 non-secure callback의 왕복이다.

.. SPDX-License-Identifier: GPL-2.0

=============================================
QTEE (Qualcomm Trusted Execution Environment)
=============================================

The QTEE driver handles communication with Qualcomm TEE [1].

The lowest level of communication with QTEE builds on the ARM SMC Calling
Convention (SMCCC) [2], which is the foundation for QTEE's Secure Channel
Manager (SCM) [3] used internally by the driver.

In a QTEE-based system, services are represented as objects with a series of
operations that can be called to produce results, including other objects.

When an object is hosted within QTEE, executing its operations is referred
to as "direct invocation". QTEE can also invoke objects hosted in the non-secure
world using a method known as "callback request".

The SCM provides two functions to support direct invocation and callback requests:

- QCOM_SCM_SMCINVOKE_INVOKE: Used for direct invocation. It can return either
  a result or initiate a callback request.
- QCOM_SCM_SMCINVOKE_CB_RSP: Used to submit a response to a callback request
  triggered by a previous direct invocation.

The QTEE Transport Message [4] is stacked on top of the SCM driver functions.

Inbound·outbound buffer와 argument

28-61

QTEE transport message는 QTEE와 공유하는 inbound 및 outbound buffer 두 개로 구성된다. inbound buffer는 direct invocation에 사용하고 outbound buffer는 callback request를 만드는 데 사용한다.

각 buffer는 header와 argument array로 시작하고 뒤에 in/out buffer payload가 놓인다. inbound header는 `qcomtee_msg_object_invoke`, outbound header는 `qcomtee_msg_callback`이며 argument는 object ID 또는 buffer의 offset과 size를 담는다.

Input Object(IO)는 현재 invocation 또는 callback request에 들어가는 object parameter이고, Output Object(OO)는 그 호출에서 나오는 object parameter다.

Input Buffer(IB)는 inbound 또는 outbound region에서 현재 호출에 전달할 parameter를 저장하는 `(offset, size)` pair다. Output Buffer(OB)는 같은 region에서 현재 호출이 반환한 parameter를 저장하는 `(offset, size)` pair다.

QTEE transport buffer layout
BufferHeaderArgumentsPayload 용도
Inboundqcomtee_msg_object_invokeobject id, buffer offset/sizedirect invocation의 input/output payload
Outboundqcomtee_msg_callbackobject id, buffer offset/sizecallback request의 input/output payload

원문의 ASCII buffer 그림을 field 단위로 재구성했다.

Transport message 해석
Message headerArgument array
IO / OOObject reference
IB / OB offset + sizeInbound or outbound shared regionParameter payload

header에서 argument를 거쳐 shared payload를 찾는다.


A message consists of two buffers shared with QTEE: inbound and outbound
buffers. The inbound buffer is used for direct invocation, and the outbound
buffer is used to make callback requests. This picture shows the contents of
a QTEE transport message::

                                      +---------------------+
                                      |                     v
    +-----------------+-------+-------+------+--------------------------+
    | qcomtee_msg_    |object | buffer       |                          |
    |  object_invoke  |  id   | offset, size |                          | (inbound buffer)
    +-----------------+-------+--------------+--------------------------+
    <---- header -----><---- arguments ------><- in/out buffer payload ->

                                      +-----------+
                                      |           v
    +-----------------+-------+-------+------+----------------------+
    | qcomtee_msg_    |object | buffer       |                      |
    |  callback       |  id   | offset, size |                      | (outbound buffer)
    +-----------------+-------+--------------+----------------------+

Each buffer is started with a header and array of arguments.

QTEE Transport Message supports four types of arguments:

- Input Object (IO) is an object parameter to the current invocation
  or callback request.
- Output Object (OO) is an object parameter from the current invocation
  or callback request.
- Input Buffer (IB) is (offset, size) pair to the inbound or outbound region
  to store parameter to the current invocation or callback request.
- Output Buffer (OB) is (offset, size) pair to the inbound or outbound region
  to store parameter from the current invocation or callback request.

QTEE component 관계와 참고 자료

62-96

user space의 client와 callback server는 `libqcomtee` `[5]`를 사용하고, generic TEE API와 `TEE_IOC_*` IOCTL을 거쳐 kernel TEE subsystem 및 QTEE driver에 접근한다.

QTEE driver는 QTEE message와 `QCOM_SCM_SMCINVOKE_*` 기반 SMCCC 호출을 사용해 secure world의 QTEE Trusted OS와 연결된다. Trusted OS 위에는 TEE Internal API와 Trusted Application이 놓인다. callback server 경로는 secure world가 non-secure object를 호출할 수 있게 한다.

참고 자료는 Qualcomm TEE 설명, ARM SMCCC 문서, `drivers/firmware/qcom/qcom_scm.c`, `drivers/tee/qcomtee/qcomtee_msg.h`, `libqcomtee` 구현을 가리킨다.

QTEE 아키텍처
Client / callback serverlibqcomteeGeneric TEE API / TEE_IOC_*
Generic TEE API / TEE_IOC_*TEE subsystemQTEE driver
QTEE driverQTEE MSGSMCCC / QCOM_SCM_SMCINVOKE_*
QTEE Trusted OSTEE Internal APITrusted Application

원문의 ASCII 그림을 client, callback, kernel, secure world 경로로 재구성했다.

QTEE source와 specification
참조내용
[1]Qualcomm Trusted Execution Environment
[2]ARM SMCCC
[3]Qualcomm SCM driver
[4]QTEE transport message definition
[5]user-space libqcomtee

문서에서 직접 연결하는 구현 위치다.

Picture of the relationship between the different components in the QTEE
architecture::

         User space               Kernel                     Secure world
         ~~~~~~~~~~               ~~~~~~                     ~~~~~~~~~~~~
   +--------+   +----------+                                +--------------+
   | Client |   |callback  |                                | Trusted      |
   +--------+   |server    |                                | Application  |
      /\        +----------+                                +--------------+
      ||  +----------+ /\                                          /\
      ||  |callback  | ||                                          ||
      ||  |server    | ||                                          \/
      ||  +----------+ ||                                   +--------------+
      ||       /\      ||                                   | TEE Internal |
      ||       ||      ||                                   | API          |
      \/       \/      \/   +--------+--------+             +--------------+
   +---------------------+  | TEE    | QTEE   |             | QTEE         |
   |   libqcomtee [5]    |  | subsys | driver |             | Trusted OS   |
   +-------+-------------+--+----+-------+----+-------------+--------------+
   |      Generic TEE API        |       |   QTEE MSG                      |
   |      IOCTL (TEE_IOC_*)      |       |   SMCCC (QCOM_SCM_SMCINVOKE_*)  |
   +-----------------------------+       +---------------------------------+

References
==========

[1] https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-11/qualcomm-trusted-execution-environment.html

[2] http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html

[3] drivers/firmware/qcom/qcom_scm.c

[4] drivers/tee/qcomtee/qcomtee_msg.h

[5] https://github.com/quic/quic-teec