From e5dc7e714f31170f4872bbef099d431b5441acf9 Mon Sep 17 00:00:00 2001 From: jljusten Date: Sun, 15 May 2011 17:23:17 +0000 Subject: [PATCH] InOsEmuPkg/Sec: Update assembly code when calling EFIAPI functions 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 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/InOsEmuPkg/Sec/X64/SwitchRam.S b/InOsEmuPkg/Sec/X64/SwitchRam.S index 6bb2857ff0..a7219bf21f 100644 --- a/InOsEmuPkg/Sec/X64/SwitchRam.S +++ b/InOsEmuPkg/Sec/X64/SwitchRam.S @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ # -# Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+# 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 @@ -35,7 +35,7 @@ ASM_PFX(SecTemporaryRamSupport): pushq %rdx // Save TemporaryMemoryBase pushq %r8 // Save PermanentMemoryBase pushq %r9 // Save CopySize - + // // Copy all of temp RAM to permanent memory, including stack // @@ -43,9 +43,11 @@ ASM_PFX(SecTemporaryRamSupport): // %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) @@ -59,7 +61,9 @@ ASM_PFX(SecTemporaryRamSupport): // 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