]> git.proxmox.com Git - mirror_edk2.git/commitdiff
InOsEmuPkg/Sec: Update assembly code when calling EFIAPI functions
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 15 May 2011 17:23:17 +0000 (17:23 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 15 May 2011 17:23:17 +0000 (17:23 +0000)
For X64 the stack should be 16-byte aligned before calling a
function, and a register spill area should be reserved.

Signed-off-by: jljusten
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11651 6f19259b-4bc3-4df7-8a09-765794883524

InOsEmuPkg/Sec/X64/SwitchRam.S

index 6bb2857ff086b62871e57509e9810989e1f79e55..a7219bf21f4671407b91f4fbe412d4e4d8378b89 100644 (file)
@@ -1,6 +1,6 @@
 #------------------------------------------------------------------------------\r
 #\r
-# Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 # Portitions copyright (c) 2011, Apple Inc. All rights reserved.\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
@@ -35,7 +35,7 @@ ASM_PFX(SecTemporaryRamSupport):
   pushq   %rdx          // Save TemporaryMemoryBase\r
   pushq   %r8           // Save PermanentMemoryBase\r
   pushq   %r9           // Save CopySize\r
-  \r
+\r
   //\r
   // Copy all of temp RAM to permanent memory, including stack\r
   //\r
@@ -43,9 +43,11 @@ ASM_PFX(SecTemporaryRamSupport):
   //          %rcx,                %rdx,                %r8\r
   movq    %r8,  %rcx    // Shift arguments\r
   movq    %r9,  %r8\r
+  subq    $0x28, %rsp   // Allocate register spill area & 16-byte align stack\r
   call    ASM_PFX(CopyMem)\r
   // Temp mem stack now copied to permanent location. %esp still in temp memory\r
-  \r
+  addq    $0x28, %rsp\r
+\r
   popq    %r9           // CopySize (old stack)\r
   popq    %r8           // PermanentMemoryBase (old stack)\r
   popq    %rdx          // TemporaryMemoryBase (old stack)\r
@@ -59,7 +61,9 @@ ASM_PFX(SecTemporaryRamSupport):
   // ZeroMem (TemporaryMemoryBase /* rcx */, CopySize /* rdx */);\r
   movq    %rdx, %rcx\r
   movq    %r9,  %rdx\r
+  subq    $0x28, %rsp   // Allocate register spill area & 16-byte align stack\r
   call    ASM_PFX(ZeroMem)\r
+  addq    $0x28, %rsp\r
 \r
   // This data comes off the NEW stack\r
   popq    %rbp\r