]>
Commit | Line | Data |
---|---|---|
f493cf81 JJ |
1 | ;------------------------------------------------------------------------------\r |
2 | ;\r | |
0aac2f77 | 3 | ; Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r |
f493cf81 JJ |
4 | ; This program and the accompanying materials\r |
5 | ; are licensed and made available under the terms and conditions of the BSD License\r | |
6 | ; which accompanies this distribution. The full text of the license may be found at\r | |
7 | ; http://opensource.org/licenses/bsd-license.php.\r | |
8 | ;\r | |
9 | ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | ;\r | |
12 | ; Module Name:\r | |
13 | ;\r | |
14 | ; LongJump.Asm\r | |
15 | ;\r | |
16 | ; Abstract:\r | |
17 | ;\r | |
18 | ; Implementation of _LongJump() on IA-32.\r | |
19 | ;\r | |
20 | ;------------------------------------------------------------------------------\r | |
21 | \r | |
0aac2f77 JY |
22 | %include "Nasm.inc"\r |
23 | \r | |
f493cf81 JJ |
24 | SECTION .text\r |
25 | \r | |
0aac2f77 JY |
26 | extern ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask))\r |
27 | \r | |
f493cf81 JJ |
28 | ;------------------------------------------------------------------------------\r |
29 | ; VOID\r | |
30 | ; EFIAPI\r | |
31 | ; InternalLongJump (\r | |
32 | ; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r | |
33 | ; IN UINTN Value\r | |
34 | ; );\r | |
35 | ;------------------------------------------------------------------------------\r | |
36 | global ASM_PFX(InternalLongJump)\r | |
37 | ASM_PFX(InternalLongJump):\r | |
0aac2f77 JY |
38 | \r |
39 | mov eax, [ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask))]\r | |
40 | test eax, eax\r | |
41 | jz CetDone\r | |
42 | mov eax, cr4\r | |
43 | bt eax, 23 ; check if CET is enabled\r | |
44 | jnc CetDone\r | |
45 | \r | |
46 | mov edx, [esp + 4] ; edx = JumpBuffer\r | |
47 | mov edx, [edx + 24] ; edx = target SSP\r | |
48 | READSSP_EAX\r | |
49 | sub edx, eax ; edx = delta\r | |
50 | mov eax, edx ; eax = delta\r | |
51 | \r | |
52 | shr eax, 2 ; eax = delta/sizeof(UINT32)\r | |
53 | INCSSP_EAX\r | |
54 | \r | |
55 | CetDone:\r | |
56 | \r | |
f493cf81 JJ |
57 | pop eax ; skip return address\r |
58 | pop edx ; edx <- JumpBuffer\r | |
59 | pop eax ; eax <- Value\r | |
60 | mov ebx, [edx]\r | |
61 | mov esi, [edx + 4]\r | |
62 | mov edi, [edx + 8]\r | |
63 | mov ebp, [edx + 12]\r | |
64 | mov esp, [edx + 16]\r | |
65 | jmp dword [edx + 20] ; restore "eip"\r | |
66 | \r |