]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PrePeiCore: seed temporary stack before entering PEI core
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 20 Oct 2017 10:44:04 +0000 (11:44 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 9 Nov 2017 21:08:07 +0000 (21:08 +0000)
DEBUG builds of PEI code will print a diagnostic message regarding
the utilization of temporary RAM before switching to permanent RAM.
For example,

  Total temporary memory:    16352 bytes.
    temporary memory stack ever used:       4820 bytes.
    temporary memory heap used for HobList: 4720 bytes.

Tracking stack utilization like this requires the stack to be seeded
with a known magic value, and this needs to occur before entering C
code, given that it uses the stack. Currently, only Nt32Pkg appears
to implement this feature, but it is useful nonetheless, so let's
wire it up for PrePeiCore.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
ArmPlatformPkg/PrePeiCore/PrePeiCoreMPCore.inf
ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf

index aab5edab0c4224b3b424550c698136e8fb450ec5..0950fd0c0cdbc33dbd4952ef2f79344ab9cf9fdd 100644 (file)
@@ -84,4 +84,10 @@ _PrepareArguments:
 \r
 _SetupPrimaryCoreStack:\r
   mov   sp, x1\r
 \r
 _SetupPrimaryCoreStack:\r
   mov   sp, x1\r
+  MOV64 (x8, FixedPcdGet64 (PcdCPUCoresStackBase))\r
+  MOV64 (x9, FixedPcdGet32 (PcdInitValueInTempStack) |\\r
+             FixedPcdGet32 (PcdInitValueInTempStack) << 32)\r
+0:stp   x9, x9, [x8], #16\r
+  cmp   x8, x1\r
+  b.lt  0b\r
   b     _PrepareArguments\r
   b     _PrepareArguments\r
index 14344425ad4cd93f47f08982e78ddb65c6800272..a491af30a048c4041ec91e7e841d7efda7de072b 100644 (file)
@@ -65,6 +65,14 @@ _PrepareArguments:
 \r
 _SetupPrimaryCoreStack:\r
   mov   sp, r1\r
 \r
 _SetupPrimaryCoreStack:\r
   mov   sp, r1\r
+  MOV32 (r8, FixedPcdGet64 (PcdCPUCoresStackBase))\r
+  MOV32 (r9, FixedPcdGet32 (PcdInitValueInTempStack))\r
+  mov   r10, r9\r
+  mov   r11, r9\r
+  mov   r12, r9\r
+0:stm   r8!, {r9-r12}\r
+  cmp   r8, r1\r
+  blt   0b\r
   b     _PrepareArguments\r
 \r
 _NeverReturn:\r
   b     _PrepareArguments\r
 \r
 _NeverReturn:\r
index abea675828dff7e75a91a8a3d84461949570a0e7..dc1ad8144492a2463c7d7fb05513f1b178f46d62 100644 (file)
@@ -79,6 +79,14 @@ _PrepareArguments
 \r
 _SetupPrimaryCoreStack\r
   mov   sp, r1\r
 \r
 _SetupPrimaryCoreStack\r
   mov   sp, r1\r
+  mov32 r8, FixedPcdGet64 (PcdCPUCoresStackBase)\r
+  mov32 r9, FixedPcdGet32 (PcdInitValueInTempStack)\r
+  mov   r10, r9\r
+  mov   r11, r9\r
+  mov   r12, r9\r
+0:stm   r8!, {r9-r12}\r
+  cmp   r8, r1\r
+  blt   0b\r
   b     _PrepareArguments\r
 \r
 _NeverReturn\r
   b     _PrepareArguments\r
 \r
 _NeverReturn\r
index ecdbccb8d620018a5ffb95baa3b70ac03de13740..8e0456f8dc2a99ed67040512fe2e26bd11e104d7 100644 (file)
@@ -75,3 +75,5 @@
   gArmTokenSpaceGuid.PcdGicDistributorBase\r
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase\r
   gArmTokenSpaceGuid.PcdGicSgiIntId\r
   gArmTokenSpaceGuid.PcdGicDistributorBase\r
   gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase\r
   gArmTokenSpaceGuid.PcdGicSgiIntId\r
+\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack\r
index b5d4e389b2a4208eab3db23f6f93c8b6c8ebe878..ec83cec2d8796553beed55755f7263ca5eafc522 100644 (file)
@@ -69,3 +69,5 @@
   gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase\r
   gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize\r
   gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize\r
   gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase\r
   gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize\r
   gArmPlatformTokenSpaceGuid.PcdCPUCoreSecondaryStackSize\r
+\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInitValueInTempStack\r