public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Gao, Liming" <liming.gao@intel.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Laszlo Ersek <lersek@redhat.com>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	Leif Lindholm <leif.lindholm@linaro.org>
Subject: Re: [PATCH] ArmPlatformPkg/PrePeiCore: seed temporary stack before entering PEI core
Date: Fri, 20 Oct 2017 16:37:39 +0000	[thread overview]
Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E16EABD@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <CAKv+Gu9GCSDA-soj7A6oxgXR0Bdg+CLwh=33HoQPFEcmJzG0NQ@mail.gmail.com>

Ard:
  This case is to share the same value between PeiCore and SecCore. I also think it will be better to define one fixed PCD in MdeModulePkg.dec for this value. Could you submit bugzillar to catch this issue first?

Thanks
Liming
> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ard Biesheuvel
> Sent: Saturday, October 21, 2017 12:10 AM
> To: Laszlo Ersek <lersek@redhat.com>
> Cc: edk2-devel@lists.01.org; Leif Lindholm <leif.lindholm@linaro.org>
> Subject: Re: [edk2] [PATCH] ArmPlatformPkg/PrePeiCore: seed temporary stack before entering PEI core
> 
> On 20 October 2017 at 16:43, Laszlo Ersek <lersek@redhat.com> wrote:
> > On 10/20/17 15:00, Leif Lindholm wrote:
> >> On Fri, Oct 20, 2017 at 12:23:25PM +0100, Ard Biesheuvel wrote:
> >>> DEBUG builds of PEI code will print a diagnostic message regarding
> >>> the utilization of temporary RAM before switching to permanent RAM.
> >>> For example,
> >>>
> >>>   Total temporary memory:    16352 bytes.
> >>>     temporary memory stack ever used:       4820 bytes.
> >>>     temporary memory heap used for HobList: 4720 bytes.
> >>>
> >>> Tracking stack utilization like this requires the stack to be seeded
> >>> with a known magic value, and this needs to occur before entering C
> >>> code, given that it uses the stack. Currently, only Nt32Pkg appears
> >>> to implement this feature, but it is useful nonetheless, so let's
> >>> wire it up for PrePeiCore.
> >>>
> >>> Contributed-under: TianoCore Contribution Agreement 1.1
> >>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> >>> ---
> >>>  ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S |  7 +++++++
> >>>  ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S     | 10 ++++++++++
> >>>  ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm   | 10 ++++++++++
> >>>  3 files changed, 27 insertions(+)
> >>>
> >>> diff --git a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
> b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
> >>> index aab5edab0c42..7a33e2754869 100644
> >>> --- a/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
> >>> +++ b/ArmPlatformPkg/PrePeiCore/AArch64/PrePeiCoreEntryPoint.S
> >>> @@ -13,6 +13,8 @@
> >>>
> >>>  #include <AsmMacroIoLibV8.h>
> >>>
> >>> +#define INIT_CAR_VALUE      0x5AA55AA55AA55AA5
> >>> +
> >>>  ASM_FUNC(_ModuleEntryPoint)
> >>>    // Do early platform specific actions
> >>>    bl    ASM_PFX(ArmPlatformPeiBootAction)
> >>> @@ -84,4 +86,9 @@ _PrepareArguments:
> >>>
> >>>  _SetupPrimaryCoreStack:
> >>>    mov   sp, x1
> >>> +  MOV64 (x8, FixedPcdGet64(PcdCPUCoresStackBase))
> >>> +  MOV64 (x9, INIT_CAR_VALUE)
> >>> +0:stp   x9, x9, [x8], #16
> >>> +  cmp   x8, x1
> >>> +  b.lt  0b
> >>>    b     _PrepareArguments
> >>> diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
> >>> index 14344425ad4c..7342e49bea59 100644
> >>> --- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
> >>> +++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
> >>> @@ -13,6 +13,8 @@
> >>>
> >>>  #include <AsmMacroIoLib.h>
> >>>
> >>> +#define INIT_CAR_VALUE      0x5AA55AA5
> >>> +
> >>
> >> Worth moving to a common header somewhere?
> >>
> >> Also defined/used in MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c.
> >
> > Furthermore, open-coded in:
> >
> > EmulatorPkg/Unix/Host/Host.c:    *StackPointer = 0x5AA55AA5;
> > Nt32Pkg/Sec/SecMain.c:    *StackPointer = 0x5AA55AA5;
> >
> > Honestly I think it should be a Fixed-At-Build PCD, in MdeModulePkg.dec,
> > similarly to
> >
> >   gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue
> >
> > in MdePkg.dec.
> >
> 
> Yes. And you both know how the MdeModulePkg maintainers are going to
> respond if I propose adding another PCD.
> 
> > I'm unhappy that we have to annoy Ard with a request to "upstream" this
> > constant to MdeModulePkg in some form, but we'll need it yet again in
> > OVMF...
> >
> 
> 
> >>
> >> That file has an explicit comment saying "temporary memory is filled
> >> with this initial value during SEC phase". Should this end have a
> >> corresponding comment saying "checked for during PEI phase"?
> >
> > Thanks
> > Laszlo
> >
> >>
> >> /
> >>     Leif
> >>
> >>>  ASM_FUNC(_ModuleEntryPoint)
> >>>    // Do early platform specific actions
> >>>    bl    ASM_PFX(ArmPlatformPeiBootAction)
> >>> @@ -65,6 +67,14 @@ _PrepareArguments:
> >>>
> >>>  _SetupPrimaryCoreStack:
> >>>    mov   sp, r1
> >>> +  MOV32 (r8, FixedPcdGet64(PcdCPUCoresStackBase))
> >>> +  MOV32 (r9, INIT_CAR_VALUE)
> >>> +  mov   r10, r9
> >>> +  mov   r11, r9
> >>> +  mov   r12, r9
> >>> +0:stm   r8!, {r9-r12}
> >>> +  cmp   r8, r1
> >>> +  blt   0b
> >>>    b     _PrepareArguments
> >>>
> >>>  _NeverReturn:
> >>> diff --git a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
> b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
> >>> index abea675828df..7455de8aa66e 100644
> >>> --- a/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
> >>> +++ b/ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
> >>> @@ -13,6 +13,8 @@
> >>>
> >>>  #include <AutoGen.h>
> >>>
> >>> +#define INIT_CAR_VALUE      0x5AA55AA5
> >>> +
> >>>    INCLUDE AsmMacroIoLib.inc
> >>>
> >>>    IMPORT  CEntryPoint
> >>> @@ -79,6 +81,14 @@ _PrepareArguments
> >>>
> >>>  _SetupPrimaryCoreStack
> >>>    mov   sp, r1
> >>> +  mov32 r8, FixedPcdGet64(PcdCPUCoresStackBase)
> >>> +  mov32 r9, INIT_CAR_VALUE
> >>> +  mov   r10, r9
> >>> +  mov   r11, r9
> >>> +  mov   r12, r9
> >>> +0:stm   r8!, {r9-r12}
> >>> +  cmp   r8, r1
> >>> +  blt   0b
> >>>    b     _PrepareArguments
> >>>
> >>>  _NeverReturn
> >>> --
> >>> 2.11.0
> >>>
> >
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


  parent reply	other threads:[~2017-10-20 16:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-20 11:23 [PATCH] ArmPlatformPkg/PrePeiCore: seed temporary stack before entering PEI core Ard Biesheuvel
2017-10-20 13:00 ` Leif Lindholm
2017-10-20 15:43   ` Laszlo Ersek
2017-10-20 16:10     ` Ard Biesheuvel
2017-10-20 16:30       ` Laszlo Ersek
2017-10-20 16:37       ` Gao, Liming [this message]
2017-10-20 16:39         ` Ard Biesheuvel
2017-10-20 16:51           ` Laszlo Ersek
2017-10-20 16:52             ` Ard Biesheuvel
2017-10-20 17:18               ` Laszlo Ersek
2017-10-23 14:18                 ` Gao, Liming
2017-10-23 14:39                   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A89E2EF3DFEDB4C8BFDE51014F606A14E16EABD@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox