[edk2-devel] [PATCH v2 1/6] ArmVirtPkg/PrePi: Ensure timely execution of library constructors

Ard Biesheuvel ardb at kernel.org
Tue Jan 24 16:34:12 UTC 2023


PrePi has a bare metal entry point, and so it is in charge of calling
the library constructors once the C runtime has been initialized
sufficiently.

However, we are now relying on a HOB to have been constructed by the
time the MMU code runs, and so the constructors should be run before
that.

Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
---
 ArmVirtPkg/PrePi/PrePi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
index c15dc305fced..3d943b2138d3 100755
--- a/ArmVirtPkg/PrePi/PrePi.c
+++ b/ArmVirtPkg/PrePi/PrePi.c
@@ -60,6 +60,9 @@ PrePiMain (
   //
   InvalidateDataCacheRange ((VOID *)(UINTN)PcdGet64 (PcdFdBaseAddress), PcdGet32 (PcdFdSize));
 
+  // SEC phase needs to run library constructors by hand.
+  ProcessLibraryConstructorList ();
+
   // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)
   Status = MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
   ASSERT_EFI_ERROR (Status);
@@ -93,9 +96,6 @@ PrePiMain (
   // Now, the HOB List has been initialized, we can register performance information
   PERF_START (NULL, "PEI", NULL, StartTimeStamp);
 
-  // SEC phase needs to run library constructors by hand.
-  ProcessLibraryConstructorList ();
-
   // Assume the FV that contains the SEC (our code) also contains a compressed FV.
   Status = DecompressFirstFv ();
   ASSERT_EFI_ERROR (Status);
-- 
2.39.0



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#98980): https://edk2.groups.io/g/devel/message/98980
Mute This Topic: https://groups.io/mt/96501368/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list