+++ /dev/null
-/** @file\r
- Implementation of _LongJump() on IA-32.\r
-\r
- Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-\r
-#include "BaseLibInternals.h"\r
-\r
-\r
-/**\r
- Restores the CPU context that was saved with SetJump().\r
-\r
- Restores the CPU context from the buffer specified by JumpBuffer.\r
- This function never returns to the caller.\r
- Instead is resumes execution based on the state of JumpBuffer.\r
-\r
- @param JumpBuffer A pointer to CPU context buffer.\r
- @param Value The value to return when the SetJump() context is restored.\r
-\r
-**/\r
-__declspec (naked)\r
-VOID\r
-EFIAPI\r
-InternalLongJump (\r
- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
- IN UINTN Value\r
- )\r
-{\r
- _asm {\r
- mov eax, [PcdGet32 (PcdControlFlowEnforcementPropertyMask)]\r
- test eax, eax\r
- jz CetDone\r
- _emit 0x0F\r
- _emit 0x20\r
- _emit 0xE0 ; mov eax, cr4\r
- bt eax, 23 ; check if CET is enabled\r
- jnc CetDone\r
-\r
- mov edx, [esp + 4] ; edx = JumpBuffer\r
- mov edx, [edx + 24] ; edx = target SSP\r
- _emit 0xF3\r
- _emit 0x0F\r
- _emit 0x1E\r
- _emit 0xC8 ; READSSP EAX\r
- sub edx, eax ; edx = delta\r
- mov eax, edx ; eax = delta\r
-\r
- shr eax, 2 ; eax = delta/sizeof(UINT32)\r
- _emit 0xF3\r
- _emit 0x0F\r
- _emit 0xAE\r
- _emit 0xE8 ; INCSSP EAX\r
-\r
-CetDone:\r
-\r
- pop eax ; skip return address\r
- pop edx ; edx <- JumpBuffer\r
- pop eax ; eax <- Value\r
- mov ebx, [edx]\r
- mov esi, [edx + 4]\r
- mov edi, [edx + 8]\r
- mov ebp, [edx + 12]\r
- mov esp, [edx + 16]\r
- jmp dword ptr [edx + 20]\r
- }\r
-}\r
-\r