]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/SetJump.nasm
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / SetJump.nasm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
5 ;
6 ; Module Name:
7 ;
8 ; SetJump.Asm
9 ;
10 ; Abstract:
11 ;
12 ; Implementation of SetJump() on IA-32.
13 ;
14 ;------------------------------------------------------------------------------
15
16 %include "Nasm.inc"
17
18 SECTION .text
19
20 extern ASM_PFX(InternalAssertJumpBuffer)
21 extern ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask))
22
23 ;------------------------------------------------------------------------------
24 ; UINTN
25 ; EFIAPI
26 ; SetJump (
27 ; OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
28 ; );
29 ;------------------------------------------------------------------------------
30 global ASM_PFX(SetJump)
31 ASM_PFX(SetJump):
32 push DWORD [esp + 4]
33 call ASM_PFX(InternalAssertJumpBuffer) ; To validate JumpBuffer
34 pop ecx
35 pop ecx ; ecx <- return address
36 mov edx, [esp]
37
38 xor eax, eax
39 mov [edx + 24], eax ; save 0 to SSP
40
41 mov eax, [ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask))]
42 test eax, eax
43 jz CetDone
44 mov eax, cr4
45 bt eax, 23 ; check if CET is enabled
46 jnc CetDone
47
48 mov eax, 1
49 INCSSP_EAX ; to read original SSP
50 READSSP_EAX
51 mov [edx + 0x24], eax ; save SSP
52
53 CetDone:
54
55 mov [edx], ebx
56 mov [edx + 4], esi
57 mov [edx + 8], edi
58 mov [edx + 12], ebp
59 mov [edx + 16], esp
60 mov [edx + 20], ecx ; eip value to restore in LongJump
61 xor eax, eax
62 jmp ecx
63