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: 863785 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jqSfUOqe"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3zNWbq0T8nz9s7F for ; Sat, 20 Jan 2018 06:48:54 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 3E676C21F76; 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-Google-Smtp-Source: AH8x22542ck1xYCZgjE8o8hV6+g5pTFspe1gQ886fCbyPWJdNLzu4IJkXu8rMVFuZNdXQ7l6Oqw+ww== 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;