]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool chain
authorLiming Gao <liming.gao@intel.com>
Thu, 11 Jan 2018 09:05:13 +0000 (17:05 +0800)
committerLiming Gao <liming.gao@intel.com>
Tue, 16 Jan 2018 15:42:48 +0000 (23:42 +0800)
https://bugzilla.tianocore.org/show_bug.cgi?id=849

In V2, use mov rax, strict qword 0 to replace the hard code db.

Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm

index ba8993d84b0b44ede48eb6f739022da8f4cc43c2..7b97810d10976a164688804a81519111a899e7f7 100644 (file)
@@ -1,5 +1,5 @@
 ;------------------------------------------------------------------------------ ;\r
 ;------------------------------------------------------------------------------ ;\r
-; Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>\r
+; Copyright (c) 2012 - 2018, 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
 ; 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
@@ -40,7 +40,7 @@ AsmIdtVectorBegin:
     db      0x6a        ; push  #VectorNum\r
     db      ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum\r
     push    rax\r
     db      0x6a        ; push  #VectorNum\r
     db      ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 32) ; VectorNum\r
     push    rax\r
-    mov     rax, ASM_PFX(CommonInterruptEntry)\r
+    mov     rax, strict qword 0 ;    mov     rax, ASM_PFX(CommonInterruptEntry)\r
     jmp     rax\r
 %endrep\r
 AsmIdtVectorEnd:\r
     jmp     rax\r
 %endrep\r
 AsmIdtVectorEnd:\r
@@ -50,7 +50,8 @@ HookAfterStubHeaderBegin:
 @VectorNum:\r
     db      0          ; 0 will be fixed\r
     push    rax\r
 @VectorNum:\r
     db      0          ; 0 will be fixed\r
     push    rax\r
-    mov     rax, HookAfterStubHeaderEnd\r
+    mov     rax, strict qword 0 ;     mov     rax, HookAfterStubHeaderEnd\r
+JmpAbsoluteAddress:\r
     jmp     rax\r
 HookAfterStubHeaderEnd:\r
     mov     rax, rsp\r
     jmp     rax\r
 HookAfterStubHeaderEnd:\r
     mov     rax, rsp\r
@@ -260,8 +261,7 @@ HasErrorCode:
     ; and make sure RSP is 16-byte aligned\r
     ;\r
     sub     rsp, 4 * 8 + 8\r
     ; and make sure RSP is 16-byte aligned\r
     ;\r
     sub     rsp, 4 * 8 + 8\r
-    mov     rax, ASM_PFX(CommonExceptionHandler)\r
-    call    rax\r
+    call    ASM_PFX(CommonExceptionHandler)\r
     add     rsp, 4 * 8 + 8\r
 \r
     cli\r
     add     rsp, 4 * 8 + 8\r
 \r
     cli\r
@@ -369,11 +369,24 @@ DoIret:
 ; comments here for definition of address map\r
 global ASM_PFX(AsmGetTemplateAddressMap)\r
 ASM_PFX(AsmGetTemplateAddressMap):\r
 ; comments here for definition of address map\r
 global ASM_PFX(AsmGetTemplateAddressMap)\r
 ASM_PFX(AsmGetTemplateAddressMap):\r
-    mov     rax, AsmIdtVectorBegin\r
+    lea     rax, [AsmIdtVectorBegin]\r
     mov     qword [rcx], rax\r
     mov     qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32\r
     mov     qword [rcx], rax\r
     mov     qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32\r
-    mov     rax, HookAfterStubHeaderBegin\r
+    lea     rax, [HookAfterStubHeaderBegin]\r
     mov     qword [rcx + 0x10], rax\r
     mov     qword [rcx + 0x10], rax\r
+\r
+; Fix up CommonInterruptEntry address\r
+    lea    rax, [ASM_PFX(CommonInterruptEntry)]\r
+    lea    rcx, [AsmIdtVectorBegin]\r
+%rep  32\r
+    mov    qword [rcx + (JmpAbsoluteAddress - 8 - HookAfterStubHeaderBegin)], rax\r
+    add    rcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32\r
+%endrep\r
+; Fix up HookAfterStubHeaderEnd\r
+    lea    rax, [HookAfterStubHeaderEnd]\r
+    lea    rcx, [JmpAbsoluteAddress]\r
+    mov    qword [rcx - 8], rax\r
+\r
     ret\r
 \r
 ;-------------------------------------------------------------------------------------\r
     ret\r
 \r
 ;-------------------------------------------------------------------------------------\r