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.web10.40754.1674116526507237338 for ; Thu, 19 Jan 2023 00:22:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HJlHx8S0; 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 F3CD761209; Thu, 19 Jan 2023 08:22:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41093C433F1; Thu, 19 Jan 2023 08:22:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674116525; bh=41/ZpHecuvgWSmaYvC0bNfdUIRzQb6tdcSW0a3Fh8QI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HJlHx8S0ILglCPiZeSty4c0NdN3eV7EtAPCGeZCk52Ww1t/AyOd3THs90M7FnlX9l yk9BE3Bjc6+C764i2RVRLY+S+etRyyG7JWd7sM+MbA6CWSN2ZeTc/O1psTghzhHP+P 3qsIsfuzR2pmS30SQ6m7IEEC38Xgri6fLJDUcyJBbmz2FxJLAi+ZGqo4U7cD3gvVnL CR/dBVXvUr6GBbOpfYqj0y16LSFjfmpoKPe15Y8P0zPIwTlkcvoKUTfMU5dFyCrlgg Zum/1xLN4GzHub4f2EL/fGOpy7MhMFAt8hXxqG4upM3JOVzGJFkHMO3v7RUQxR9t9j Zr8goylS+v2jQ== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Gerd Hoffmann , Michael Kubacki , Oliver Steffen Subject: [PATCH 1/3] ArmVirtPkg/PrePi: Ensure timely execution of library constructors Date: Thu, 19 Jan 2023 09:21:51 +0100 Message-Id: <20230119082153.1520196-2-ardb@kernel.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119082153.1520196-1-ardb@kernel.org> References: <20230119082153.1520196-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