From patchwork Thu Jul 15 19:19:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Gagniuc X-Patchwork-Id: 1505878 X-Patchwork-Delegate: patrick.delaunay73@gmail.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=85.214.62.61; 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=CG6sXyqG; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 4GQkj35Nvnz9vL1 for ; Fri, 16 Jul 2021 05:20:07 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 72B0B82C3B; Thu, 15 Jul 2021 21:19:51 +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="CG6sXyqG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8025382EA5; Thu, 15 Jul 2021 21:19:39 +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-oi1-x231.google.com (mail-oi1-x231.google.com [IPv6:2607:f8b0:4864:20::231]) (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 80BE982BE8 for ; Thu, 15 Jul 2021 21:19:33 +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-oi1-x231.google.com with SMTP id h9so7955647oih.4 for ; Thu, 15 Jul 2021 12:19:33 -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=qHzwIYl1ZDK6HUzNRZXkuFoTqplS/3MtIG1oGrXdN/8=; b=CG6sXyqGXkgGengY8r3XmZc10rusYdeyhf05whDxgAy584iXMyiXNk9e2tPItRgecA UsZZONdsS0tCOB7Gy5faM7JftjdouHZkXyHu5NKZ7gY9lP2h/ClPvCZV9w7eIhTX+lFp Ii1tOuLYNiaQFsBk2ItrbTo8tD2JGZbqED4iGfcz4lASnovyzDYjii87FaOhAAa8Jkae I/1MLxY3CDi0eXndmxFn0EetQIgfxHONYBQFZG7B8uk6uVLVtaX0suf6VNwEJkd7ohc0 4YPjkpoWuV83j9BVYWKXoGzNAh9ZAb7cquW/0aa6hC6o8P1Q2A1GsP1KoMSf0FlL6zBC f5QA== 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=qHzwIYl1ZDK6HUzNRZXkuFoTqplS/3MtIG1oGrXdN/8=; b=IsaCtHnD4ELUQ8q/PiAUoRU808mYsPcdrbomclYQgT3WB1RjU4w67EpDVs33nvZwpr 4tdGmHkilKZbppU11qsE97oXU3uuWxEyBmDKJ8WtR0ihio3q5rFs5f1aNkKg6+SjsBe4 M4cx/0vvBVb6xa2jV/RsdXgtKA/o4Cz7YbY2u7k2eYICpdwA/aMCRsKe58JZH9paKPfE B+4HZMEmZMLCDkBt5ZGYOMTUmnNWenDfs7ElOfGbKPdrfQAUtlD0AHOI/WY3pImGCuTE MsgZBESkwzvXqcIoFfmYbWknv0UxygfXokFTUyrJEE8lAni8xTEgg9YWKfIAe2Dwl1TQ WlTQ== X-Gm-Message-State: AOAM531ucBUcKk2t/81/ryLxdyyNnhqwcz277vwhu5ja7KRl17FagsZC z6aKivGvm67X+HoN+ISaJCfdOTyvRcs= X-Google-Smtp-Source: ABdhPJyXUsapa1msuFSsrnghaOn7Bhxuz5hLkz04NBFWrhjQzpkP5a8B4au9F99Tyvn5ezKUs+/d6w== X-Received: by 2002:aca:cf97:: with SMTP id f145mr9284880oig.108.1626376771759; Thu, 15 Jul 2021 12:19:31 -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 4sm1264377ooc.42.2021.07.15.12.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 12:19:31 -0700 (PDT) From: Alexandru Gagniuc To: u-boot@lists.denx.de, patrick.delaunay@foss.st.com Cc: Alexandru Gagniuc , Tom Rini , Simon Glass Subject: [PATCH v5 2/5] spl: Introduce spl_board_prepare_for_optee() hook Date: Thu, 15 Jul 2021 14:19:24 -0500 Message-Id: <20210715191927.337676-3-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210715191927.337676-1-mr.nuke.me@gmail.com> References: <20210715191927.337676-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.103.2 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 eba77cace6..2919fa3e92 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -167,6 +167,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! */ @@ -747,6 +751,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 cee9a42ddb..04ab2b6d7d 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);