From patchwork Mon Feb 26 12:36:05 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: 129636 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp156005lja; Mon, 26 Feb 2018 04:40:40 -0800 (PST) X-Google-Smtp-Source: AG47ELugGWLAPbB+ILU8xUW3835gy59iwrHsK6DYq9lQ2KNFzcEbyZQAUOqv1VPYVneGHDYSEFnw X-Received: by 10.80.222.77 with SMTP id a13mr10502789edl.176.1519648840293; Mon, 26 Feb 2018 04:40:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519648840; cv=none; d=google.com; s=arc-20160816; b=sqha/esmEJ79XqxvHnhcglmIBQFxci83cxeSjG5cHMRoxx59ZLfJsnDM4OkrLvSIdw O5bbAsV9rx8bhBFurD/pbb450Y6qG8ahqkqBpkSSw3Wne8ztoDwWlprncIJuJifTzsOi mATNq58fUHh5eccVd4wHsnTWbBLOp4jX8/lLrOsm4NNV0dDcCZFW/fZ95LHT2fT2orZ5 A7rbw3egGm1V6NfifswOLKznaqSrzYPm5qGSYZQzIyoA2odT1N2Vi74Z0MwN4k2qmDxf b3IOrltrAsUUb0ygAUpdIXZKAlHx5v7c+1R+Hr/kjcS+zTLPP9vAY+Gr8rcu3BdaXNbY wQxQ== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:arc-authentication-results; bh=ex13RZzct18N40wXo6DGvzO6oijfoSlboEUjXG44mMQ=; b=OThu6gPNPrEinVBUlysFTBZcB1GUB4xe4r3EtLu18Lk27uNrI1RSgThRgoPTF+jD0y 3bB7UWoSODWqDQ237INY+BbqWSKrZeGxMC6qjUM8SkuqAcDHbviseGwhui32V5iKmf6B Dobwg7At4fKu7c7sRp3FID854E4my/F7JZAAcSOqhGdh1+cu3ofy0n1aM5hAJ2kh32kH gLdKrW5VE7ySraPOt9Bo7trKDbZxAS+Y7+boLZn/QWws6HJbAGJJ1Ai8iIL9T+VUdZ/1 uzoDwFYJ7T8BvbRQemSmgDQCDWjHeSJqk4kk8rP/6IEd0wuZtr7b6qsCYd2I+JimxYXG HSlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=N5lQOWKX; 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 q6si9226324edc.17.2018.02.26.04.40.40; Mon, 26 Feb 2018 04:40:40 -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=N5lQOWKX; 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 BF0A1C220F7; Mon, 26 Feb 2018 12:40:16 +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_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 E3082C22122; Mon, 26 Feb 2018 12:37:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4BC30C22118; Mon, 26 Feb 2018 12:36:25 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id 5C4DFC220C5 for ; Mon, 26 Feb 2018 12:36:21 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id h21so17136887wmd.1 for ; Mon, 26 Feb 2018 04:36:21 -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=9ZcMRc8SBntseoaIVMS6azZkIlMR4wH0szSTketBFIA=; b=N5lQOWKXT2ZxRgIgV4yas3Ob96y78a4Nr2WPpwv1unV8iTRxfIhIcqBO+/M1iJ8bZP nQL5+FgrZ9teGKAkTQ97UcsavFYWMAktFqaKlQIJNgO++9aVOVQ7eL5yHhVpdVfVEaPm fec9JO6ehKMbxOSYaA1ntg71Sqgsn1wTYiDv8= 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=9ZcMRc8SBntseoaIVMS6azZkIlMR4wH0szSTketBFIA=; b=Dyyv72hm1HG6eThEwIbXsO9+DVYXZ1SzaTH2ewDZVy7w4ljQAIPHUFbvGBqFVcpX+7 gkjNJ+Df4cMzk+AQNge6hYEaZZ8mrdVu4AGs6BbyGsT5WX6dmp5fDbaQ13M0zbAFes2v G9NsfS9Vey8igLqX7gQ/flwYmGzQ9HAe9IRuY/Vt893DjcT790wqXMfqNk37/CEebORz 72I3YvUz5Etk6mJPIKNh6ujnGGmEOkw9F28B0/FsfFsPaePpgYQjNR2BobA27GE0YMAz jKT+tFyupnjY39UnBc0N5opgYQXCGtwJUufVFbpgkWL0rQplGRNd8wDjvolRgnV7qN5a jP7g== X-Gm-Message-State: APf1xPDjwNACwyPiDq4hGAqFougHJbDGG6NCvtrLdzF9H3Q2Nl4+WBkt /EU/R05dNS4IJaH3/qsOerAqUNz7MSU= X-Received: by 10.80.212.43 with SMTP id t43mr14397906edh.53.1519648580707; Mon, 26 Feb 2018 04:36:20 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id f6sm2493967edn.45.2018.02.26.04.36.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 04:36:20 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, trini@konsulko.com, harinarayan@ti.com, afd@ti.com, kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, peng.fan@nxp.com Date: Mon, 26 Feb 2018 12:36:05 +0000 Message-Id: <1519648566-12061-12-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519648566-12061-1-git-send-email-bryan.odonoghue@linaro.org> References: <1519648566-12061-1-git-send-email-bryan.odonoghue@linaro.org> Subject: [U-Boot] [PATCH v4 11/12] bootm: optee: Add mechanism to validate a bootable TEE image 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 makes it possible to verify the contents and location of an a bootable TEE image in DRAM prior to handing off control to that image. If image verification fails we won't try to boot any further. 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 Tested-by: Peng Fan --- common/bootm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common/bootm.c b/common/bootm.c index adb1213..3246ceb 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -19,6 +19,7 @@ #include #include #include +#include #if defined(CONFIG_CMD_USB) #include #endif @@ -201,6 +202,12 @@ static int bootm_find_os(cmd_tbl_t *cmdtp, int flag, int argc, if (images.os.type == IH_TYPE_KERNEL_NOLOAD) { images.os.load = images.os.image_start; images.ep += images.os.load; + } else if (images.os.type == IH_TYPE_TEE_BOOTABLE) { + ret = optee_verify_bootm_image(images.os.image_start, + images.os.load, + images.os.image_len); + if (ret) + return ret; } images.os.start = map_to_sysmem(os_hdr); @@ -275,7 +282,8 @@ static int bootm_find_other(cmd_tbl_t *cmdtp, int flag, int argc, { if (((images.os.type == IH_TYPE_KERNEL) || (images.os.type == IH_TYPE_KERNEL_NOLOAD) || - (images.os.type == IH_TYPE_MULTI)) && + (images.os.type == IH_TYPE_MULTI) || + (images.os.type == IH_TYPE_TEE_BOOTABLE)) && (images.os.os == IH_OS_LINUX || images.os.os == IH_OS_VXWORKS)) return bootm_find_images(flag, argc, argv); @@ -827,6 +835,7 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, switch (image_get_type(hdr)) { case IH_TYPE_KERNEL: case IH_TYPE_KERNEL_NOLOAD: + case IH_TYPE_TEE_BOOTABLE: *os_data = image_get_data(hdr); *os_len = image_get_data_size(hdr); break;