From patchwork Tue Mar 13 16:50:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 885281 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="X8Z+p+rO"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40117v05zCz9sTT for ; Wed, 14 Mar 2018 03:50:50 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id BEBB1C21E12; Tue, 13 Mar 2018 16:50:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 4C479C21C8B; Tue, 13 Mar 2018 16:50:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0C0F6C21C8B; Tue, 13 Mar 2018 16:50:42 +0000 (UTC) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by lists.denx.de (Postfix) with ESMTPS id 4F7CAC21BE5 for ; Tue, 13 Mar 2018 16:50:42 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id d10so807265wrf.3 for ; Tue, 13 Mar 2018 09:50:42 -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=kgfrI5cSjQql2MvEeOpYcXQrPRQ2+fuoLmPswao+xf0=; b=X8Z+p+rO83sepk2XMU4x+VFkQ+LUhMjzMbQ2ENXrRXchYxz3BUDi8kXx9xsfLj24Pb FD7SAP+97RvudD+C9FTlEj9l81H4Es92t2BdEa5FTHfO1y7TosjC1qyxHrabVeGTaRug EKqJNmzvLKwyxcFqVfrUo4M01CK/0WwAYkCyk= 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=kgfrI5cSjQql2MvEeOpYcXQrPRQ2+fuoLmPswao+xf0=; b=M8ERATEfRm8NOnLx4UCf6PDP0VM9dQLlt5qySUgL9nj/P8axxd3N8I1FKvJpAO29zW 8AlxLAnKut2Wd7rpTL7DEqRX36/MoKyZHJFn/6I3nXpF6+GsGAFsbI9z+KqGvqLsnIK+ kJFCqtxs67nYU2xgqXuhOxuqLnSUA8UyPLF5BL9vlWgfQTc7hmbH7+GjaUTEwgtgTml/ Ok4ax1WTgcX1HjlgFknqY1RUAcTffg89LLL4tXJqVM2pND2H57WaPSh8WNuy1iHc6zm9 SsWhnCdcUre9p2gULKTwV1t0qsSvo9dZCTANR7iEreJla2LteBk6diuLZ9XRcC4A6KHL wvrA== X-Gm-Message-State: AElRT7EjMB/ylu/ZKfDOoICQN0Vv5CaTig1AVlBMrhtnC58QH3d8JgmZ zyE6dECQCuugvNWifaKmqdwLUDh9buU= X-Google-Smtp-Source: AG47ELvKjdxBElBYlG6I4UiW5oRWXUIzAyUQ7VQz7gQuuX/T14Sj+bJtiyz0ZBwTgwyr7j68fe/KOg== X-Received: by 10.80.176.69 with SMTP id i63mr1564062edd.215.1520959841617; Tue, 13 Mar 2018 09:50:41 -0700 (PDT) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id 33sm476671edz.37.2018.03.13.09.50.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 13 Mar 2018 09:50:40 -0700 (PDT) From: Bryan O'Donoghue To: U-Boot@lists.denx.de, trini@konsulko.com, afd@ti.com, kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, peng.fan@nxp.com Date: Tue, 13 Mar 2018 16:50:26 +0000 Message-Id: <1520959836-16105-1-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [U-Boot] [PATCH v6 00/10] Add new OPTEE bootm support to u-boot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" v6: - Fix CONFIG_BOOTM_TEE Manually editing .config file meant this disparity was missed. "Those whom the gods wish to destroy they first make mad" v5: This patchset now works by making a bootable OPTEE image mkimage -A arm -T kernel -O tee -C none -d tee.bin uTee.optee The concept is the same as the earlier version of this patchset except instead of "mkimage -T tee" we do "mkimage -T kernel -O tee". Andrew suggested this and it is technically feasible. So here is the revised patchset. - Converted IH_TYPE_OPTEE to IH_OS_TEE - Andrew - Removed Tested-by: for Peng Fan on patches with churn as a result - Added patch for CONFIG_OPTEE_ADDR This CONFIG entry will be used in an upcoming set of patch for the board I'm working with. v4: - New type "optee" renamed to "tee-bootable". We discussed making the namespace here more logical and obvious in another thread. Kever may or may not end up adding "tee-combo". This patchset will result in "tee" and "tee-bootable" being valid names. Since "tee" is an existing image type the name will be maintained. - Tom - Added doc/README.trusted-execution-environment This gives a brief introduction on TEE plus some links to the spec and the op-tee website. In then lays out the difference between these two types "tee" (tee-standalone) "tee-bootable" - Bryan, Philipp - Small change made to comment on existing TEE - Bryan - Reworded the Kconfig option "OPTEE" Makes a little bit more sense to me re-reading now - Bryan - Add patch to define CONFIG_OPTEE_LOAD_ADDR An upcoming set of patches for a board will make use of this define in an OPTEE context. v3: - Rework printout to be added at the end as opposed to churn over three separate patches - Andrew - Reword patch 006 to better explain the thinking behind new image type - Andrew v2: - Added CONFIG_OPTEE_TZDRAM_BASE instead of #ifndef OPTEE_TZDRAM_BASE as an error. - Tom Rini - Added Tested-by: Peng Fan - as indicated - Added better explanation text to patch 6/9 "tools: mkimage: add optee image type" - Fixed some checkpatch warnings in optee.c v1: This series adds a new OPTEE bootable image type to u-boot, which is directly bootable with the bootm command. There is already a TEE image type but, in this case the TEE firmware is loaded into RAM, jumped into and then back out of. This image type is a directly bootable image as described here : http://mrvan.github.io/optee-imx6ul Instead of reusing the Linux bootable image type instead a new image type is defined, which allows us to perform additional image verification, prior to handing off control via bootm. OPTEE images get linked to a specific address at compile time and must be loaded to this address too. This series extends out mkimage with a new image type that allows the OPTEE binary link location to be validated against CONFIG_OPTEE_TZDRAM_BASE and CONFIG_OPTEE_TZDRAM_SIZE respectively prior to proceeding through the bootm phase. Once applied you can generate a bootable OPTEE image like this mkimage -A arm -T optee -C none -d ./out/arm-plat-imx/core/tee.bin uTee.optee That image can then be booted directly by bootm. bootm will verify the header contents of the OPTEE binary against the DRAM area carved out in u-boot. If the defined DRAM area does not match the link address specified we refuse to boot. Kever - I'd like to suggest that your OPTEE SPL image takes a different image type IH_TYPE_OPTEE_SPL ? to indicate the different behavior your image type has versus a directly bootable bootm image. Bryan O'Donoghue (10): optee: Add lib entries for sharing OPTEE code across ports optee: Add CONFIG_OPTEE_TZDRAM_SIZE optee: Add CONFIG_OPTEE_TZDRAM_BASE optee: Add CONFIG_OPTEE_LOAD_ADDR optee: Add optee_image_get_entry_point() optee: Add optee_image_get_load_addr() optee: Add optee_verify_bootm_image() optee: Add error printout image: Add IH_OS_TEE for TEE chain-load boot bootm: optee: Add a bootm command for type IH_OS_TEE common/bootm_os.c | 32 +++++++++++++++++++++++++ common/image.c | 1 + include/image.h | 1 + include/tee/optee.h | 41 ++++++++++++++++++++++++++++++++ lib/Kconfig | 1 + lib/Makefile | 1 + lib/optee/Kconfig | 39 ++++++++++++++++++++++++++++++ lib/optee/Makefile | 7 ++++++ lib/optee/optee.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ tools/default_image.c | 15 ++++++++++-- 10 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 lib/optee/Kconfig create mode 100644 lib/optee/Makefile create mode 100644 lib/optee/optee.c