From patchwork Tue Jan 12 08:43:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jorge Ramirez-Ortiz, Foundries" X-Patchwork-Id: 1425027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.a=rsa-sha256 header.s=google header.b=KqQwSe25; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DFPJ86X3wz9sX5 for ; Tue, 12 Jan 2021 19:44:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 99C00827BD; Tue, 12 Jan 2021 09:43:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.b="KqQwSe25"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F3347827BB; Tue, 12 Jan 2021 09:43:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A93478271F for ; Tue, 12 Jan 2021 09:43:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jorge@foundries.io Received: by mail-wm1-x32f.google.com with SMTP id n16so1315155wmc.0 for ; Tue, 12 Jan 2021 00:43:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=from:to:cc:subject:date:message-id; bh=7nv8p6iLOrImShSBbeE3GCkapvSGffB9nQoaHtswtHc=; b=KqQwSe25QEDrfOb4K3Q/hMMxRRkGnhEpIPgyBaP0b75ZNOC/6ksXCz8I7e3rzec3n7 dSJzOEjZPFvibzxOVDZIunivxBFDW1fXSvbKFJt98QQal+siNeCPYBQvoIjNJ+WZ7oSb ZhGDBCyENg00xbeOZe6u/3Tu4ZUc+UI4y0iplsUkvtjUtjCFP7ayGuuKMvL39xniWzUK tlXNBUCwR5n2i/ZlZtw/rsQZodbnfYceHBFrIoPeeXpuJVK7bgjkJi9YheWTGeFtDst2 InNMQ7+N+QMn+F31fKQPpc0WJl/KlA19htRzmrSitkXlBC41oMvX1/lNFZWNXbMDJV60 CIMQ== 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=7nv8p6iLOrImShSBbeE3GCkapvSGffB9nQoaHtswtHc=; b=oMs7rfVjRW6AwonrGp2XhDwJ2dy31sP8YuDFGbaoYqfO7TqUdiLLii1xdae+/AsuZ9 G7z82myrTHx6nhdQoKYecUciAf4u+DLVAeOZYHPYCLf5t8JAPqaygpv+7mFZ9De6YKX4 mLBCEE00cZfssSpYxuQx4d6bnV3VUexr1zj1vHWaln8zN8E3jfbffd7e07V0k29Qgqth U7Cam510voa+LF2Z1lc1AqZtaoDpI8HSmpGTZ9lQq+312VHuwyW24EiMU4aXcbRkNfUa HUDq+T32iMuPXkNPNb3rWaWP/r46R+gH0uNZjc7XHuYgbktCNIVWZn6chbtJzoZ5z6Z/ 2t8Q== X-Gm-Message-State: AOAM533qPtFI6+NtlAEi99yLBRKO5BV8wKPFSUd7vKy2Q3z2bu34D8dP Qe1MLAUAWRE00raQUij39twN2A== X-Google-Smtp-Source: ABdhPJzznybRXIsWI0y5ThngMARg5/sf4/peqIGeKWbwqSWWA+pmZ4k0phi19Unte44Y+6lQsw6hkw== X-Received: by 2002:a1c:4986:: with SMTP id w128mr1455225wma.89.1610441034293; Tue, 12 Jan 2021 00:43:54 -0800 (PST) Received: from localhost.localdomain (240.red-95-121-89.dynamicip.rima-tde.net. [95.121.89.240]) by smtp.gmail.com with ESMTPSA id z63sm2714487wme.8.2021.01.12.00.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 00:43:53 -0800 (PST) From: Jorge Ramirez-Ortiz To: jorge@foundries.io, jens.wiklander@linaro.org, sjg@chromium.org, igor.opaniuk@foundries.io Cc: u-boot@lists.denx.de, seanga2@gmail.com, vikas.gupta@broadcom.com, trini@konsulko.com, mike@foundries.io, ricardo@foundries.io Subject: [PATCHv3 0/4] OP-TEE I2C trampoline and associated tests Date: Tue, 12 Jan 2021 09:43:36 +0100 Message-Id: <20210112084340.23858-1-jorge@foundries.io> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean This patchset allows OP-TEE to communicate with I2C devices; a typical use case would be servicing U-Boot requests that require underlying cryptographic operations implemented by an I2C chip. On a board fitted with the NXP SE050 I2C secure element, OP-TEE can route some of the cryptographic operations it needs to that device (ie RSA, ECC, CTR..). Before the REE executes, OP-TEE would use its own I2C drivers to communicate with the device on the bus; later on, once the REE is up, accesses to the I2C bus should be coordinated with the REE to avoid collisions. However instead of implementing such a synchronization mechanism, this trampoline service permits OP-TEE to route those I2C requests back to U-boot without then having to worry about collisions. Lets suppose that U-Boot executes the trusted application Android Verified Boot; when OP-TEE receives the request - and before executing the application - it uses RSA to verify it. So on the back of the TA function invocation, OP-TEE returns to U-boot with a sequence of RPC calls requesting I2C transfers (check carefully the implementation in do_call_with_arg(...) implemented in drivers/tee/optee/core.c and notice the while loop) When using sandbox testing, RPC is called directly to validate its actual implementation; however as succintly described above, these calls will always be originated in OP-TEE. Igor Opaniuk (3): test: py: add pygit2 and pyelftools to requirements.txt drivers: tee: sandbox: add rpc test ta emulation test: dm: tee: extend with RPC test Jorge Ramirez-Ortiz (1): drivers: tee: i2c trampoline driver drivers/tee/Makefile | 2 + drivers/tee/optee/Kconfig | 9 ++ drivers/tee/optee/Makefile | 1 + drivers/tee/optee/i2c.c | 90 +++++++++++++++ drivers/tee/optee/optee_msg.h | 21 ++++ drivers/tee/optee/optee_msg_supplicant.h | 5 + drivers/tee/optee/optee_private.h | 17 +++ drivers/tee/optee/supplicant.c | 3 + drivers/tee/sandbox.c | 137 ++++++++++++++++++++++- include/tee/optee_ta_rpc_test.h | 28 +++++ test/dm/tee.c | 109 +++++++++++++++++- test/py/requirements.txt | 2 + 12 files changed, 415 insertions(+), 9 deletions(-) create mode 100644 drivers/tee/optee/i2c.c create mode 100644 include/tee/optee_ta_rpc_test.h