From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96196C47080 for ; Mon, 31 May 2021 17:43:48 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C55A461186 for ; Mon, 31 May 2021 17:43:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C55A461186 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C1B382EA1; Mon, 31 May 2021 19:43:37 +0200 (CEST) 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="Ssa5LD3l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B05CC82EA6; Mon, 31 May 2021 19:43:28 +0200 (CEST) Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) (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 D491F82E92 for ; Mon, 31 May 2021 19:43:23 +0200 (CEST) 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-x32e.google.com with SMTP id 36-20020a9d0ba70000b02902e0a0a8fe36so11742616oth.8 for ; Mon, 31 May 2021 10:43:23 -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=8dwe7G/XRvgkF8MmiPR+gQfsB6lpVV8CrYeHDvpuF4Y=; b=Ssa5LD3lT1ZjlcnkOMFqQSDS9f5bBeO7NAn/hHkYgxEODUo3xTBkct9vpamjIn5Gre dT9coz4SHAvGpXiuGlny/eiN3Zw0kwn9RDv8wJhvL0ih/NZ7ehvhJCyjHzKtK6bUgahn W6yKZBUWElHCVzvsHp8n7ay+szEoQWf8Pyf4lLKqcxHi4igelWR9h9bTP6NEGuatt0xO cmP+NrNCxtsrsy3gmO4Fpt41baQBqakyFuXJgtCO/To4LmCcmbHqIMeksgzsssen1IbS fnxh8C29WxYTH4cusZh4+oTnCZQIW90FuwmvfbWCc54cQ4xqL4gNjbEErdhPR26e5hYq rXEg== 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=8dwe7G/XRvgkF8MmiPR+gQfsB6lpVV8CrYeHDvpuF4Y=; b=XV9C3MwVMyTMEcJnJm7eRs26JPpGXU/GNx+l1UCSwcRytT9o7KMUZJQje8vP5qEHVX 5aMnMMmp6wmIGztZ5USHuuGGF5faP1inD5I973mbigmsUlkqxxdyGzUYLw0t+qUntttN sCv+OpadaobShHkCEvsDdcl3HPVdb+l/QAQGa1qVOyDm2/IkHjs6vNHJl5nuqH/RR1Sh yrRsRjb3R4WNAUFSWA3GnJCPLYIXBUfPk3Acu6lnFnZK5eM0nHsZaKZ46gSH3h4n1XSu JlplDg967wwT3kDHvs8v84lRlI/99eL7YPBOJbXpRkt6rW45uYRjudhV4/ehNmtawStF YKxA== X-Gm-Message-State: AOAM533zabLDttqEPPHrTEqv6TMbZxHP7Mmc+7X4BDTlRs8OnHyzC/h4 R4FIJKZz5aB3pN9j3a1GrOr3oegLilM= X-Google-Smtp-Source: ABdhPJx5nfFeYj6nVXhjVwtD2GRr32kiA2wk4Fzq4oK5XFTWs+jpvgUO1ecbguG89Q5x3s3k492Zmg== X-Received: by 2002:a05:6830:1251:: with SMTP id s17mr18453921otp.81.1622483002335; Mon, 31 May 2021 10:43:22 -0700 (PDT) Received: from nuclearis3.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id 12sm825048ooy.0.2021.05.31.10.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 May 2021 10:43:22 -0700 (PDT) From: Alexandru Gagniuc To: u-boot@lists.denx.de, trini@konsulko.com, patrick.delaunay@foss.st.com Cc: Alexandru Gagniuc , sjg@chromium.org, etienne.carriere@linaro.org Subject: [PATCH v4 2/5] spl: Introduce spl_board_prepare_for_optee() hook Date: Mon, 31 May 2021 12:43:11 -0500 Message-Id: <20210531174314.1395666-3-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531174314.1395666-1-mr.nuke.me@gmail.com> References: <20210531174314.1395666-1-mr.nuke.me@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 a0a608fd772..56f6d47b164 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -165,6 +165,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! */ @@ -745,6 +749,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 cee9a42ddb5..04ab2b6d7d8 100644 --- a/include/spl.h +++ b/include/spl.h @@ -388,6 +388,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); -- 2.31.1