From patchwork Fri Jan 19 19:43: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: 125219 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp444112ljf; Fri, 19 Jan 2018 11:47:40 -0800 (PST) X-Google-Smtp-Source: AH8x225JWqWbXJ5nmtXM5wtMCYW2qe0ZJQ9kgMrwjn2SqMN1mx1o5KbtICkDPIYho4aBvE8jTMJO X-Received: by 10.80.133.140 with SMTP id a12mr57605edh.286.1516391260772; Fri, 19 Jan 2018 11:47:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516391260; cv=none; d=google.com; s=arc-20160816; b=awIuIrfP5sAbvz71nUGJGfBHGyphjaHcEr6pJSOBHNA/pPO0UR9IEBhq6CvFv3sMDk L6lUOS7zu66C2SRBpAiNWiuUs6lpFwyN9zi6+HI4VYL209VWP7shs5qtwYSeMJ4+GYxs Zh/OcwPNDp/EuetU8ED9nuUztc0uXT/bmA+uA/bo6DsHQQ0JtpxjkgIzqLLlnXeoJ9GI yN3F87PE/Y2mUuuTx54nNHnI+bzfpo4ykfi4ocvpYgEP8Lk+OQBH8r8K0gpEeCHYI4cs NsihyPg+T4oQ9MQrPAJVKrxksiTR0EmvcqsGHzoioVi7OrfB1gXeNqVQoP5JHYbx+Mm4 NeGw== 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=QFzOjjw6Ls0OcJzw5JuhqTbQjg8RHaD1PzgICbRrVMo=; b=cINYtTUxryFsMyh1I9ZZ7Oqa4hxl233hVXpV5SgRVuq0LaCRW1OaYVajDSG4VGJGa9 61W09LTNRfNQTzWRsk62JNt4I2CdaVz8Hjgxz2BdAruaWlaNLdp6bsaHBKXFkzXO9AxZ dkaPju8ERGjcVrnVPYZl229Lb0e7VrQutNnYaHj+q9R0QQ+ms4YhNRBRp8Th2CjVV8ou M5lYKVnw6PtfQ+j9PjWpzUndelvELu/f2nEQ97QpbZa6W5olOydyioDPKt8a3WRPhzoz qje4CNGoA69BShcOvSF/MxS4lOPkWLxuHQAeWbJjPQMr0Kr+PmulbkTXYdeYQDVoKPX2 hzng== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=jqSfUOqe; 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 44si9606682edt.374.2018.01.19.11.47.40; Fri, 19 Jan 2018 11:47: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=jqSfUOqe; 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 517B9C21F9E; Fri, 19 Jan 2018 19:45:15 +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 1BD87C21F9A; Fri, 19 Jan 2018 19:43:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 75B08C21F91; Fri, 19 Jan 2018 19:43:45 +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 9CAFDC21DDF for ; Fri, 19 Jan 2018 19:43:41 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id 141so5659369wme.3 for ; Fri, 19 Jan 2018 11:43:41 -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=VfQzZRzM3DQYXdLJBCX//TaVWV5MboWeZdKPbCHr1qE=; b=jqSfUOqeD0EEL5+mn0x1rdfji4Y2m6p4kFEaxfkQWjV4AzrzxeEcLQJhBeCdvPY7E2 mhy17I0xrtmUnE33KfC0ssPbemxIEbsXoBssY8owsaIbjtWQUY6Qd1jpVE+VH8+HkOWq lKJn7GfHaxUyehmkBIXpQkzsFhIgmLMymmiR0= 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=VfQzZRzM3DQYXdLJBCX//TaVWV5MboWeZdKPbCHr1qE=; b=WyROJEca+pQ+ZdmOSYo6NtmCXZhelKuc/Sm8bwrAQm/hXzz6dsKyipey43xb7z/GFi lZ2Sfw8QgWRnXuZHKxvV7eUQvD7vTqC0PjtU4H0o0KIgBKzlYNNTfbJq9XawaMfhFaIs zWPMmZfvRQp195dMsPHXAlqt4V5A/1cILYSYQGKOtLQjOpQFmCHF/NjktVeuNun/TUIP ARWu7C0QvVVy/fDH8j2U+5UUkAQDmDuHkXG5/2Vkelo7L/UQxaQny3WDjj5HXtZzeyv/ guJTYlcrTdBz2K08YJ3WXEzmb/vsXtsoKioQWHVam9WIiAL/0nkAeI2kKpV2y3imr7al 6caA== X-Gm-Message-State: AKwxytduKJPQBBJ/B9GfCo7BEU4uJ7T809sVUWIixN4DIHF0l5uvkOLv +wJrR7op7xVuwRFaICtVjRQ7IIFLeyY= X-Received: by 10.80.208.145 with SMTP id v17mr56081edd.182.1516391021065; Fri, 19 Jan 2018 11:43:41 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id p6sm5936051edh.68.2018.01.19.11.43.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Jan 2018 11:43:40 -0800 (PST) From: Bryan O'Donoghue To: u-boot@lists.denx.de, trini@konsulko.com Date: Fri, 19 Jan 2018 19:43:26 +0000 Message-Id: <1516391006-22483-10-git-send-email-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516391006-22483-1-git-send-email-bryan.odonoghue@linaro.org> References: <1516391006-22483-1-git-send-email-bryan.odonoghue@linaro.org> Cc: harinarayan@ti.com Subject: [U-Boot] [PATCH v2 9/9] bootm: optee: Add mechanism to validate an OPTEE image before 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" This patch makes it possible to verify the contents and location of an OPTEE 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..d528844 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_OPTEE) { + 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_OPTEE)) && (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_OPTEE: *os_data = image_get_data(hdr); *os_len = image_get_data_size(hdr); break;