2 Implementation of _LongJump() on IA-32.
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "BaseLibInternals.h"
20 Restores the CPU context that was saved with SetJump().
22 Restores the CPU context from the buffer specified by JumpBuffer.
23 This function never returns to the caller.
24 Instead is resumes execution based on the state of JumpBuffer.
26 @param JumpBuffer A pointer to CPU context buffer.
27 @param Value The value to return when the SetJump() context is restored.
34 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
,
39 mov eax
, [PcdGet32 (PcdControlFlowEnforcementPropertyMask
)]
44 _emit
0xE0 ; mov eax
, cr4
45 bt eax
, 23 ; check
if CET is enabled
48 mov edx
, [esp
+ 4] ; edx
= JumpBuffer
49 mov edx
, [edx
+ 24] ; edx
= target SSP
53 _emit
0xC8 ; READSSP EAX
54 sub edx
, eax
; edx
= delta
55 mov eax
, edx
; eax
= delta
57 shr eax
, 2 ; eax
= delta
/sizeof(UINT32
)
61 _emit
0xE8 ; INCSSP EAX
65 pop eax
; skip
return address
66 pop edx
; edx
<- JumpBuffer
67 pop eax
; eax
<- Value
73 jmp dword ptr
[edx
+ 20]