2 Implementation of _LongJump() on IA-32.
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "BaseLibInternals.h"
14 Restores the CPU context that was saved with SetJump().
16 Restores the CPU context from the buffer specified by JumpBuffer.
17 This function never returns to the caller.
18 Instead is resumes execution based on the state of JumpBuffer.
20 @param JumpBuffer A pointer to CPU context buffer.
21 @param Value The value to return when the SetJump() context is restored.
28 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
33 mov eax
, [PcdGet32 (PcdControlFlowEnforcementPropertyMask
)]
38 _emit
0xE0 ; mov eax
, cr4
39 bt eax
, 23 ; check
if CET is enabled
42 mov edx
, [esp
+ 4] ; edx
= JumpBuffer
43 mov edx
, [edx
+ 24] ; edx
= target SSP
47 _emit
0xC8 ; READSSP EAX
48 sub edx
, eax
; edx
= delta
49 mov eax
, edx
; eax
= delta
51 shr eax
, 2 ; eax
= delta
/sizeof(UINT32
)
55 _emit
0xE8 ; INCSSP EAX
59 pop eax
; skip
return address
60 pop edx
; edx
<- JumpBuffer
61 pop eax
; eax
<- Value
67 jmp dword ptr
[edx
+ 20]