From: lgao4 Date: Fri, 10 Nov 2006 09:01:25 +0000 (+0000) Subject: Fix to pre-allocate 32bytes in stack to Load X64 Image. X-Git-Tag: edk2-stable201903~23948 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=9723bdde15bfa46251c7a5440b034e80f11d192f Fix to pre-allocate 32bytes in stack to Load X64 Image. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1929 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/EdkModulePkg/Core/DxeIplX64Peim/DxeLoadX64.c b/EdkModulePkg/Core/DxeIplX64Peim/DxeLoadX64.c index d011858cb9..7b293ef0c2 100644 --- a/EdkModulePkg/Core/DxeIplX64Peim/DxeLoadX64.c +++ b/EdkModulePkg/Core/DxeIplX64Peim/DxeLoadX64.c @@ -260,10 +260,14 @@ Returns: // // Compute the top of the stack we were allocated. Pre-allocate a 32 bytes - // for safety (PpisNeededByDxe and DxeCore). + // for x64 calling convention. // - TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT; - TopOfStack = (EFI_PHYSICAL_ADDRESS) ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT); + // The first four parameters to a function are passed in rcx, rdx, r8 and r9. + // Any further parameters are pushed on the stack. Furthermore, space (4 * 8bytes) for the + // register parameters is reserved on the stack, in case the called function + // wants to spill them; this is important if the function is variadic. + // + TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - 32; // // Add architecture-specifc HOBs (including the BspStore HOB)