]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix to pre-allocate 32bytes in stack to Load X64 Image.
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Nov 2006 09:01:25 +0000 (09:01 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Nov 2006 09:01:25 +0000 (09:01 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1929 6f19259b-4bc3-4df7-8a09-765794883524

EdkModulePkg/Core/DxeIplX64Peim/DxeLoadX64.c

index d011858cb9ca3513d1b4b5fb9663a8bce83254bd..7b293ef0c2bb39cca1de152853c56d051f8f18eb 100644 (file)
@@ -260,10 +260,14 @@ Returns:
 \r
   //\r
   // Compute the top of the stack we were allocated. Pre-allocate a 32 bytes\r
 \r
   //\r
   // Compute the top of the stack we were allocated. Pre-allocate a 32 bytes\r
-  // for safety (PpisNeededByDxe and DxeCore).\r
+  // for x64 calling convention.\r
   //\r
   //\r
-  TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT;\r
-  TopOfStack = (EFI_PHYSICAL_ADDRESS) ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);\r
+  // The first four parameters to a function are passed in rcx, rdx, r8 and r9. \r
+  // Any further parameters are pushed on the stack. Furthermore, space (4 * 8bytes) for the \r
+  // register parameters is reserved on the stack, in case the called function \r
+  // wants to spill them; this is important if the function is variadic. \r
+  //\r
+  TopOfStack = BaseOfStack + EFI_SIZE_TO_PAGES (STACK_SIZE) * EFI_PAGE_SIZE - 32;\r
 \r
   //\r
   // Add architecture-specifc HOBs (including the BspStore HOB)\r
 \r
   //\r
   // Add architecture-specifc HOBs (including the BspStore HOB)\r