]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
UefiCpuPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / UefiCpuPkg / Library / CpuExceptionHandlerLib / X64 / ExceptionHandlerAsm.nasm
index ba8993d84b0b44ede48eb6f739022da8f4cc43c2..4db1a09f288185ca4af071a500d6d718dedec1a6 100644 (file)
@@ -1,12 +1,6 @@
 ;------------------------------------------------------------------------------ ;\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
-; http://opensource.org/licenses/bsd-license.php.\r
-;\r
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+; Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>\r
+; SPDX-License-Identifier: BSD-2-Clause-Patent\r
 ;\r
 ; Module Name:\r
 ;\r
@@ -40,7 +34,7 @@ AsmIdtVectorBegin:
     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
@@ -50,7 +44,8 @@ HookAfterStubHeaderBegin:
 @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
@@ -260,8 +255,7 @@ HasErrorCode:
     ; 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
@@ -369,11 +363,24 @@ DoIret:
 ; 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     rax, HookAfterStubHeaderBegin\r
+    lea     rax, [HookAfterStubHeaderBegin]\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