From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by mx.groups.io with SMTP id smtpd.web11.20018.1674578071514241107 for ; Tue, 24 Jan 2023 08:34:31 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cBVTQGGT; spf=pass (domain: kernel.org, ip: 145.40.73.55, 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 sin.source.kernel.org (Postfix) with ESMTPS id B4F58CE1B8C; Tue, 24 Jan 2023 16:34:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BBF3C4339C; Tue, 24 Jan 2023 16:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674578065; bh=41/ZpHecuvgWSmaYvC0bNfdUIRzQb6tdcSW0a3Fh8QI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cBVTQGGTIzNlrYFfnG3dO4YflWTpa7n7if/USETn7DX2tsgkaa5TlfdwisK3qHCCC wVWYH32nRZKwuocZnECKJcDEZ+MvssvP1MtOFGNK0OJke/XBYerEQUMY79jrCUQvr2 MbkOHUR/bwtQh/a1dd2Xl1aMafyQDfTSso8LnVAA8bPsEGiTo3dxNhPxiDS4iXnp+n yscM85qkteHcWDATu8bCv0VLLiqOkGOh4SaVizBHNlRjh27Ka1Ll1vaGaYPmh7EbY0 UsI8lOsXgs8G0K/nQVWSDyiUPXmiBMKpC33zDTbX5oObATExiGwywDf3slXFzNNAHu mJHgMdIMEBl0Q== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Michael Kubacki , Jiewen Yao , Oliver Steffen Subject: [PATCH v2 1/6] ArmVirtPkg/PrePi: Ensure timely execution of library constructors Date: Tue, 24 Jan 2023 17:34:12 +0100 Message-Id: <20230124163417.584727-2-ardb@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230124163417.584727-1-ardb@kernel.org> References: <20230124163417.584727-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- 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 ( //=0D InvalidateDataCacheRange ((VOID *)(UINTN)PcdGet64 (PcdFdBaseAddress), Pc= dGet32 (PcdFdSize));=0D =0D + // SEC phase needs to run library constructors by hand.=0D + ProcessLibraryConstructorList ();=0D +=0D // Initialize MMU and Memory HOBs (Resource Descriptor HOBs)=0D Status =3D MemoryPeim (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUef= iRegionSize));=0D ASSERT_EFI_ERROR (Status);=0D @@ -93,9 +96,6 @@ PrePiMain ( // Now, the HOB List has been initialized, we can register performance i= nformation=0D PERF_START (NULL, "PEI", NULL, StartTimeStamp);=0D =0D - // SEC phase needs to run library constructors by hand.=0D - ProcessLibraryConstructorList ();=0D -=0D // Assume the FV that contains the SEC (our code) also contains a compre= ssed FV.=0D Status =3D DecompressFirstFv ();=0D ASSERT_EFI_ERROR (Status);=0D --=20 2.39.0