From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.6814.1657117233763122297 for ; Wed, 06 Jul 2022 07:20:33 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: thomas.abraham@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B60D3106F; Wed, 6 Jul 2022 07:20:33 -0700 (PDT) Received: from [10.57.11.190] (unknown [10.57.11.190]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 627F43F792; Wed, 6 Jul 2022 07:20:32 -0700 (PDT) Message-ID: <94dcbbe0-dd1f-6e92-fa44-ff5895d8e75c@arm.com> Date: Wed, 6 Jul 2022 15:20:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [edk2][PATCH V3 1/1] ArmPlatformPkg/PrePeiCore: Explicitly invoke constructor for SEC phase To: Rohit Mathew , devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Rebecca Cran , Pierre Gondois References: <20220706134234.17847-1-rohit.mathew@arm.com> From: "Thomas Abraham" In-Reply-To: <20220706134234.17847-1-rohit.mathew@arm.com> Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 06/07/2022 14:42, Rohit Mathew wrote: > Invoke the constructor in the SEC phase to call into initialization > functions associated with libraries linked with this particular module. > For instance, PrePeiCore's CEntryPoint function calls DebugLib library's > print API before the library is initialized. This change is essential > to initialize uart for SEC phase. > > Signed-off-by: Rohit Mathew > --- > ArmPlatformPkg/PrePeiCore/PrePeiCore.h | 11 ++++++++++- > ArmPlatformPkg/PrePeiCore/PrePeiCore.c | 6 +++++- > 2 files changed, 15 insertions(+), 2 deletions(-) > > Changes since V1: > - Rebased on top of latest master branch. > - Addressed comments from Ard. > > Changes since V2: > - Rebased on top of latest master branch. > > Link to github branch for the patch - > https://github.com/rohit-arm/edk2/tree/sec_constructor_issue > > diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.h b/ArmPlatformPkg/PrePeiCore/PrePeiCore.h > index 0345dd7bdd2a..b752c4b9e617 100644 > --- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.h > +++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.h > @@ -1,7 +1,7 @@ > /** @file > Main file supporting the transition to PEI Core in Normal World for Versatile Express > > - Copyright (c) 2011, ARM Limited. All rights reserved. > + Copyright (c) 2011 - 2022, ARM Limited. All rights reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -73,4 +73,13 @@ PeiCommonExceptionEntry ( > IN UINTN LR > ); > > +/* > + * Constructor for SEC phase > + */ > +VOID > +EFIAPI > +ProcessLibraryConstructorList ( > + VOID > + ); > + > #endif > diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c > index 6dd9bcdea24f..9654866f0c13 100644 > --- a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c > +++ b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c > @@ -1,7 +1,7 @@ > /** @file > Main file supporting the transition to PEI Core in Normal World for Versatile Express > > - Copyright (c) 2011-2014, ARM Limited. All rights reserved. > + Copyright (c) 2011 - 2022, ARM Limited. All rights reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -86,6 +86,10 @@ CEntryPoint ( > ArmEnableVFP (); > } > > + // Explicitly invoke the library constructor to resolve any library > + // dependency. > + ProcessLibraryConstructorList(); > + > // Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on. > > // If not primary Jump to Secondary Main Reviewed-by: Thomas Abraham Tested-by: Thomas Abraham Thanks.