]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix bug when reserve stack space to fill exception context.
authorJeff Fan <jeff.fan@intel.com>
Fri, 10 Jan 2014 02:48:49 +0000 (02:48 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 10 Jan 2014 02:48:49 +0000 (02:48 +0000)
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15086 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.S
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.asm

index 6e80d848fef2033f77cb5afa203d862e83639374..233dbcbcc536e0d6b990635dd8d517b56ee4acd5 100644 (file)
@@ -1,5 +1,5 @@
 #------------------------------------------------------------------------------ ;\r
-# Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -269,15 +269,15 @@ VectorNum:
 ASM_GLOBAL ASM_PFX(HookAfterStubHeaderEnd)\r
 ASM_PFX(HookAfterStubHeaderEnd):\r
     movq    %rsp, %rax\r
-    subq    $8, %rsp\r
-    andl    $0x0fffffff0, %esp\r
+    andl    $0x0fffffff0, %esp  # make sure 16-byte aligned for exception context\r
+    subq    $0x18, %rsp         # reserve room for filling exception data later\r
     pushq   %rcx\r
     movq    8(%rax), %rcx\r
     pushq   %rax\r
     movabsl ASM_PFX(mErrorCodeFlag), %eax\r
     bt      %ecx, %eax\r
     popq    %rax\r
-    j     NoErrorData\r
+    jnc     NoErrorData\r
     pushq   (%rsp)            # push additional rcx to make stack alignment\r
 NoErrorData:\r
     xchgq   (%rsp), %rcx      # restore rcx, save Exception Number in stack\r
index f348efe4befeb3406db407dbb3a39dab5b252436..59bec5985a5a1d5e497b6b26714a8ea7a190203e 100644 (file)
@@ -1,5 +1,5 @@
 ;------------------------------------------------------------------------------ ;\r
-; Copyright (c) 2012 - 2013, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>\r
 ; This program and the accompanying materials\r
 ; are licensed and made available under the terms and conditions of the BSD License\r
 ; which accompanies this distribution.  The full text of the license may be found at\r
@@ -53,12 +53,12 @@ HookAfterStubHeaderBegin:
     jmp     rax\r
 HookAfterStubHeaderEnd:\r
     mov     rax, rsp\r
-    sub     rsp, 8h\r
-    and     sp, 0fff0h\r
+    and     sp,  0fff0h        ; make sure 16-byte aligned for exception context\r
+    sub     rsp, 18h           ; reserve room for filling exception data later\r
     push    rcx\r
     mov     rcx, [rax + 8]\r
     bt      mErrorCodeFlag, ecx\r
-    j     @F\r
+    jnc     @F\r
     push    [rsp]             ; push additional rcx to make stack alignment\r
 @@:\r
     xchg    rcx, [rsp]        ; restore rcx, save Exception Number in stack\r