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=-16.5 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,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 334FCC83028 for ; Thu, 2 Sep 2021 17:34:24 +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 239CC610E5 for ; Thu, 2 Sep 2021 17:34:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 239CC610E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com 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 BEBE582BD6; Thu, 2 Sep 2021 19:34:20 +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="jGCZ7fkR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3C9B480202; Thu, 2 Sep 2021 19:34:18 +0200 (CEST) Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) (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 1F10382C0C for ; Thu, 2 Sep 2021 19:34:13 +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-oo1-xc33.google.com with SMTP id j11-20020a4a92cb000000b002902ae8cb10so770691ooh.7 for ; Thu, 02 Sep 2021 10:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=oxSS+SR3+SRUB+2mh/zMto3cY6UwiZYiaotk2pKf9H4=; b=jGCZ7fkRklolzXYqYwRgtemEZalDKLMBBqjVoWcDriyiRxRZ7pF3wgvkr01jM+kjk/ hOkcdy12jy3beQX/reEpp13PrrzQBIZqvW5RkMo7fYfqlrAdLul9zC2dMIvWmKTu2kD6 dsZrlE2pyoSaeqArohDjte5MjCjOY8ZCrIyNOnBOYjKEQRrYKyjRpeft7SLQYQThQgwC kR9X/Il2GLGMA6oF6ca6vKaGMBVJGhPgQN/5EyzPxp/vF+WcvwfhYgdIYIuR4KaSoOxN C64Blh1hCO9/leNpmDPlJpf5hBDwQM/kWsJPTJ1D/p9f/gYrPfuamFMR52U/ndMFieqx UQ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=oxSS+SR3+SRUB+2mh/zMto3cY6UwiZYiaotk2pKf9H4=; b=YDnqdYr3IPUQj/uOJjrXftoaw0CDFhX9cZDJGqojNwQwtq9ZWMlP4ADa6PrxTsyf// s4i9DtuflPcRXMJ8+iDTQYh/2Myb6aqBo4slvmp8ta6X9vNsNKLHNOIHG5eOj3Z7FHiu ym4LHNGpeQF4HYdGEkOD2vBooByfH2GsieT0HDGE7CKofeiOTZVk12RWim9HsOYOKrff EyBI38syG07HoMYAFNzhYTa4FD5JaWawN376pEGO79YCNjFVu1+ErGjqFopRCWwANeWH Qbrtq4YOIG4REGHM15+J8H6mX91gFWNpiDZnzhoenXXW0okPh8S+ecAduHVrDFobAz3K 9N1Q== X-Gm-Message-State: AOAM533DWJHidtE7LGsRaZiggMc7vAyS6VUTetiQViIUz+08vT02Xvoz 0Gj7BwrLTmkX7gWcxQxUGnZKufC/xKQ= X-Google-Smtp-Source: ABdhPJytHCcU7MuJJtC/eM7OdjPGxeiZ/cAbeCbizs3wLj+QSLIiJeH4LiarB8XGqJfr0KhNpi3OFg== X-Received: by 2002:a4a:a8c9:: with SMTP id r9mr3506038oom.49.1630604051749; Thu, 02 Sep 2021 10:34:11 -0700 (PDT) Received: from nuclearis3.gtech (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id i5sm466455oie.11.2021.09.02.10.34.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Sep 2021 10:34:11 -0700 (PDT) Subject: Re: [PATCH 10/10] stm32mp1: spl: Copy optee nodes to target FDT for OP-TEE payloads From: "Alex G." To: Patrick DELAUNAY , u-boot@lists.denx.de Cc: marex@denx.de, Patrice CHOTARD , Etienne Carriere , U-Boot STM32 , Tom Rini References: <20210826214209.254461-1-mr.nuke.me@gmail.com> <20210826214209.254461-11-mr.nuke.me@gmail.com> <1afb6206-e2e9-30e7-33f5-695341e88841@foss.st.com> <0d056c73-60ad-2590-a355-1aff7a8af73d@gmail.com> Message-ID: <62cc5865-dd38-1cd0-de84-21874144a95b@gmail.com> Date: Thu, 2 Sep 2021 12:34:10 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <0d056c73-60ad-2590-a355-1aff7a8af73d@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US 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.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Patrick, On 9/1/21 10:10 AM, Alex G. wrote: > Hi Patrick, > > On 8/31/21 12:24 PM, Patrick DELAUNAY wrote: >> Hi, >> >> On 8/26/21 11:42 PM, Alexandru Gagniuc wrote: >>> OP-TEE does not take a devicetree for its own use. However, it does >>> pass the devicetree to the normal world OS. In most cases that will >>> be some other devicetree-bearing platform, such as linux. >>> >>> As in other cases where there's an OPTEE payload (e.g. BOOTM_OPTEE), >>> it is required to copy the optee nodes to he target's FDT. Do this as >>> part of spl_board_prepare_for_optee(). >>> >>> Signed-off-by: Alexandru Gagniuc >>> --- >>>   arch/arm/mach-stm32mp/spl.c | 2 ++ >>>   1 file changed, 2 insertions(+) >>> >>> diff --git a/arch/arm/mach-stm32mp/spl.c b/arch/arm/mach-stm32mp/spl.c >>> index d9fdc5926c..94fbb45cf9 100644 >>> --- a/arch/arm/mach-stm32mp/spl.c >>> +++ b/arch/arm/mach-stm32mp/spl.c >>> @@ -19,6 +19,7 @@ >>>   #include >>>   #include >>>   #include >>> +#include >>>   u32 spl_boot_device(void) >>>   { >>> @@ -182,6 +183,7 @@ void stm32_init_tzc_for_optee(void) >>>   void spl_board_prepare_for_optee(void *fdt) >>>   { >>>       stm32_fdt_setup_mac_addr(fdt); >>> +    optee_copy_fdt_nodes(fdt); >>>       stm32_init_tzc_for_optee(); >>>   } >> >> >> NAK the OP-TEE nodes are ADDED by the OP-TEE firmware in the unsecure >> device tree (when CFG_DT is activated) >> >> before to jump to the kernel (that remove the need to have DT >> allignement with U-Boot SPL device tree) >> >> => SPL should not copy the OP-TEE nodes in next stage DT >> >> reference in optee_os = core/arch/arm/kernel/boot.c: add_optee_dt_node() >> >> add_optee_dt_node() <= update_external_dt() <= paged_init_primary() >> >> It is the expected configuration for OP-TEE on STM32MP15 platform. > > I agree that if a component modifies the platform, it should be > responsible for updating the devicetree. Two issues though > > > 1. Consistency > > The STM32IMAGE boot path expects u-boot to add the optee nodes, while > the FIP path expects OP-TEE to add the nodes. Which one do we stick to? > > > 2. Memory access > > I don't understand is how OP-TEE would get past the TZC. > If we look at optee_os => plat-0stm32mp1/plat_tzc400: >     "Early boot stage is in charge of configuring memory regions" > The following memory has been set up by SPL (or TF-A for that matter): > >     Nonsec: c0000000->ddffffff >     Sec:    de000000->dfdfffff >     SHMEM:  dfe00000->dfffffff > > The external DTB will be in the nonsec region, which OP-TEE allegedly > can't access. So how would this get patched? Let's set aside the above for a bit. I tried the following OP-TEE configs: "CFG_DT=y CFG_DTB_MAX_SIZE=0x80000" Crashes with 'unhandled pageable abort' somewhere in core/arch/arm/plat-stm32mp1/ . I don't have much more time to spend debugging this. "CFG_DT=y CFG_DTB_MAX_SIZE=0x80000 PLATFORM_FLAVOR=157C_DK2" This adds about 800 ms to the boot time. (power on to kernel printing the first line). I have an allowance of 1 second to get to the kernel. I cannot just add 800ms to the boot time and hope nobody notices. However, calling optee_copy_fdt_nodes() adds no measureable amount of time. Unless OP-TEE can modify the devicetree without increasing boot time, I will not go down this path. This is an engineering decision driven by the product requirements. That being said, I request that you reconsider your NAK based on this new data. Alex