From patchwork Thu Apr 15 16:48:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alex G." X-Patchwork-Id: 1466726 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=i6atvX97; 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 4FLlfm4vdQz9sW5 for ; Fri, 16 Apr 2021 02:49:04 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7B37C82022; Thu, 15 Apr 2021 18:48:50 +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="i6atvX97"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F0F7E82025; Thu, 15 Apr 2021 18:48:47 +0200 (CEST) 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-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) (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 B6D8A81FE1 for ; Thu, 15 Apr 2021 18:48:36 +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-x32c.google.com with SMTP id w21-20020a9d63950000b02901ce7b8c45b4so23149886otk.5 for ; Thu, 15 Apr 2021 09:48:36 -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=h3y1mYSYG2GW0U6vbwWA6JwPnRUzqmnRNwqT20R48CM=; b=i6atvX97AqoQ+Aye/4Kt0ikGrryJ63cBSJVI+X3hMPVOrbw1bxrwzqkXVl1UPBJ3u1 9zGMxQYwqowL6eUQmCd115Z1XGdX00JAj4YnIJfPgWNmiJ/F0bsRZZGwd3Im3mlzC6DG lM2JSx0h2geU5V7KVWtUoEe04Q4qlzkCFZ6QXZx8c+IUocDKB/KW3oF88gKJKM68XxUq 92c+lB7GbRjyEKyyUQ0rLohzVAWQvVIjnc6VyCAvubjevxv4Nc5Enl6BS1zggt/YsBaa cYMtpD8YcJbUG91FOez+ErIJiAWaX30mU6y7KIrWLI2NisNwXRtCZ6tB12KvuODGEMBc NYBA== 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=h3y1mYSYG2GW0U6vbwWA6JwPnRUzqmnRNwqT20R48CM=; b=Ynofkj//AECgp2AdsrUWjEUwYEgUdIMfYO5ZFBAfvMKZRtRh5ag7Efa8LE7hMf48Sk kOGnttIMIiYkStd3bd/2RdKVhLQB2UNdj1YMRo8C63IbPWzGdHRkgmJqdAwztSv/ifRI R/GEjQbbreFnynjogqhLue91OUkrCeOPW1FjmM0wijMqLvVtlDGPFqN+0cgvUQQhaw19 CCR4YcNyrY3jMx+ZqhGcgttKK9O3OJwDPRHTexxigjF2DNiGAJi6/qnH1rNSOKAiZ6yB WXpr1d6S+cxUZnMAR+evfc5CTRsZScNJWqnXoFD9DYFuojr1L7ZLsl9P5EhQh+7O6csj dPxw== X-Gm-Message-State: AOAM531JquuGUawHNM2Luh5KNnnqHiI5qTeX5XFZdD/aixkiQsQ7ITnS LcIa4MET93IJ+p320uZ+87V47tyuvDNb5Q== X-Google-Smtp-Source: ABdhPJyPxXhjnjMCvN5lfsAA1QKD0G6XvVeGUgBOWYFtRdl0zmRvOX9uBtm5UFdJsqgN4JWKHZqXIA== X-Received: by 2002:a9d:170a:: with SMTP id i10mr195559ota.32.1618505315084; Thu, 15 Apr 2021 09:48:35 -0700 (PDT) Received: from nuclearis2-1.gtech (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id p15sm768268otl.23.2021.04.15.09.48.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 09:48:34 -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 v3 2/5] spl: Introduce spl_board_prepare_for_optee() hook Date: Thu, 15 Apr 2021 11:48:26 -0500 Message-Id: <20210415164829.2302939-3-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210415164829.2302939-1-mr.nuke.me@gmail.com> References: <20210415164829.2302939-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 556a91ab53..190c8fd1b3 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -162,6 +162,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! */ @@ -723,6 +727,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 4f6e0e53f5..a3bedbc797 100644 --- a/include/spl.h +++ b/include/spl.h @@ -396,6 +396,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);