From patchwork Mon Mar 15 15:47:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Gagniuc X-Patchwork-Id: 1453336 X-Patchwork-Delegate: patrice.chotard@st.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=JjzzQllY; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DzgmS0mc3z9sCD for ; Tue, 16 Mar 2021 02:47:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 39BD8826BA; Mon, 15 Mar 2021 16:47:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="JjzzQllY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DD7AA82759; Mon, 15 Mar 2021 16:47:30 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6B8388204D for ; Mon, 15 Mar 2021 16:47:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-ot1-x329.google.com with SMTP id p24so7194897ota.11 for ; Mon, 15 Mar 2021 08:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h+BQQHpGhQ8f2JJnEqbkjGsv42BWrAydOlo4D2bgDdY=; b=JjzzQllYrle0AXoMzvy6qjMbHF1viTgyX19NSt4tNmLpxgJdewco/Wzh7a1sUXO5Ej Y4FD3ftzrFrUB1kw7HP6v2kPnSrfaOQixB5JKZPRp00eB3aBIm8CMIGzNAYLeZNqqnZc pNPn9K9dO20uk6cP6i+YzrR8zo8YbIGjm/avu0MvUFeXmZAiwV1i0C16v4wyzYP9yE43 ROkkgwwFp8ORPQ05nT0vqtut6SLmAe2IiR5RENpUMZQHUhn1F0uG0+NbOGwfJ9aKcFLW azB3h/Bt41K9+68mm7hfJC9ZrMEqZ2rEt009msmJgATC6qPtkU4kcVzy7FRldNM5GtLf wnKA== 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:mime-version:content-transfer-encoding; bh=h+BQQHpGhQ8f2JJnEqbkjGsv42BWrAydOlo4D2bgDdY=; b=II0Q9a2FlaA41NdqJLLU3GJ/h+obo7EabOvpSl2BpunDTZukFK3BPgvPGzhsApx/3D qv+EDTC2g1S2efO8EM31KUflOxn+TMdqLn3gXOiOBrLJIjElriRUvtH/tlWt4CA6Nh/C K2k4yl9WJgAIQwY9KDq0mxb4W3tzL26nhTtMxbZGR8VOGatpny8T4TRu/XPzP2PIxOMH VFGki0S7t+S13LbKWuiPjxNAd5Egrq+ucrx3cWCNHs121ifckJYFuUykRMnSobFySf48 JIxsquhnKrHH4kn+DG2ruYAy06MunNAnJddz+Wfr7e8QHMJuf9oqIKq1Jr00qrjFO2st Ojjw== X-Gm-Message-State: AOAM5325MRVzlu8t/A+IbqB3/hE9VRHaW9ZpvP6Z7SMtqsLjmLZJsazH 1ugmxm/IqKbfTrtx9d/WwzwxXlHZg5Y= X-Google-Smtp-Source: ABdhPJxVTIni2EDyJLRHhJySrg4fGU0DUM2J8G5vBBiUKK49e0sQgP1MpUA3nTVE/4izAKBJ4ZjVGA== X-Received: by 2002:a9d:ef3:: with SMTP id 106mr14586148otj.24.1615823244910; Mon, 15 Mar 2021 08:47:24 -0700 (PDT) Received: from nuclearis2-1.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id x18sm6560960otr.73.2021.03.15.08.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Mar 2021 08:47:24 -0700 (PDT) From: Alexandru Gagniuc To: u-boot@lists.denx.de Cc: Alexandru Gagniuc , trini@konsulko.com, sjg@chromium.org Subject: [PATCH v2 2/5] spl: Introduce spl_board_prepare_for_optee() hook Date: Mon, 15 Mar 2021 10:47:12 -0500 Message-Id: <20210315154715.2258433-3-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210315154715.2258433-1-mr.nuke.me@gmail.com> References: <20210315154715.2258433-1-mr.nuke.me@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean OP-TEE requires some particular setup, which is not needed for linux or other payloads. Add a hook for platform-specific code to perform any OP-TEE related configuration and initialization. A weak function is used because it is symmetrical to other spl_board_prepare_for_*() implementations. A solution to avoid the use of weak functions would trivially apply to all these implementations. However, re-designing this is beyond the scope of this patch. Signed-off-by: Alexandru Gagniuc Reviewed-by: Tom Rini Reviewed-by: Simon Glass Reviewed-by: Patrick Delaunay --- common/spl/spl.c | 5 +++++ include/spl.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/common/spl/spl.c b/common/spl/spl.c index e3d84082f4..bf4629588e 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -161,6 +161,10 @@ __weak void spl_board_prepare_for_linux(void) /* Nothing to do! */ } +__weak void spl_board_prepare_for_optee(void *fdt) +{ +} + __weak void spl_board_prepare_for_boot(void) { /* Nothing to do! */ @@ -706,6 +710,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) #if CONFIG_IS_ENABLED(OPTEE) case IH_OS_TEE: debug("Jumping to U-Boot via OP-TEE\n"); + spl_board_prepare_for_optee(spl_image.fdt_addr); spl_optee_entry(NULL, NULL, spl_image.fdt_addr, (void *)spl_image.entry_point); break; diff --git a/include/spl.h b/include/spl.h index 0d134587de..939b77972a 100644 --- a/include/spl.h +++ b/include/spl.h @@ -387,6 +387,20 @@ int spl_parse_image_header(struct spl_image_info *spl_image, const struct image_header *header); void spl_board_prepare_for_linux(void); + +/** + * spl_board_prepare_for_optee() - Prepare board for an OPTEE payload + * + * Prepares the board for booting an OP-TEE payload. Initialization is platform + * specific, and may include configuring the TrustZone memory, and other + * initialization steps required by OP-TEE. + * Note that @fdt is not used directly by OP-TEE. OP-TEE passes this @fdt to + * its normal world target. This target is not guaranteed to be u-boot, so @fdt + * changes that would normally be done by u-boot should be done in this step. + * + * @fdt: Devicetree that will be passed on, or NULL + */ +void spl_board_prepare_for_optee(void *fdt); void spl_board_prepare_for_boot(void); int spl_board_ubi_load_image(u32 boot_device); int spl_board_boot_device(u32 boot_device);