Revision: 16152
http://sourceforge.net/p/edk2/code/16152
Author: jyao1
Date: 2014-09-22 05:54:41 +0000 (Mon, 22 Sep 2014)
Log Message:
-----------
Fix X64 native function call prolog. Prepare space for at least 4 arguments,
even if the native function's arguments are less than 4.
>From MSDN x64 Software Conventions, Overview of x64 Calling Conventions:
?\226?\128?\156The caller is responsible for allocating space for parameters to
the
callee, and must always allocate sufficient space for the 4 register
parameters, even if the callee doesn?\226?\128?\153t have that many parameters.
This aids in the simplicity of supporting C unprototyped functions,
and vararg C/C++ functions.?\226?\128?\157
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Samer El-Haj-Mahmoud [email protected]
Reviewed by: Jiewen Yao <[email protected]>
Reviewed by: Feng Tian <[email protected]>
Modified Paths:
--------------
trunk/edk2/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S
trunk/edk2/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm
Modified: trunk/edk2/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S 2014-09-22
05:40:30 UTC (rev 16151)
+++ trunk/edk2/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.S 2014-09-22
05:54:41 UTC (rev 16152)
@@ -3,7 +3,7 @@
# This code provides low level routines that support the Virtual Machine
# for option ROMs.
#
-# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
# 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
@@ -46,7 +46,34 @@
# Set stack pointer to new value
sub %rdx, %r8
+
+ #
+ # Fix X64 native function call prolog. Prepare space for at least 4
arguments,
+ # even if the native function's arguments are less than 4.
+ #
+ # From MSDN x64 Software Conventions, Overview of x64 Calling
Conventions:
+ # "The caller is responsible for allocating space for parameters to the
+ # callee, and must always allocate sufficient space for the 4 register
+ # parameters, even if the callee doesn't have that many parameters.
+ # This aids in the simplicity of supporting C unprototyped functions,
+ # and vararg C/C++ functions."
+ #
+ cmp $0x20, %r8
+ jae skip_expansion
+ mov $0x20, %r8
+skip_expansion:
+
sub %r8, %rsp
+
+ #
+ # Fix X64 native function call 16-byte alignment.
+ #
+ # From MSDN x64 Software Conventions, Stack Usage:
+ # "The stack will always be maintained 16-byte aligned, except within
+ # the prolog (for example, after the return address is pushed)."
+ #
+ and $0xFFFFFFFFFFFFFFF0, %rsp
+
mov %rsp, %rcx
sub $0x20, %rsp
call ASM_PFX(CopyMem)
Modified: trunk/edk2/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm
===================================================================
--- trunk/edk2/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm
2014-09-22 05:40:30 UTC (rev 16151)
+++ trunk/edk2/MdeModulePkg/Universal/EbcDxe/X64/EbcLowLevel.asm
2014-09-22 05:54:41 UTC (rev 16152)
@@ -4,6 +4,7 @@
; for option ROMs.
;
; Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2014 Hewlett-Packard Development Company, L.P.<BR>
; 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
@@ -50,7 +51,34 @@
; Set stack pointer to new value
sub r8, rdx
+
+ ;
+ ; Fix X64 native function call prolog. Prepare space for at least 4
arguments,
+ ; even if the native function's arguments are less than 4.
+ ;
+ ; From MSDN x64 Software Conventions, Overview of x64 Calling
Conventions:
+ ; "The caller is responsible for allocating space for parameters to the
+ ; callee, and must always allocate sufficient space for the 4 register
+ ; parameters, even if the callee doesn't have that many parameters.
+ ; This aids in the simplicity of supporting C unprototyped functions,
+ ; and vararg C/C++ functions."
+ ;
+ cmp r8, 20h
+ jae skip_expansion
+ mov r8, 20h
+skip_expansion:
+
sub rsp, r8
+
+ ;
+ ; Fix X64 native function call 16-byte alignment.
+ ;
+ ; From MSDN x64 Software Conventions, Stack Usage:
+ ; "The stack will always be maintained 16-byte aligned, except within
+ ; the prolog (for example, after the return address is pushed)."
+ ;
+ and rsp, NOT 0fh
+
mov rcx, rsp
sub rsp, 20h
call CopyMem
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits