From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web08.8841.1651567396193591109 for ; Tue, 03 May 2022 01:43:16 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FVly8Kk0; spf=pass (domain: kernel.org, ip: 145.40.68.75, 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 ams.source.kernel.org (Postfix) with ESMTPS id F1702B81A56 for ; Tue, 3 May 2022 08:43:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCC10C385B0 for ; Tue, 3 May 2022 08:43:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1651567392; bh=BE0z851nt93nSyClJPomGoJq+W1A7ec4BFVi2MczABE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FVly8Kk0sQAbhuFLVIUpdl5EXkV9JcJc0n9wc+gIRbZTyUC2T1yT0BXpaqDQLYkvC ulkBSR3NNj3jmE3fW6+Mj8LH4KwOFjs48s8ilX2NedkmxtNpu9Krns+O5fTyTjeQAi +Vzcj+mzKsmGuANb1CvY/fDJC3R9VQkmPfC/sOZd4pMaM4DUpQ52z9LPcz6QWFBcOf XHQzw62ZMl9ebt0w44hMcHR8H2JGEC1HS1dLgMDxJZRnn9IEwCZnygQ3QnMTh0v87S abqKqvAr4schtOnozqCaAxwpSP/XR3BFtyqm6H1MKarbl2U1NPE0OTxLNsuDztcbcZ YERQloBfI796Q== Received: by mail-oi1-f174.google.com with SMTP id m11so17502449oib.11 for ; Tue, 03 May 2022 01:43:12 -0700 (PDT) X-Gm-Message-State: AOAM530BfaKNxfRYCvX0bAcsOWYC6yNxMavxWpoBnNyz7hW1zoh/oQe8 ITxE5KYX1Qe5tgniSo2jo57Er6/vvtcbntdyFJg= X-Google-Smtp-Source: ABdhPJzDn5vRH6o/vl0eJzMKuVdeLjA2ak0VPUr2xu2K1yl5SJQOrAUrqIhhWihh/uD1FcZAy5y7mIuWCG9zUB6fzwk= X-Received: by 2002:a05:6808:1141:b0:325:cd92:ef8d with SMTP id u1-20020a056808114100b00325cd92ef8dmr1381463oiu.228.1651567391876; Tue, 03 May 2022 01:43:11 -0700 (PDT) MIME-Version: 1.0 References: <20220308115525.30481-1-rohit.mathew@arm.com> In-Reply-To: <20220308115525.30481-1-rohit.mathew@arm.com> From: "Ard Biesheuvel" Date: Tue, 3 May 2022 10:43:00 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [edk2-platforms][PATCH V1 1/1] ArmPlatformPkg/PrePeiCore: Explicitly invoke constructor for SEC phase To: Rohit Mathew , Rebecca Cran Cc: edk2-devel-groups-io , Ard Biesheuvel , Sami Mujawar Content-Type: text/plain; charset="UTF-8" (+ Rebecca) On Tue, 8 Mar 2022 at 12:55, Rohit Mathew wrote: > > PrePeiCore's CEntry function calls DebugLib library's print API before > the library is initialized. So, invoke the constructor in the SEC phase > to call into initialization functions associated with libraries linked > with this particular module. This change is essential to initialize > uart for SEC. > > Signed-off-by: Rohit Mathew > --- > ArmPlatformPkg/PrePeiCore/PrePeiCore.h | 11 ++++++++++- > ArmPlatformPkg/PrePeiCore/PrePeiCore.c | 9 +++++++-- > 2 files changed, 17 insertions(+), 3 deletions(-) > > Link to github branch with the patches in this series - > https://github.com/rohit-arm/edk2/tree/sec_constructor_issue > > diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.h b/ArmPlatformPkg/PrePeiCore/PrePeiCore.h > index 0345dd7bdd2a..d2491aa586ee 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 > + ); > + Why do we need this? Can't we just include PiPei.h or something like that? > #endif > diff --git a/ArmPlatformPkg/PrePeiCore/PrePeiCore.c b/ArmPlatformPkg/PrePeiCore/PrePeiCore.c > index 6dd9bcdea24f..b5f7d2f05b1e 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,7 +86,12 @@ CEntryPoint ( > ArmEnableVFP (); > } > > - // Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on. > + // In the Sec phase, explicitly invoke the library constructors. This helps > + // the DebugPrint library to be initialized before it is used by subsequent > + // code executed in the sec phase. Please drop the reference to DebugLib - calling library constructors could be needed for any library dependency. > + ProcessLibraryConstructorList(); > + > + //Note: The MMU will be enabled by MemoryPeim. Only the primary core will have the MMU on. Please leave this comment as before. > > // If not primary Jump to Secondary Main > if (ArmPlatformIsPrimaryCore (MpId)) { > -- > 2.25.1 >