]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/LongJump.nasm
MdePkg: Replace Opcode with the corresponding instructions.
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / LongJump.nasm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
5 ;
6 ; Module Name:
7 ;
8 ; LongJump.Asm
9 ;
10 ; Abstract:
11 ;
12 ; Implementation of _LongJump() on IA-32.
13 ;
14 ;------------------------------------------------------------------------------
15
16 %include "Nasm.inc"
17
18 SECTION .text
19
20 extern ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask))
21
22 ;------------------------------------------------------------------------------
23 ; VOID
24 ; EFIAPI
25 ; InternalLongJump (
26 ; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
27 ; IN UINTN Value
28 ; );
29 ;------------------------------------------------------------------------------
30 global ASM_PFX(InternalLongJump)
31 ASM_PFX(InternalLongJump):
32
33 mov eax, [ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask))]
34 test eax, eax
35 jz CetDone
36 mov eax, cr4
37 bt eax, 23 ; check if CET is enabled
38 jnc CetDone
39
40 mov edx, [esp + 4] ; edx = JumpBuffer
41 mov edx, [edx + 24] ; edx = target SSP
42 rdsspd eax
43 sub edx, eax ; edx = delta
44 mov eax, edx ; eax = delta
45
46 shr eax, 2 ; eax = delta/sizeof(UINT32)
47 incsspd eax
48
49 CetDone:
50
51 pop eax ; skip return address
52 pop edx ; edx <- JumpBuffer
53 pop eax ; eax <- Value
54 mov ebx, [edx]
55 mov esi, [edx + 4]
56 mov edi, [edx + 8]
57 mov ebp, [edx + 12]
58 mov esp, [edx + 16]
59 jmp dword [edx + 20] ; restore "eip"
60