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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C5A3C433F5 for ; Sun, 17 Oct 2021 11:01:06 +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 BE7B5610E8 for ; Sun, 17 Oct 2021 11:01:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BE7B5610E8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 20A6D831B2; Sun, 17 Oct 2021 13:01:03 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io 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=foundries.io header.i=@foundries.io header.b="K6F/+nbi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 786F3831B2; Sun, 17 Oct 2021 13:01:00 +0200 (CEST) Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) (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 1D0A583221 for ; Sun, 17 Oct 2021 13:00:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-pg1-x530.google.com with SMTP id c4so6038619pgv.11 for ; Sun, 17 Oct 2021 04:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m2LA7psMAhEMRtPYOm2jtCQ3wy3vFPdprE4PNL7fGyA=; b=K6F/+nbiPqXoEXKdXmmr+CrqRp1jfYQ7AARsfggumWuWpWcayQPceo9XA5ZcfpzEhZ jF3kTWZBJt2Lr7wVDeowjVw+SUIJtQxA0BZQX5Hd9yHtMn92/2qAGSlrq0ClPfCqLYUg qmcd64gJ94wF0vczd6QOBi/2HXthK95atpn3XD6WpjzZYMmaGq4YOQrrD9mOzuG1YL2s HnmDZQSssZ36emN2KEsfaVccp0ldPP1Mu/4vmOsupnz3oOJ6fYO0AdwqDv0iRgWbbUso fxU8zzYEEpCn2AZJBZoT132adLUofAJZcaLos3MnWQyKWMpVFDBu+H09Nma3SdjBZIsN 4wLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m2LA7psMAhEMRtPYOm2jtCQ3wy3vFPdprE4PNL7fGyA=; b=sM6EoWmBCQZdRYmS8znbrl8v/9++bxTO5lPj0cYw6tFTTW4e+pA0+g5oBGEPSl1jtB +CNgxRd5tXKtkD61EB929DSCcr07N3E8f3ky6TmSIrh5S8S9SqzfNoFQ7mGBYIg3ZY/5 uDlxHdj98bX24SXq/huvovWVc6hA0+/S8jsODmv6HXwrfJ0oVaXN7aSRqJayXnjdx1o7 Brv0gNawtZw1FFgtGkFLZVg3M8bx7Ujooq+CjW/9PvSPqm1vQl04I1l/RbDJcs/6qXCs X26MIytW4D7tjjKEvBmexUD1iqX68hi3yezgECrP1I5JU6r8GdUHfJPQaI/NR+6JfWA9 U6Eg== X-Gm-Message-State: AOAM533nwRWYCDiD4xfhEFjIZE5zmnOFQxp3ocuZ4s0LoiYIbsksZwnJ QeQyQlo3oEAO7OVLRy24qTrKQ5a4LHEL7qzzIW2c0A== X-Google-Smtp-Source: ABdhPJwSnQoy3OEyrYyk8s8Eq2oNOVnJ1VvrV4Amg/KnaFx3/xDZ39JTROG1lrp2BORv2YYRwf7DBbpHanVdo654MEg= X-Received: by 2002:a63:6d43:: with SMTP id i64mr9465627pgc.277.1634468454241; Sun, 17 Oct 2021 04:00:54 -0700 (PDT) MIME-Version: 1.0 References: <20210925140544.50001-1-oleksandr.suvorov@foundries.io> <20211014234443.GA1321219@bill-the-cat> In-Reply-To: <20211014234443.GA1321219@bill-the-cat> From: Oleksandr Suvorov Date: Sun, 17 Oct 2021 14:00:37 +0300 Message-ID: Subject: Re: [PATCH] arm: spl: flush and disable cache before jumping to OPTEE To: Tom Rini Cc: U-Boot-Denx , Ricardo Salveti , Alexandru Gagniuc , Bin Meng , =?UTF-8?B?TWFyZWsgQmVow7pu?= , Marek Vasut , Michael Walle , =?UTF-8?Q?Pali_Roh=C3=A1r?= , Patrick Delaunay , Simon Glass , Stefan Roese Content-Type: text/plain; charset="UTF-8" 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 Hello Tom, On Fri, Oct 15, 2021 at 2:44 AM Tom Rini wrote: > > On Sat, Sep 25, 2021 at 05:05:43PM +0300, Oleksandr Suvorov wrote: > > > From: Ricardo Salveti > > > > Make sure to flush, disable caches and interrupts before jumpint to > > OPTEE. This fixes the SDP->SPL->OPTEE boot flow on iMX6Q and most > > likely on some other ARM SoCs. > > > > Signed-off-by: Ricardo Salveti > > Co-developed-by: Oleksandr Suvorov > > Signed-off-by: Oleksandr Suvorov > > --- > > > > arch/arm/lib/spl.c | 11 +++++++++++ > > common/spl/spl.c | 11 +++++++++-- > > include/spl.h | 9 +++++++++ > > 3 files changed, 29 insertions(+), 2 deletions(-) > > > > diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c > > index 8e2bdf3536..16e3cd557a 100644 > > --- a/arch/arm/lib/spl.c > > +++ b/arch/arm/lib/spl.c > > @@ -77,3 +77,14 @@ void __noreturn jump_to_image_linux(struct spl_image_info *spl_image) > > } > > #endif /* CONFIG_ARM64 */ > > #endif > > + > > +#if CONFIG_IS_ENABLED(OPTEE) > > +void __noreturn jump_to_image_optee(struct spl_image_info *spl_image) > > +{ > > + /* flush and turn off caches before jumping to OPTEE */ > > + cleanup_before_linux(); > > + > > + spl_optee_entry(NULL, NULL, spl_image->fdt_addr, > > + (void *)spl_image->entry_point); > > +} > > +#endif > > diff --git a/common/spl/spl.c b/common/spl/spl.c > > index d55d3c2848..f3fab3c4d9 100644 > > --- a/common/spl/spl.c > > +++ b/common/spl/spl.c > > @@ -171,6 +171,14 @@ __weak void spl_board_prepare_for_optee(void *fdt) > > { > > } > > > > +#if CONFIG_IS_ENABLED(OPTEE) > > +__weak void __noreturn jump_to_image_optee(struct spl_image_info *spl_image) > > +{ > > + spl_optee_entry(NULL, NULL, spl_image->fdt_addr, > > + (void *)spl_image->entry_point); > > +} > > +#endif > > + > > __weak void spl_board_prepare_for_boot(void) > > { > > /* Nothing to do! */ > > @@ -777,8 +785,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) > > 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); > > + jump_to_image_optee(&spl_image); > > break; > > #endif > > #if CONFIG_IS_ENABLED(OPENSBI) > > diff --git a/include/spl.h b/include/spl.h > > index afbf39bef4..8e7173d294 100644 > > --- a/include/spl.h > > +++ b/include/spl.h > > @@ -460,6 +460,15 @@ int spl_board_boot_device(u32 boot_device); > > */ > > void __noreturn jump_to_image_linux(struct spl_image_info *spl_image); > > > > +/** > > + * jump_to_image_linux() - Jump to OP-TEE OS from SPL > > + * > > + * This jumps into OP-TEE OS using the information in @spl_image. > > + * > > + * @spl_image: Image description to set up > > + */ > > +void __noreturn jump_to_image_optee(struct spl_image_info *spl_image); > > + > > /** > > * spl_start_uboot() - Check if SPL should start the kernel or U-Boot > > * > > At current, this causes evb-rk3229 and evb-rk3288 to fail to build. A > trivial "test on OPTEE_IMAGE" instead leads to warnings about a > noreturnn function returning. Please rebase on current master and > retest your use cases, thanks! Thank you for the notes! I've fixed both issues in the 2nd version of the patchset. > > -- > Tom -- Best regards, Oleksandr Suvorov Software Engineer T: +380 63 8489656 E: oleksandr.suvorov@foundries.io W: www.foundries.io