From: "Olivier Martin" Subject: Re: [PATCH v2 09/29] ArmPlatformPkg/PrePi: allow use of patchable PCDs Date: Wed, 28 Jan 2015 15:28:51 -0000 Message-ID: <33228.1929244802$1422459030@news.gmane.org> References: <1422299011-2409-1-git-send-email-ard.biesheuvel@linaro.org> <1422299011-2409-10-git-send-email-ard.biesheuvel@linaro.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1422299011-2409-10-git-send-email-ard.biesheuvel@linaro.org> Content-Language: en-gb List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: 'Ard Biesheuvel' , edk2-devel@lists.sourceforge.net, lersek@redhat.com, roy.franz@linaro.org, leif.lindholm@linaro.org, stefano.stabellini@eu.citrix.com, Ian.Campbell@citrix.com, anthony.perard@citrix.com, christoffer.dall@linaro.org, xen-devel@lists.xen.org, ilias.biris@linaro.org List-Id: xen-devel@lists.xenproject.org Reviewed-By: Olivier Martin > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: 26 January 2015 19:03 > To: edk2-devel@lists.sourceforge.net; lersek@redhat.com; Olivier > Martin; roy.franz@linaro.org; leif.lindholm@linaro.org; > stefano.stabellini@eu.citrix.com; Ian.Campbell@citrix.com; > anthony.perard@citrix.com; christoffer.dall@linaro.org; xen- > devel@lists.xen.org; ilias.biris@linaro.org > Cc: Ard Biesheuvel > Subject: [PATCH v2 09/29] ArmPlatformPkg/PrePi: allow use of patchable > PCDs > > Avoid using FixedPcdGetXX () to reference system memory and FD > base address PCDs so that the platform can choose to use patchable > PCDs instead. This allows a runtime self-relocating PrePi to poke > alternate values into them that can only be discovered at runtime. > > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Ard Biesheuvel > --- > ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S | 8 ++++---- > ArmPlatformPkg/PrePi/PrePi.c | 8 ++++---- > 2 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S > b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S > index fcea9496cbd5..3fa6bf1f0322 100644 > --- a/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S > +++ b/ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S > @@ -42,14 +42,14 @@ _SetSVCMode: > // at the top of the DRAM) > _SetupStackPosition: > // Compute Top of System Memory > - LoadConstantToReg (FixedPcdGet64 (PcdSystemMemoryBase), x1) > - LoadConstantToReg (FixedPcdGet64 (PcdSystemMemorySize), x2) > + ldr x1, PcdGet64 (PcdSystemMemoryBase) > + ldr x2, PcdGet64 (PcdSystemMemorySize) > sub x2, x2, #1 > add x1, x1, x2 // x1 = SystemMemoryTop = PcdSystemMemoryBase > + PcdSystemMemorySize > > // Calculate Top of the Firmware Device > - LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), x2) > - LoadConstantToReg (FixedPcdGet32(PcdFdSize), x3) > + ldr x2, PcdGet64 (PcdFdBaseAddress) > + ldr w3, PcdGet32 (PcdFdSize) > sub x3, x3, #1 > add x3, x3, x2 // x3 = FdTop = PcdFdBaseAddress + PcdFdSize > > diff --git a/ArmPlatformPkg/PrePi/PrePi.c > b/ArmPlatformPkg/PrePi/PrePi.c > index 9a5e067ef537..0e551c518d6b 100755 > --- a/ArmPlatformPkg/PrePi/PrePi.c > +++ b/ArmPlatformPkg/PrePi/PrePi.c > @@ -30,8 +30,8 @@ > #include "PrePi.h" > #include "LzmaDecompress.h" > > -#define IS_XIP() (((UINT32)FixedPcdGet32 (PcdFdBaseAddress) > > (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet32 > (PcdSystemMemorySize))) || \ > - ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 > (PcdFdSize)) < FixedPcdGet64 (PcdSystemMemoryBase))) > +#define IS_XIP() (((UINT32)PcdGet64 (PcdFdBaseAddress) > > (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64 > (PcdSystemMemorySize))) || \ > + ((PcdGet64 (PcdFdBaseAddress) + PcdGet32 > (PcdFdSize)) < PcdGet64 (PcdSystemMemoryBase))) > > // Not used when PrePi in run in XIP mode > UINTN mGlobalVariableBase = 0; > @@ -108,8 +108,8 @@ PrePiMain ( > > // If ensure the FD is either part of the System Memory or totally > outside of the System Memory (XIP) > ASSERT (IS_XIP() || > - ((FixedPcdGet32 (PcdFdBaseAddress) >= FixedPcdGet64 > (PcdSystemMemoryBase)) && > - ((UINT32)(FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 > (PcdFdSize)) <= (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) + > FixedPcdGet64 (PcdSystemMemorySize))))); > + ((PcdGet64 (PcdFdBaseAddress) >= PcdGet64 > (PcdSystemMemoryBase)) && > + ((UINT32)(PcdGet64 (PcdFdBaseAddress) + PcdGet32 > (PcdFdSize)) <= (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64 > (PcdSystemMemorySize))))); > > // Initialize the architecture specific bits > ArchInitialize (); > -- > 1.8.3.2 >