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.3 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 6509DC432BE for ; Wed, 1 Sep 2021 15:10:22 +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 55AEA6108B for ; Wed, 1 Sep 2021 15:10:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 55AEA6108B 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 BD464834DB; Wed, 1 Sep 2021 17:10:18 +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="GXX8FwhG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57BDD834DA; Wed, 1 Sep 2021 17:10:16 +0200 (CEST) Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) (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 67EAE834F6 for ; Wed, 1 Sep 2021 17:10:12 +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-x330.google.com with SMTP id q11-20020a9d4b0b000000b0051acbdb2869so58794otf.2 for ; Wed, 01 Sep 2021 08:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=pmPVZvas+4IPPlgSoibLVmYjzvn+bhWKk5elvEBrgRc=; b=GXX8FwhGFLry5G7My7+hrf0fzxVOu6tXhojFMRoh6HZgNn6KahEgz6SBRnTN+WXU/4 /6nVgr271Es54chbrwwc0avSUFbpmIy4hKWp4ekUxEYjHX+vVFRSMMbEUm+3/7kvUrGQ l6qP1VNKA3xQ+L53dYoTcdoC8tfocggXrb0M0JEJ87uo6RDndhb5BVVDHoyVixf9Kvry sBY3HMsaCu6QJVM2fF0QiXmeK3i5GqM/wVbKOpTdvNdrraH9r/MOz8K07mjyryP4sYRc cn4ieL8tjyFxiJx5EqQDPcYbF820XaAgU9gnFnatjoSzqKkOIYqKcKWOwtA7m+WhzFhG NjYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pmPVZvas+4IPPlgSoibLVmYjzvn+bhWKk5elvEBrgRc=; b=qcyscFvxpraJVtUj8VJrEAo2tzSeemlfHH4OtwurjQREDVzITu44VnZNoo7nlM4XeW QmxvNhs190osOgbh0nMknoQ+B/RdeMdC/Tw4OMSj+2M46pL+62gnLwok9GJ3Cv4lbSmZ nnZRPOTfdLAOEsh7wyXaaA0x7NzdPdEbfBeizN0xKt3JW63VLp3VZIT48l6Md4YKCl4O FTT6f4ElHrdrlL7S3P9FwWZRFk2tWpSRmKkGObzprInpzjAoY0R1X9g3rHUOimBg0o99 RbOFXiGlbHc+g4HVdxro0I6BkOfSkf8XYJVj/xR9sU8jHOiENKNEFtUJGx1sM46MxIUY iLXw== X-Gm-Message-State: AOAM533T43TpY9Ta2Ec2KrrJ3BLAxwMePSTWzvm3jWjlL/Sh/tJOKXeo nCsBfMdwN++vm5ROVxnsLgHIrU6dnM8= X-Google-Smtp-Source: ABdhPJx4wLcQ3UKPP3rnYLEQZFWSWg4V0TK+BWf53awIOn1Z+/dLo7XfhwqPE7944bEoS4VUYqXcmQ== X-Received: by 2002:a05:6830:4090:: with SMTP id x16mr28869988ott.71.1630509010477; Wed, 01 Sep 2021 08:10:10 -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 w9sm4700723oti.35.2021.09.01.08.10.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Sep 2021 08:10:09 -0700 (PDT) Subject: Re: [PATCH 10/10] stm32mp1: spl: Copy optee nodes to target FDT for OP-TEE payloads To: Patrick DELAUNAY , u-boot@lists.denx.de Cc: marex@denx.de, Patrice CHOTARD , Etienne Carriere , U-Boot STM32 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> From: "Alex G." Message-ID: <0d056c73-60ad-2590-a355-1aff7a8af73d@gmail.com> Date: Wed, 1 Sep 2021 10:10:08 -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: <1afb6206-e2e9-30e7-33f5-695341e88841@foss.st.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 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? Alex