From patchwork Mon Sep 3 14:47:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Wiklander X-Patchwork-Id: 145805 Delivered-To: patches@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2575574ljw; Mon, 3 Sep 2018 07:47:32 -0700 (PDT) X-Received: by 2002:a2e:7406:: with SMTP id p6-v6mr7852696ljc.5.1535986052280; Mon, 03 Sep 2018 07:47:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535986052; cv=none; d=google.com; s=arc-20160816; b=ko7wX/0WYUpSAWkFQO/Y80eRwKoZQkUbMT6V+kXip0o9gVOATZc9hcPAlY7Q7IOBaF MYh/9iDwtuqyLt60CRRJD52AkKMqrp1eyJgJ6Xgoxae4eKEGf11vYtqJVJu/3zoltJyl p0INyKAxgOlDP9obp7XX8p6/SrwRloGgBC5bZb22naLv2e1VzO0KbU+njNIYrWxVwnBZ Leg4LdC0F9nTgEKly0/8hi++1Y+tG3pHJ6yNDYXuQSi6QAmRL/7hXAEkGaG+SgqnDrar WmY67SX5zHZh9eKDSSgVyxde1j7tjcIzP0yqkzCuKP8XHnLj+42bZmcs8Fb7BNCZZiNy ek/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=lgCdUmBufLy6+xjFvNL7oyDbBWl5csz7nRRV9iomFaE=; b=XD79C+VUM63kbro+wKjbq86xy5RvDA0XHrDGZjNlHmBr6Cu+g5sEGQXxmkbmCJIMcz v7Zzf0982zT8K5HSJmfk1lXfwBHisSrchPopLbdRbA1pdNgsZaKUhv1T/EZgbR03eXNY s+jWCHrb1wAImqPH+32p8PrfhC1L+CJrdFE3AnOARZ2JXmgfQchxXQRiqH48RmKs3Xhl YWg2mXPzCz/GhuUzzUNyyAIzJcjTbDaexhheXEMHr9YcWSLUfha2EUQ5RxQROdWSlFud rwmhb5jUy2X66bQf0Q61CM5D0dfyaqZcBTw4Eqsgc6D+JXOAA6l7BePHaeftukB2A/Pm ZJdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U0L0cGkg; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id r16-v6sor5338621lff.13.2018.09.03.07.47.32 for (Google Transport Security); Mon, 03 Sep 2018 07:47:32 -0700 (PDT) Received-SPF: pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=U0L0cGkg; spf=pass (google.com: domain of jens.wiklander@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=jens.wiklander@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lgCdUmBufLy6+xjFvNL7oyDbBWl5csz7nRRV9iomFaE=; b=U0L0cGkgD5movJSm59seJ5277rX2Sii1JOxKYRiOhyRhv5HIYQDCQxwyZBecCbFUdG FvGA0zy4K7yDvJPyKehO/8ZUJl5KuUBNdfxCBRwJ3DPLidGZAL0JrJm7/QEE1enz6H1w NsVElzoThgFJb7/gZJ+HLwi/HhPRNen0sU64o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lgCdUmBufLy6+xjFvNL7oyDbBWl5csz7nRRV9iomFaE=; b=CAuZrG+G6HsXxbjd7vhQdmgbMv36qi4WhaAYosPRc8QLC3pSmK0G/HL4hV1t5jwDZC /CcDnLarlqd5hkiTLeMc6ZUVlc9wyN2exauEGtHFqsKS3cLQvRKGmuOfVzBfpKrITex3 VpVCi1ITAKLch3N1UHxI107KqHArnFWDd1qIyCueAWTJTrJWW19v6uY4jmgAFfjcHBfg yH9l4+x+aWBEVxSl/+sLga5m5ApqTxTcY9EKb8WgHI6YpytSq7M93aMMRKDRJeft55Sl Qj7FazP0tejBGj37ZUjNU0OsNah+ZaeeRbRYZP5h+kES1a7WqkeDjEKcQd6XxDcafeFj vtIw== X-Gm-Message-State: APzg51CJbUpygbUobcSQkZN8qMW8pbga0G2rq0NVrBn8lMyv6I18O027 AJI5edA3Dx/zMg9VKc5PfGbEDCEy X-Google-Smtp-Source: ANB0VdYoFPTvjnCXfu6An4nloiHygv5hUaAoZX+bd1g1vI5woq8deUG6lNBEhrMGGdG8FPJfkPm9CA== X-Received: by 2002:a19:a2c1:: with SMTP id l184-v6mr14591020lfe.129.1535986052043; Mon, 03 Sep 2018 07:47:32 -0700 (PDT) Return-Path: Received: from jax.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id w18-v6sm3343431ljd.73.2018.09.03.07.47.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 07:47:31 -0700 (PDT) From: Jens Wiklander To: u-boot@lists.denx.de Cc: Simon Glass , Igor Opaniuk , Tom Rini , Jaehoon Chung , Pierre Aubert , Albert Aribaud , Peter Griffin , Michal Simek , Jens Wiklander Subject: [PATCH v3 09/20] Documentation: tee uclass and op-tee driver Date: Mon, 3 Sep 2018 16:47:00 +0200 Message-Id: <20180903144711.31585-10-jens.wiklander@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180903144711.31585-1-jens.wiklander@linaro.org> References: <20180903144711.31585-1-jens.wiklander@linaro.org> Reviewed-by: Simon Glass Signed-off-by: Jens Wiklander --- doc/README.tee | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 doc/README.tee -- 2.17.1 diff --git a/doc/README.tee b/doc/README.tee new file mode 100644 index 000000000000..79e7996a6f5f --- /dev/null +++ b/doc/README.tee @@ -0,0 +1,112 @@ +============= +TEE uclass +============= + +This document describes the TEE uclass in U-Boot + +A TEE (Trusted Execution Environment) is a trusted OS running in some +secure environment, for example, TrustZone on ARM CPUs, or a separate +secure co-processor etc. A TEE driver handles the details needed to +communicate with the TEE. + +This uclass deals with: + +- Registration of TEE drivers + +- Managing shared memory between U-Boot and the TEE + +- Providing a generic API to the TEE + +The TEE interface +================= + +include/tee.h defines the generic interface to a TEE. + +A client finds the TEE device via tee_find_device(). Other important functions +when interfacing with a TEE are: + +- tee_shm_alloc(), tee_shm_register() and tee_shm_free() to manage shared + memory objects often needed when communicating with the TEE. + +- tee_get_version() lets the client know which the capabilities of the TEE + device. + +- tee_open_session() opens a session to a Trusted Application + +- tee_invoke_func() invokes a function in a Trusted Application + +- tee_close_session() closes a session to a Trusted Application + +Much of the communication between clients and the TEE is opaque to the +driver. The main job for the driver is to receive requests from the +clients, forward them to the TEE and send back the results. + +OP-TEE driver +============= + +The OP-TEE driver handles OP-TEE [1] based TEEs. Currently it is only the ARM +TrustZone based OP-TEE solution that is supported. + +Lowest level of communication with OP-TEE builds on ARM SMC Calling +Convention (SMCCC) [2], which is the foundation for OP-TEE's SMC interface +[3] used internally by the driver. Stacked on top of that is OP-TEE Message +Protocol [4]. + +OP-TEE SMC interface provides the basic functions required by SMCCC and some +additional functions specific for OP-TEE. The most interesting functions are: + +- OPTEE_SMC_FUNCID_CALLS_UID (part of SMCCC) returns the version information + which is then returned by TEE_IOC_VERSION + +- OPTEE_SMC_CALL_GET_OS_UUID returns the particular OP-TEE implementation, used + to tell, for instance, a TrustZone OP-TEE apart from an OP-TEE running on a + separate secure co-processor. + +- OPTEE_SMC_CALL_WITH_ARG drives the OP-TEE message protocol + +- OPTEE_SMC_GET_SHM_CONFIG lets the driver and OP-TEE agree on which memory + range to used for shared memory between Linux and OP-TEE. + +The GlobalPlatform TEE Client API [5] is implemented on top of the generic +TEE API. + +Picture of the relationship between the different components in the +OP-TEE architecture: + + U-Boot Secure world + ~~~~~~ ~~~~~~~~~~~~ + +------------+ +-------------+ + | Client | | Trusted | + | | | Application | + +------------+ +-------------+ + /\ /\ + || || + \/ \/ + +------------+ +-------------+ + | TEE | | TEE Internal| + | uclass | | API | + +------------+ +-------------+ + | OP-TEE | | OP-TEE | + | driver | | Trusted OS | + +------------+-----------+-------------+ + | OP-TEE MSG | + | SMCCC (OPTEE_SMC_CALL_*) | + +--------------------------------------+ + +RPC (Remote Procedure Call) are requests from secure world to the driver. +An RPC is identified by a special range of SMCCC return values from +OPTEE_SMC_CALL_WITH_ARG. + +References +========== + +[1] https://github.com/OP-TEE/optee_os + +[2] http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html + +[3] drivers/tee/optee/optee_smc.h + +[4] drivers/tee/optee/optee_msg.h + +[5] http://www.globalplatform.org/specificationsdevice.asp look for + "TEE Client API Specification v1.0" and click download.