]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/Ia32/SetJump.nasm
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / SetJump.nasm
index 6d3a5a25bb708556756f9ecf2285912d2f48a81d..364613b5f9a58afe1d3cfa510d40661630ff550f 100644 (file)
@@ -1,13 +1,7 @@
 ;------------------------------------------------------------------------------\r
 ;\r
-; Copyright (c) 2006, 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) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+; SPDX-License-Identifier: BSD-2-Clause-Patent\r
 ;\r
 ; Module Name:\r
 ;\r
 ;\r
 ;------------------------------------------------------------------------------\r
 \r
+%include "Nasm.inc"\r
+\r
     SECTION .text\r
 \r
 extern ASM_PFX(InternalAssertJumpBuffer)\r
+extern ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask))\r
 \r
 ;------------------------------------------------------------------------------\r
 ; UINTN\r
@@ -37,6 +34,24 @@ ASM_PFX(SetJump):
     pop     ecx\r
     pop     ecx                         ; ecx <- return address\r
     mov     edx, [esp]\r
+\r
+    xor     eax, eax\r
+    mov     [edx + 24], eax        ; save 0 to SSP\r
+\r
+    mov     eax, [ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask))]\r
+    test    eax, eax\r
+    jz      CetDone\r
+    mov     eax, cr4\r
+    bt      eax, 23                ; check if CET is enabled\r
+    jnc     CetDone\r
+\r
+    mov     eax, 1\r
+    INCSSP_EAX                     ; to read original SSP\r
+    READSSP_EAX\r
+    mov     [edx + 0x24], eax      ; save SSP\r
+\r
+CetDone:\r
+\r
     mov     [edx], ebx\r
     mov     [edx + 4], esi\r
     mov     [edx + 8], edi\r