Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1082874ybg; Thu, 4 Jun 2020 00:02:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAH0WEdzLBUwnOZAawADe4h+OGwJ5OBB8EK4pwBH6f7Di9wSG74VdGTTmGbiNG+iVKe/pn X-Received: by 2002:a17:906:1c94:: with SMTP id g20mr2577074ejh.319.1591254169848; Thu, 04 Jun 2020 00:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591254169; cv=none; d=google.com; s=arc-20160816; b=KtBXFGavf5/y4nwaU0Wzx3KBavP2e22N8HMTXk89MeRIVz0uzVlInOWtO0jQYUgoQX xhM+GRTovvXFC7Vo6BF7/He7blgjsCdkzoVsrrfjA3fo57nDYv7dTjHEdNJ8JxUyZFtW hcIrmxpUVxykGKiSDmmMBmYXXH9aUYqN1zrDdVMpxxYImqmOR1/T7WngiX/abJFxETYv dRwyXgxATJ3xV5WpWsNffr+y8eYwLLVOuZ9Z91SJ1Wj7dfZ6YgT/rm7rqc/gytq2mhZe bExmBvQKUa4Fb5hyIV/kQHpSmU+TRUNyGDX6UAVLBir/2vIm6jMqyzSHrNtfjaVabfRy h5RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=ehnvTHrC4FiL82yKM8mB6k6smyhfZQn4QW5Pmpjoujo=; b=QUothB+OzwTszRMOQtBEvnkQn1WIPf+i6R6evDNMlJB7mwEVW+NWUwvdHsjfEE8T5s J9JxyiET3gP50MWpwSd2pb8115HBGLSlJCtgIpCJ2wAQL/JgJpLOu+DuxWqpkZO2w15E WKZ4ABNuNO0Thxl7hZ72gnqPcYALM8ytSWs4gPsyWWRQDl887uWr6I4deLZsDv6fIfzq P97FEhlwUWqnQ3zIjCe3HsVL55ArPQ2KwLRdQset+u2r5BMURiBt8F0v3EYl4FVwLDK8 CM6y1NKTZ1+YiWFjlxAhr4Bmv956+X3WQUpFNGkJiVePmxVJr7RwnpDnc8x8NPSMzEzw Iy3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="WNeCSo/6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si1172489edv.240.2020.06.04.00.02.26; Thu, 04 Jun 2020 00:02:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="WNeCSo/6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726835AbgFDHAK (ORCPT + 99 others); Thu, 4 Jun 2020 03:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727769AbgFDHAF (ORCPT ); Thu, 4 Jun 2020 03:00:05 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8604C05BD1E for ; Thu, 4 Jun 2020 00:00:02 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id x22so2869229pfn.3 for ; Thu, 04 Jun 2020 00:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ehnvTHrC4FiL82yKM8mB6k6smyhfZQn4QW5Pmpjoujo=; b=WNeCSo/6X9jnPJN+T6rzzS/5NWS+b/GuJrQza+Ug291tJqT3pqMSPUgcJNsT7tyGVq 5axyUMwjNCuEOcXMe48YN9w1FgT5IQHFUGed5OYfeIpXkxi7IqOkuauXJcUVkWoX6YSu jxf01kqpxgW0PEOpm1vz3SsmzWE/ywFVLNBEBdgIJwBYQoqBH0pVUMDGVwDNcAuJHvXw /2uk5Xlo4tEqO/pgcD6onbxG5eSa6yoggwvBNr1sTV/ui0RNLVsVHofGmIAqWUQx9Izd TTt0S+vlo925mKxLXv2VLDyU2saDLBsbCBywYEkd7YAER6DRg0epJAq8PL/KwxGmafsn S/7w== 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; bh=ehnvTHrC4FiL82yKM8mB6k6smyhfZQn4QW5Pmpjoujo=; b=olrOuV0shDg660/KnVlyBlhMs5Crk3gNlAc9bycpI23EtKFXpDYpTgvcam1ALPfbon 61cGA2fmqGSnYpKtv40nok9ny7GUMcSSa4Fywc57HJ4xYRAlTEp+A5T1FfrLyysdLxnO /UJFpe7fmSfS1b+++hUuEd/ceMHuQ2UN1LO9X4TrA8Sxd6+DNYt754aWMZ41tzcQwBra 952TE/+z8KBIrFzyPqhmYKc/qv6t6LtwJ4on80oube+kAuxR6ex+PvpavSLj1v3ano+j xLOIWoq7tbnCx64hVN3dgnN48LFw2owHPJvowuqIf13MFngp5MyqGDZ9QyvIqfVZtK1T Wyjw== X-Gm-Message-State: AOAM532i5cEhUgGEF6G5JvJqYXKvxqq7uF8UdZ1KqZC/gPYsGO6ZpI7w u0iZ23hT9GHV2+KZiPglgVq7TA== X-Received: by 2002:a05:6a00:843:: with SMTP id q3mr2764044pfk.107.1591254002252; Thu, 04 Jun 2020 00:00:02 -0700 (PDT) Received: from localhost.localdomain ([117.252.66.248]) by smtp.gmail.com with ESMTPSA id q6sm1703309pff.163.2020.06.03.23.59.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jun 2020 00:00:01 -0700 (PDT) From: Sumit Garg To: jens.wiklander@linaro.org, corbet@lwn.net Cc: maxim.uvarov@linaro.org, jarkko.sakkinen@linux.intel.com, tee-dev@lists.linaro.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, Sumit Garg Subject: [PATCH v2] Documentation: tee: Document TEE kernel interface Date: Thu, 4 Jun 2020 12:29:39 +0530 Message-Id: <1591253979-29067-1-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Update documentation with TEE bus infrastructure which provides an interface for kernel client drivers to communicate with corresponding Trusted Application. Signed-off-by: Sumit Garg --- Changes in v2: - Add TEE client driver example snippet. Documentation/tee.txt | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/Documentation/tee.txt b/Documentation/tee.txt index c8fad81..350dd40 100644 --- a/Documentation/tee.txt +++ b/Documentation/tee.txt @@ -53,6 +53,66 @@ clients, forward them to the TEE and send back the results. In the case of supplicants the communication goes in the other direction, the TEE sends requests to the supplicant which then sends back the result. +The TEE kernel interface +======================== + +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 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); + OP-TEE driver ============= @@ -112,6 +172,14 @@ kernel are handled by the kernel driver. Other RPC messages will be forwarded to tee-supplicant without further involvement of the driver, except switching shared memory buffer representation. +OP-TEE device enumeration +------------------------- + +OP-TEE provides a pseudo Trusted Application: drivers/tee/optee/device.c in +order to support device enumeration. In other words, OP-TEE driver invokes this +application to retrieve a list of Trusted Applications which can be registered +as devices on the TEE bus. + AMD-TEE driver ============== -- 2.7.4