From patchwork Fri Jan 12 14:52:21 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: 124355 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2155589qgn; Fri, 12 Jan 2018 06:58:18 -0800 (PST) X-Google-Smtp-Source: ACJfBouzSSxT5qkB7ct7sGnzuQVazoa3KUkF3UrA4w/2HdPwWmqu65lP/AEW3ULGkZHtjBKBmQ9l X-Received: by 10.80.240.2 with SMTP id r2mr6903579edl.91.1515769098807; Fri, 12 Jan 2018 06:58:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515769098; cv=none; d=google.com; s=arc-20160816; b=TQXbCncZ7VX93BZ9rl1vmhGKfzH6vJ4nLpxA1/PHgOFkVb86Jn5mCYfLwMgYMqUQs1 wtqMcP42AhtMKNvAVaoW93X5v2QaKBnD+Dex7Llq/GGKVOiNYT6jKJTUthtbqarYfMl7 GP2Se/g6nhvDGZ2Cvu8ivK8ld4uVEXtVvNR6eSE9HIBo5yFDK2D59YcYWFZxBso7CZr2 TxQso3yLFbNcMOno2avR0sX1cqlJzFb1H35lBJ6pJMGjCUpu0se9CY7NsJ9GpxrPUfnL Oayq1//a3i5c8869WXrR12G0NzR6X51UCUxF5XQH1LUgklho2a5Zu7VtUWeAOOmpQ+u9 V/dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=rLlOOGDf7qZvXU1mLwglbQdFBTzeSXOQq30ie4Dxdto=; b=kZtnxsUGv9iLNiasVPCm/VFHmJydm7dNwxMMZcuoVTBlw3JXQRrT7OmXQXtM3oat7g LBVJDlGmN+tsnByBf+jkdcUFGPllof7YMgGQj6pn+Xkzb4cwD+xqlXLgXs4Reb4pB8eY YGqpYfpx4xCw1eC4sXcsgMudCqcRFJtrtIDGYYReUCyznKQnoiD7rLiQcf8GDmL1FgxM iQO97Pe+GJMedWbbE90/mZrRQzE0sV/oO5XHq9amkQj1oacysYqjTC1I9iDfZeaIvjmH wH5S26J1k2bPoZ+rOAwzmqpsEdWpLgCSYL9qfYvNuTZ0yl7HL0Qe4l/pKaXSVUQvFIRP nM7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kkF71uf9; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id x90si281246edc.235.2018.01.12.06.58.18; Fri, 12 Jan 2018 06:58:18 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=kkF71uf9; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id 60DACC221FA; Fri, 12 Jan 2018 14:58:04 +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_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 ED8DDC22283; Fri, 12 Jan 2018 14:52:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0B04AC22271; Fri, 12 Jan 2018 14:52:36 +0000 (UTC) Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by lists.denx.de (Postfix) with ESMTPS id C0861C22261 for ; Fri, 12 Jan 2018 14:52:32 +0000 (UTC) Received: by mail-wm0-f65.google.com with SMTP id i11so12291809wmf.4 for ; Fri, 12 Jan 2018 06:52:32 -0800 (PST) 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=+AjnYS7CO+0XC96Z5+Mx+PyqTRgnT5RevNQ3wB8+yLE=; b=kkF71uf9DeBw/889VAPNwfsVNlG7yMOuZ0xUIfGdxZtXJcYQbkrW0tboYaJohtU0Df zjCNZxc0w10qrh7YuHnYMBiRXuTMlvk0RWBx6NT+mGzUhO0ZFI9vwxgw//QfOiGf+J1R kSuP6inH1VXgxRnGas0dyUYxDeU0OTfPHZDmk= 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=+AjnYS7CO+0XC96Z5+Mx+PyqTRgnT5RevNQ3wB8+yLE=; b=o9mqsUB4kQmHAWZWZ3qEJ/9FibcIViEFr4WbOTNHQP5RLiKSVIm5U+jDDszIxVPrBZ b9IN2m4Ivq2G3TyaAgPrhiPfvqveFOXmxHrEh+FK4eq+jjNFiGqnUrA2Sbk8Fq5m9viY 7VKO1kHE+78yBhwvYqPGC5+UilCtRirlNpxKGpcd2POCHIMrYmb7gUivtjJ58JRBMQ3l jUQAJWj6EYfimkOl8WvK5Yqqou5u9LEi1BSFF4rCGSVP5gl8ofHiCX8C5JEc2k708XIg Y3l+XS3Yli8hWhkHrEFxFMuMHLv9S09FTad+RvujWyEP2V9/5TiAyTtYGNXWId1qqWom AwEg== X-Gm-Message-State: AKwxytcnxbGkpdfYFhZmLKHb/WUJnlhHXL/33iQivG44hpYRuA8HPK5b dQKVlUOvaCbZi/Fucf9axD+0TldXUp8= X-Received: by 10.80.246.133 with SMTP id d5mr16866953edn.93.1515768752271; Fri, 12 Jan 2018 06:52:32 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id d20sm1318629ede.16.2018.01.12.06.52.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jan 2018 06:52:31 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de Date: Fri, 12 Jan 2018 14:52:21 +0000 Message-Id: <1515768744-25246-7-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515768744-25246-1-git-send-email-bryan.odonoghue@linaro.org> References: <1515768744-25246-1-git-send-email-bryan.odonoghue@linaro.org> Cc: trini@konsulko.com, harinarayan@ti.com Subject: [U-Boot] [PATCH 6/9] tools: mkimage: add optee image type 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" This patch adds support for bootable OPTEE images to mkimage. Currently there is a (Trusted Execution Environment) TEE image type, the TEE image type is installed to a memory location with u-boot continuing to own the boot process whereas the OPTEE image type defined here is a bootable image, which typically wants to live at a defined location in memory. Defining a new image type allows us to pull out the load address and entry point defined in the OPTEE header and having a separate image type lays the foundation for a subsequent patch to validate the OPTEE memory defined in a board-port matches the link location specified in the OPTEE bootable image. example usage: mkimage -A arm -T optee -C none -d ./out/arm-plat-imx/core/tee.bin uTee.optee Signed-off-by: Bryan O'Donoghue Cc: Harinarayan Bhatta Cc: Andrew F. Davis Cc: Tom Rini Cc: Kever Yang Cc: Philipp Tomsich Cc: Peng Fan --- common/image.c | 1 + include/image.h | 1 + tools/default_image.c | 25 +++++++++++++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/common/image.c b/common/image.c index 4bcf6b3..381ef07 100644 --- a/common/image.c +++ b/common/image.c @@ -161,6 +161,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_TEE, "tee", "Trusted Execution Environment Image",}, { IH_TYPE_FIRMWARE_IVT, "firmware_ivt", "Firmware with HABv4 IVT" }, { IH_TYPE_PMMC, "pmmc", "TI Power Management Micro-Controller Firmware",}, + { IH_TYPE_OPTEE, "optee", "OPTEE Boot Image",}, { -1, "", "", }, }; diff --git a/include/image.h b/include/image.h index a128a62..9175624 100644 --- a/include/image.h +++ b/include/image.h @@ -271,6 +271,7 @@ enum { IH_TYPE_TEE, /* Trusted Execution Environment OS Image */ IH_TYPE_FIRMWARE_IVT, /* Firmware Image with HABv4 IVT */ IH_TYPE_PMMC, /* TI Power Management Micro-Controller Firmware */ + IH_TYPE_OPTEE, /* OPTEE Boot Image */ IH_TYPE_COUNT, /* Number of image types */ }; diff --git a/tools/default_image.c b/tools/default_image.c index 4e5568e..5653933 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -18,6 +18,7 @@ #include "mkimage.h" #include +#include #include static image_header_t header; @@ -25,7 +26,8 @@ static image_header_t header; static int image_check_image_types(uint8_t type) { if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) || - (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT)) + (type == IH_TYPE_KERNEL_NOLOAD) || (type == IH_TYPE_FIRMWARE_IVT) || + (type == IH_TYPE_OPTEE)) return EXIT_SUCCESS; else return EXIT_FAILURE; @@ -90,6 +92,8 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, uint32_t checksum; time_t time; uint32_t imagesize; + uint32_t ep; + uint32_t addr; image_header_t * hdr = (image_header_t *)ptr; @@ -99,18 +103,27 @@ static void image_set_header(void *ptr, struct stat *sbuf, int ifd, sbuf->st_size - sizeof(image_header_t)); time = imagetool_get_source_date(params, sbuf->st_mtime); - if (params->type == IH_TYPE_FIRMWARE_IVT) + ep = params->ep; + addr = params->addr; + imagesize = sbuf->st_size - sizeof(image_header_t); + + switch (params->type) { + case IH_TYPE_FIRMWARE_IVT: /* Add size of CSF minus IVT */ imagesize = sbuf->st_size - sizeof(image_header_t) + 0x1FE0; - else - imagesize = sbuf->st_size - sizeof(image_header_t); + break; + case IH_TYPE_OPTEE: + addr = optee_image_get_load_addr(hdr); + ep = optee_image_get_entry_point(hdr); + break; + } /* Build new header */ image_set_magic(hdr, IH_MAGIC); image_set_time(hdr, time); image_set_size(hdr, imagesize); - image_set_load(hdr, params->addr); - image_set_ep(hdr, params->ep); + image_set_load(hdr, addr); + image_set_ep(hdr, ep); image_set_dcrc(hdr, checksum); image_set_os(hdr, params->os); image_set_arch(hdr, params->arch);