From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web09.8792.1651568791161459135 for ; Tue, 03 May 2022 02:06:31 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DC8ZqKf4; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6B1AA6134E for ; Tue, 3 May 2022 09:06:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE039C385B2 for ; Tue, 3 May 2022 09:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651568789; bh=3CdwEk5JBhhzC2UHhwLP1jOJsmvejViMd7+nzatz6mo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=DC8ZqKf4v3Bo1b9pIzDlat1psKsYaLOhs2Nd42QEyS+52Dg90IKMw9Zfq0AC02Akb ZOl7tyZ+6dqofC/BkssaIUa6tk8z1y8ZWal2xkgn1XRx8dIVXVe17jDYbu0VO6S5hx t/EWiJkKmC1rWB7TavRq0EHZ0aXDlv0g0R3mtocIjfF1YjlSrTLAMdmyb37lHS6eyo AaNGr5rDkBFx7hDRrJ/M+PSCXGREoqWZ1cr7A9UbcH9c3TFFujNiDhVHyaX3/xrvUa IjMgb8eFBgMi0AQyRsrMew9HdbOEUT/cF1QKn/af+yPrLZktVu5sO2/+uYDU6+KBji FyZpbx/tQyOYg== Received: by mail-oa1-f49.google.com with SMTP id 586e51a60fabf-e5e433d66dso16603377fac.5 for ; Tue, 03 May 2022 02:06:29 -0700 (PDT) X-Gm-Message-State: AOAM530dVXZXO22ZHSOzg0rpY/IrF3aRkRTcgZ4JbxlV3flBXfJitmgU ODdoHS0MRxa2WYkSod8MeT8o7f9Tlj24rUlfHfk= X-Google-Smtp-Source: ABdhPJyVwbL3YOVlcnhQ/Y3GLHMqFyhTiGhUa4zCfLFOvFocWSfQ0ElIgeZwgogrrOXX06q69+DfR4JfGS4uR1qB/9o= X-Received: by 2002:a05:6870:eaa5:b0:da:b3f:2b45 with SMTP id s37-20020a056870eaa500b000da0b3f2b45mr1374022oap.228.1651568789040; Tue, 03 May 2022 02:06:29 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "Ard Biesheuvel" Date: Tue, 3 May 2022 11:06:17 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-devel] ArmPlatformPkg: understanding PrePi vs PrePeiCore To: edk2-devel-groups-io , Rebecca Cran , Andrew Fish Cc: Ard Biesheuvel , Leif Lindholm Content-Type: text/plain; charset="UTF-8" On Tue, 12 Apr 2022 at 18:01, Rebecca Cran wrote: > > I've been working on cleaning up some of the code in ArmPlatformPkg and > have been trying to understand the differences between PrePi and PrePeiCore. > It looks like PrePi was added to save space over PrePeiCore, but I'm > wondering if we still need it? Andrew should be able to answer this, as well as Eugene, I imagine. The reason is that PEI is designed to execute in place from NOR flash, and so it assumes that global variables are read-only, except for some 'temporary RAM' located in the cache running in no-evict mode, which includes the stack as well. This permits PEI to configure and initialize the DRAM controller and DRAM. When EDK2 was ported to the BeagleBoard, it relied on a previous boot stage that copied the image into DRAM and executed it from there. This means PEI is unneeded, and SEC can launch the DXE core directly, provided that it creates the minimal PEI context that the DXE core relies on to be able to initialize itself. This is why MemoryPeim, CpuPeim etc are all factored into libraries on ARM, this permits the individual PEIMs to pull in the functionality, but permits a single PrePi SEC stage to pull in those same libraries and have the same functionality. Unfortunately, for things like Capsule Update and measured boot, PrePi is unsuitable unless we factor out those things into libraries as well. Since PEI can happily execute from DRAM as well as NOR flash, this means that for more complete implementations, PrePeiCore is a better choice. Note that SynQuacer also uses PrePeiCore, but actually does run it in place from NOR flash, just like ArmVirtQemu does. Platforms such as Seattle use PrePeiCore but rely on TF-A to copy the entire FD image into DRAM first. > I'm guessing most of the platforms below > could use the latter, possibly with the exception of BeagleBoard and > VExpress? > > > Platforms using PrePi/Pei{Uni,MP}Core: > > RPi3 > RPi4 > HiKey > BeagleBoard > VExpress-FVP > ArmJuno > HiKey960 > DurianPkg > VExpress-CTA15-A7 > > -- > Rebecca Cran > > > > > >