From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=jordan.l.justen@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8512A211CFFD0 for ; Sat, 2 Mar 2019 13:45:18 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2019 13:45:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,433,1544515200"; d="scan'208";a="120464212" Received: from dwfeck-mobl1.amr.corp.intel.com (HELO localhost) ([10.254.107.10]) by orsmga006.jf.intel.com with ESMTP; 02 Mar 2019 13:45:17 -0800 MIME-Version: 1.0 In-Reply-To: <20190302121111.70992-1-ray.ni@intel.com> References: <20190302121111.70992-1-ray.ni@intel.com> To: Ray Ni , edk2-devel@lists.01.org From: Jordan Justen Message-ID: <155156311737.17885.4362726503400495940@jljusten-skl> User-Agent: alot/0.8 Date: Sat, 02 Mar 2019 13:45:17 -0800 Subject: Re: [PATCH] EmulatorPkg/Sec: Don't install TemporaryRamSupport PPI X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Mar 2019 21:45:19 -0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable On 2019-03-02 04:11:11, Ray Ni wrote: > TemporaryRamSupport PPI is called by PeiCore to migrate temporary > memory from permanent memory. But the implementation assumes > ebp/rbp contains the original esp/rsp value when migrating which > is not always true the compiler optimization is turned on. > A real boot failure is seen using GCC5. > In fact, below commit in year 2013 enhanced PeiCore to migrate > the memory without calling TemporaryRamSupport PPI. > SHA-1: 0f9ebb321638e9142ab3bdcc19000c49bb83b9ba > * Add support for PI1.2.1 TempRam Done PPI. >=20 > So this patch removes TemporaryRamSupport PPI implementation from > EmulatorPkg/Sec module to fix the boot failure when using GCC5. I don't think we should just hide the known bug with the TemporaryRamSupport PPI implementation in the PEI Core. I would agree that we should make this change after addressing that. -Jordan > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ray Ni > Cc: Jordan Justen > Cc: Andrew Fish > --- > EmulatorPkg/Sec/Ia32/SwitchRam.S | 95 ------------------------------ > EmulatorPkg/Sec/Ia32/SwitchRam.asm | 94 ----------------------------- > EmulatorPkg/Sec/Ia32/TempRam.c | 65 -------------------- > EmulatorPkg/Sec/Sec.c | 61 +------------------ > EmulatorPkg/Sec/Sec.h | 14 +---- > EmulatorPkg/Sec/Sec.inf | 15 +---- > EmulatorPkg/Sec/X64/SwitchRam.S | 72 ---------------------- > EmulatorPkg/Sec/X64/SwitchRam.asm | 76 ------------------------ > 8 files changed, 5 insertions(+), 487 deletions(-) > delete mode 100644 EmulatorPkg/Sec/Ia32/SwitchRam.S > delete mode 100644 EmulatorPkg/Sec/Ia32/SwitchRam.asm > delete mode 100644 EmulatorPkg/Sec/Ia32/TempRam.c > delete mode 100644 EmulatorPkg/Sec/X64/SwitchRam.S > delete mode 100644 EmulatorPkg/Sec/X64/SwitchRam.asm >=20 > diff --git a/EmulatorPkg/Sec/Ia32/SwitchRam.S b/EmulatorPkg/Sec/Ia32/Swit= chRam.S > deleted file mode 100644 > index 39304daef1..0000000000 > --- a/EmulatorPkg/Sec/Ia32/SwitchRam.S > +++ /dev/null > @@ -1,95 +0,0 @@ > -#-----------------------------------------------------------------------= ------- > -# > -# Copyright (c) 2007, Intel Corporation. All rights reserved.
> -# This program and the accompanying materials > -# are licensed and made available under the terms and conditions of the = BSD License > -# which accompanies this distribution. The full text of the license may= be found at > -# http:#opensource.org/licenses/bsd-license.php > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR I= MPLIED. > -# > -# Module Name: > -# > -# Stack.asm > -# > -# Abstract: > -# > -# Switch the stack from temporary memory to permenent memory. > -# > -#-----------------------------------------------------------------------= ------- > - > - .text > - > - > -//----------------------------------------------------------------------= -------- > -// VOID > -// EFIAPI > -// SecSwitchStack ( > -// UINT32 TemporaryMemoryBase, > -// UINT32 PermenentMemoryBase > -// )// > -//----------------------------------------------------------------------= -------- > -ASM_GLOBAL ASM_PFX(SecSwitchStack) > -ASM_PFX(SecSwitchStack): > -# > -# Save three register: eax, ebx, ecx > -# > - push %eax > - push %ebx > - push %ecx > - push %edx > - > -# > -# !!CAUTION!! this function address's is pushed into stack after > -# migration of whole temporary memory, so need save it to permenent > -# memory at first! > -# > - > - movl 20(%esp), %ebx # Save the first parameter > - movl 24(%esp), %ecx # Save the second parameter > - > -# > -# Save this function's return address into permenent memory at first. > -# Then, Fixup the esp point to permenent memory > -# > - > - movl %esp, %eax > - subl %ebx, %eax > - addl %ecx, %eax > - movl (%esp), %edx # copy pushed register's value to= permenent memory > - movl %edx, (%eax) > - movl 4(%esp), %edx > - movl %edx, 4(%eax) > - movl 8(%esp), %edx > - movl %edx, 8(%eax) > - movl 12(%esp), %edx > - movl %edx, 12(%eax) > - movl 16(%esp), %edx > - movl %edx, 16(%eax) > - movl %eax, %esp # From now, esp is pointed to per= menent memory > - > -# > -# Fixup the ebp point to permenent memory > -# > -#ifndef __APPLE__ > - movl %ebp, %eax > - subl %ebx, %eax > - addl %ecx, %eax > - movl %eax, %ebp # From now, ebp is pointed to per= menent memory > - > -# > -# Fixup callee's ebp point for PeiDispatch > -# > - movl (%ebp), %eax > - subl %ebx, %eax > - addl %ecx, %eax > - movl %eax, (%ebp) # From now, Temporary's PPI calle= r's stack is in permenent memory > -#endif > - > - pop %edx > - pop %ecx > - pop %ebx > - pop %eax > - ret > - > diff --git a/EmulatorPkg/Sec/Ia32/SwitchRam.asm b/EmulatorPkg/Sec/Ia32/Sw= itchRam.asm > deleted file mode 100644 > index 731ee0ffdb..0000000000 > --- a/EmulatorPkg/Sec/Ia32/SwitchRam.asm > +++ /dev/null > @@ -1,94 +0,0 @@ > -;-----------------------------------------------------------------------= ------- > -; > -; Copyright (c) 2007 - 2012, Intel Corporation. All rights reserved.
> -; This program and the accompanying materials > -; are licensed and made available under the terms and conditions of the = BSD License > -; which accompanies this distribution. The full text of the license may= be found at > -; http://opensource.org/licenses/bsd-license.php > -; > -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR I= MPLIED. > -; > -; Module Name: > -; > -; Stack.asm > -; > -; Abstract: > -; > -; Switch the stack from temporary memory to permenent memory. > -; > -;-----------------------------------------------------------------------= ------- > - > - .586p > - .model flat,C > - .code > - > -;-----------------------------------------------------------------------= ------- > -; VOID > -; EFIAPI > -; SecSwitchStack ( > -; UINT32 TemporaryMemoryBase, > -; UINT32 PermenentMemoryBase > -; ); > -;-----------------------------------------------------------------------= ------- > -SecSwitchStack PROC > - ; > - ; Save three register: eax, ebx, ecx > - ; > - push eax > - push ebx > - push ecx > - push edx > - > - ; > - ; !!CAUTION!! this function address's is pushed into stack after > - ; migration of whole temporary memory, so need save it to permenent > - ; memory at first! > - ; > - > - mov ebx, [esp + 20] ; Save the first parameter > - mov ecx, [esp + 24] ; Save the second parameter > - > - ; > - ; Save this function's return address into permenent memory at first. > - ; Then, Fixup the esp point to permenent memory > - ; > - mov eax, esp > - sub eax, ebx > - add eax, ecx > - mov edx, dword ptr [esp] ; copy pushed register's value to= permenent memory > - mov dword ptr [eax], edx > - mov edx, dword ptr [esp + 4] > - mov dword ptr [eax + 4], edx > - mov edx, dword ptr [esp + 8] > - mov dword ptr [eax + 8], edx > - mov edx, dword ptr [esp + 12] > - mov dword ptr [eax + 12], edx > - mov edx, dword ptr [esp + 16] ; Update this function's return a= ddress into permenent memory > - mov dword ptr [eax + 16], edx > - mov esp, eax ; From now, esp is pointed to per= menent memory > - > - ; > - ; Fixup the ebp point to permenent memory > - ; > - mov eax, ebp > - sub eax, ebx > - add eax, ecx > - mov ebp, eax ; From now, ebp is pointed to permenen= t memory > - > - ; > - ; Fixup callee's ebp point for PeiDispatch > - ; > - mov eax, dword ptr [ebp] > - sub eax, ebx > - add eax, ecx > - mov dword ptr [ebp], eax ; From now, Temporary's PPI caller's s= tack is in permenent memory > - > - pop edx > - pop ecx > - pop ebx > - pop eax > - ret > -SecSwitchStack ENDP > - > - END > diff --git a/EmulatorPkg/Sec/Ia32/TempRam.c b/EmulatorPkg/Sec/Ia32/TempRa= m.c > deleted file mode 100644 > index 591354970b..0000000000 > --- a/EmulatorPkg/Sec/Ia32/TempRam.c > +++ /dev/null > @@ -1,65 +0,0 @@ > -/*++ @file > - Temp RAM PPI > - > -Copyright (c) 2011, Apple Inc. All rights reserved.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D License > -which accompanies this distribution. The full text of the license may b= e found at > -http://opensource.org/licenses/bsd-license.php > - > -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMP= LIED. > - > -**/ > - > -#include > -#include > -#include > - > -#include > - > -VOID > -EFIAPI > -SecSwitchStack ( > - UINT32 TemporaryMemoryBase, > - UINT32 PermenentMemoryBase > - ); > - > - > -EFI_STATUS > -EFIAPI > -SecTemporaryRamSupport ( > - IN CONST EFI_PEI_SERVICES **PeiServices, > - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, > - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, > - IN UINTN CopySize > - ) > -{ > - // > - // Migrate the whole temporary memory to permanent memory. > - // > - CopyMem ( > - (VOID*)(UINTN)PermanentMemoryBase, > - (VOID*)(UINTN)TemporaryMemoryBase, > - CopySize > - ); > - > - // > - // SecSwitchStack function must be invoked after the memory migration > - // immediately, also we need fixup the stack change caused by new call= into > - // permanent memory. > - // > - SecSwitchStack ((UINT32) TemporaryMemoryBase, (UINT32) PermanentMemory= Base); > - > - // > - // We need *not* fix the return address because currently, > - // The PeiCore is executed in flash. > - // > - > - // > - // Simulate to invalid temporary memory, terminate temporary memory > - // > - //ZeroMem ((VOID*)(UINTN)TemporaryMemoryBase, CopySize); > - > - return EFI_SUCCESS; > -} > diff --git a/EmulatorPkg/Sec/Sec.c b/EmulatorPkg/Sec/Sec.c > index 4132e9d9b7..84bd54f6c6 100644 > --- a/EmulatorPkg/Sec/Sec.c > +++ b/EmulatorPkg/Sec/Sec.c > @@ -4,6 +4,7 @@ > The OS application will call the SEC with the PEI Entry Point API. > =20 > Copyright (c) 2011, Apple Inc. All rights reserved.
> +Copyright (c) 2019, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D License > which accompanies this distribution. The full text of the license may b= e found at > @@ -17,22 +18,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EIT= HER EXPRESS OR IMPLIED. > #include "Sec.h" > =20 > =20 > - > -EFI_PEI_TEMPORARY_RAM_SUPPORT_PPI mSecTemporaryRamSupportPpi =3D { > - SecTemporaryRamSupport > -}; > - > - > -EFI_PEI_PPI_DESCRIPTOR gPrivateDispatchTable[] =3D { > - { > - EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, > - &gEfiTemporaryRamSupportPpiGuid, > - &mSecTemporaryRamSupportPpi > - } > -}; > - > - > - > /** > The entry point of PE/COFF Image for the PEI Core, that has been hijac= ked by this > SEC that sits on top of an OS application. So the entry and exit of th= is module > @@ -77,54 +62,12 @@ _ModuleEntryPoint ( > EFI_PEI_FILE_HANDLE FileHandle; > VOID *PeCoffImage; > EFI_PEI_CORE_ENTRY_POINT EntryPoint; > - EFI_PEI_PPI_DESCRIPTOR *Ppi; > - EFI_PEI_PPI_DESCRIPTOR *SecPpiList; > - UINTN SecReseveredMemorySize; > - UINTN Index; > =20 > EMU_MAGIC_PAGE()->PpiList =3D PpiList; > ProcessLibraryConstructorList (); > =20 > DEBUG ((EFI_D_ERROR, "SEC Has Started\n")); > =20 > - // > - // Add Our PPIs to the list > - // > - SecReseveredMemorySize =3D sizeof (gPrivateDispatchTable); > - for (Ppi =3D PpiList, Index =3D 1; ; Ppi++, Index++) { > - SecReseveredMemorySize +=3D sizeof (EFI_PEI_PPI_DESCRIPTOR); > - > - if ((Ppi->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) =3D=3D EFI_= PEI_PPI_DESCRIPTOR_TERMINATE_LIST) { > - // Since we are appending, need to clear out privious list termina= tor. > - Ppi->Flags &=3D ~EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST; > - break; > - } > - } > - > - // Keep everything on a good alignment > - SecReseveredMemorySize =3D ALIGN_VALUE (SecReseveredMemorySize, CPU_ST= ACK_ALIGNMENT); > - > -#if 0 > - // Tell the PEI Core to not use our buffer in temp RAM > - SecPpiList =3D (EFI_PEI_PPI_DESCRIPTOR *)SecCoreData->PeiTemporaryRamB= ase; > - SecCoreData->PeiTemporaryRamBase =3D (VOID *)((UINTN)SecCoreData->PeiT= emporaryRamBase + SecReseveredMemorySize); > - SecCoreData->PeiTemporaryRamSize -=3D SecReseveredMemorySize; > -#else > - { > - // > - // When I subtrack from SecCoreData->PeiTemporaryRamBase PEI Core cr= ashes? Either there is a bug > - // or I don't understand temp RAM correctly? > - // > - EFI_PEI_PPI_DESCRIPTOR PpiArray[10]; > - > - SecPpiList =3D &PpiArray[0]; > - ASSERT (sizeof (PpiArray) >=3D SecReseveredMemorySize); > - } > -#endif > - // Copy existing list, and append our entries. > - CopyMem (SecPpiList, PpiList, sizeof (EFI_PEI_PPI_DESCRIPTOR) * Index); > - CopyMem (&SecPpiList[Index], gPrivateDispatchTable, sizeof (gPrivateDi= spatchTable)); > - > // Find PEI Core and transfer control > VolumeHandle =3D (EFI_PEI_FV_HANDLE)(UINTN)SecCoreData->BootFirmwareVo= lumeBase; > FileHandle =3D NULL; > @@ -138,7 +81,7 @@ _ModuleEntryPoint ( > ASSERT_EFI_ERROR (Status); > =20 > // Transfer control to PEI Core > - EntryPoint (SecCoreData, SecPpiList); > + EntryPoint (SecCoreData, PpiList); > =20 > // PEI Core never returns > ASSERT (FALSE); > diff --git a/EmulatorPkg/Sec/Sec.h b/EmulatorPkg/Sec/Sec.h > index c5781201eb..8f60de4405 100644 > --- a/EmulatorPkg/Sec/Sec.h > +++ b/EmulatorPkg/Sec/Sec.h > @@ -4,6 +4,7 @@ > The OS application will call the SEC with the PEI Entry Point API. > =20 > Copyright (c) 2011, Apple Inc. All rights reserved.
> +Copyright (c) 2019, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D License > which accompanies this distribution. The full text of the license may b= e found at > @@ -25,9 +26,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. > #include > #include > =20 > -#include > - > - > // > // I think this shold be defined in a MdePkg include file? > // > @@ -37,15 +35,5 @@ ProcessLibraryConstructorList ( > VOID > ); > =20 > -EFI_STATUS > -EFIAPI > -SecTemporaryRamSupport ( > - IN CONST EFI_PEI_SERVICES **PeiServices, > - IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, > - IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, > - IN UINTN CopySize > - ); > - > - > #endif > =20 > diff --git a/EmulatorPkg/Sec/Sec.inf b/EmulatorPkg/Sec/Sec.inf > index d253fd724e..8691c86dde 100644 > --- a/EmulatorPkg/Sec/Sec.inf > +++ b/EmulatorPkg/Sec/Sec.inf > @@ -3,7 +3,7 @@ > # > # Main executable file of Unix Emulator that loads PEI core after initia= lization finished. > # Portions copyright (c) 2011, Apple Inc. All rights reserved.
> -# Copyright (c) 2012, Intel Corporation. All rights reserved.
> +# Copyright (c) 2012 - 2019, Intel Corporation. All rights reserved.
> # > # This program and the accompanying materials > # are licensed and made available under the terms and conditions of the= BSD License > @@ -25,15 +25,7 @@ [Defines] > =20 > [Sources] > Sec.c > - > -[Sources.X64] > - X64/SwitchRam.asm > - X64/SwitchRam.S > - > -[Sources.IA32] > - Ia32/TempRam.c > - Ia32/SwitchRam.asm > - Ia32/SwitchRam.S > + Sec.h > =20 > [Packages] > MdePkg/MdePkg.dec > @@ -46,8 +38,5 @@ [LibraryClasses] > PpiListLib > BaseMemoryLib > =20 > -[Ppis] > - gEfiTemporaryRamSupportPpiGuid > - > [Pcd] > gEmulatorPkgTokenSpaceGuid.PcdPeiServicesTablePage > diff --git a/EmulatorPkg/Sec/X64/SwitchRam.S b/EmulatorPkg/Sec/X64/Switch= Ram.S > deleted file mode 100644 > index 9ed1f911e7..0000000000 > --- a/EmulatorPkg/Sec/X64/SwitchRam.S > +++ /dev/null > @@ -1,72 +0,0 @@ > -#-----------------------------------------------------------------------= ------- > -# > -# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
> -# Portitions copyright (c) 2011, Apple Inc. All rights reserved. > -# This program and the accompanying materials > -# are licensed and made available under the terms and conditions of the = BSD License > -# which accompanies this distribution. The full text of the license may= be found at > -# http://opensource.org/licenses/bsd-license.php. > -# > -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR I= MPLIED. > -# > -#-----------------------------------------------------------------------= ------- > - > - > - > -// EFI_STATUS > -// EFIAPI > -// SecTemporaryRamSupport ( > -// IN CONST EFI_PEI_SERVICES **PeiServices, // %rcx > -// IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, // %rdx > -// IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, // %r8 > -// IN UINTN CopySize // %r9 > -// ) > -// > -ASM_GLOBAL ASM_PFX(SecTemporaryRamSupport) > -ASM_PFX(SecTemporaryRamSupport): > - // Adjust callers %rbp to account for stack move > - subq %rdx, %rbp // Calc offset of %rbp in Temp Memory > - addq %r8, %rbp // add in permanent base to offset > - > - pushq %rbp // stack frame is for the debugger > - movq %rsp, %rbp > - > - pushq %rdx // Save TemporaryMemoryBase > - pushq %r8 // Save PermanentMemoryBase > - pushq %r9 // Save CopySize > - > - // > - // Copy all of temp RAM to permanent memory, including stack > - // > - // CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize); > - // %rcx, %rdx, %r8 > - movq %r8, %rcx // Shift arguments > - movq %r9, %r8 > - subq $0x28, %rsp // Allocate register spill area & 16-byte align = stack > - call ASM_PFX(CopyMem) > - // Temp mem stack now copied to permanent location. %esp still in temp= memory > - addq $0x28, %rsp > - > - popq %r9 // CopySize (old stack) > - popq %r8 // PermanentMemoryBase (old stack) > - popq %rdx // TemporaryMemoryBase (old stack) > - > - movq %rsp, %rcx // Move to new stack > - subq %rdx, %rcx // Calc offset of stack in Temp Memory > - addq %r8, %rcx // Calc PermanentMemoryBase address > - movq %rcx, %rsp // Update stack > - // Stack now points to permanent memory > - > - // ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */); > - movq %rdx, %rcx > - movq %r9, %rdx > - subq $0x28, %rsp // Allocate register spill area & 16-byte align = stack > - call ASM_PFX(ZeroMem) > - addq $0x28, %rsp > - > - // This data comes off the NEW stack > - popq %rbp > - ret > - > - > diff --git a/EmulatorPkg/Sec/X64/SwitchRam.asm b/EmulatorPkg/Sec/X64/Swit= chRam.asm > deleted file mode 100644 > index d1a7b943fd..0000000000 > --- a/EmulatorPkg/Sec/X64/SwitchRam.asm > +++ /dev/null > @@ -1,76 +0,0 @@ > -;-----------------------------------------------------------------------= ------- > -; > -; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
> -; Portitions copyright (c) 2011, Apple Inc. All rights reserved. > -; This program and the accompanying materials > -; are licensed and made available under the terms and conditions of the = BSD License > -; which accompanies this distribution. The full text of the license may= be found at > -; http://opensource.org/licenses/bsd-license.php. > -; > -; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > -; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR I= MPLIED. > -; > -;-----------------------------------------------------------------------= ------- > - > -EXTERN CopyMem:PROC > -EXTERN ZeroMem:PROC > - > - .code > - > -;-----------------------------------------------------------------------= ------- > -; EFI_STATUS > -; EFIAPI > -; SecTemporaryRamSupport ( > -; IN CONST EFI_PEI_SERVICES **PeiServices, // %rcx > -; IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase, // %rdx > -; IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase, // %r8 > -; IN UINTN CopySize // %r9 > -; ) > -;-----------------------------------------------------------------------= ------- > -SecTemporaryRamSupport PROC > - ; Adjust callers %rbp to account for stack move > - sub rbp, rdx ; Calc offset of %rbp in Temp Memory > - add rbp, r8 ; add in permanent base to offset > - > - push rbp ; stack frame is for the debugger > - mov rbp, rsp > - > - push rdx ; Save TemporaryMemoryBase > - push r8 ; Save PermanentMemoryBase > - push r9 ; Save CopySize > - > - ; > - ; Copy all of temp RAM to permanent memory, including stack > - ; > - ; CopyMem (PermanentMemoryBase, TemporaryMemoryBase, CopySize); > - ; %rcx, %rdx, %r8 > - mov rcx, r8 ; Shift arguments > - mov r8, r9 > - sub rsp, 028h ; Allocate register spill area & 16-byte align s= tack > - call CopyMem > - ; Temp mem stack now copied to permanent location. %esp still in temp = memory > - add rsp, 028h > - > - pop r9 ; CopySize (old stack) > - pop r8 ; PermanentMemoryBase (old stack) > - pop rdx ; TemporaryMemoryBase (old stack) > - > - mov rcx, rsp ; Move to new stack > - sub rcx, rdx ; Calc offset of stack in Temp Memory > - add rcx, r8 ; Calc PermanentMemoryBase address > - mov rsp, rcx ; Update stack > - ; Stack now points to permanent memory > - > - ; ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */); > - mov rcx, rdx > - mov rdx, r9 > - sub rsp, 028h ; Allocate register spill area & 16-byte align s= tack > - call ZeroMem > - add rsp, 028h > - > - ; This data comes off the NEW stack > - pop rbp > - ret > -SecTemporaryRamSupport ENDP > - > - END > --=20 > 2.20.1.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel