2 Implementation of SetJump() 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"
13 Worker function that checks ASSERT condition for JumpBuffer
15 Checks ASSERT condition for JumpBuffer.
17 If JumpBuffer is NULL, then ASSERT().
18 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
20 @param JumpBuffer A pointer to CPU context buffer.
25 InternalAssertJumpBuffer (
26 IN BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
30 Saves the current CPU context that can be restored with a call to LongJump()
33 Saves the current CPU context in the buffer specified by JumpBuffer and
34 returns 0. The initial call to SetJump() must always return 0. Subsequent
35 calls to LongJump() cause a non-zero value to be returned by SetJump().
37 If JumpBuffer is NULL, then ASSERT().
38 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
40 @param JumpBuffer A pointer to CPU context buffer.
42 @retval 0 Indicates a return from SetJump().
50 OUT BASE_LIBRARY_JUMP_BUFFER
*JumpBuffer
55 call InternalAssertJumpBuffer
61 mov
[edx
+ 24], eax
; save
0 to SSP
63 mov eax
, [PcdGet32 (PcdControlFlowEnforcementPropertyMask
)]
68 _emit
0xE0 ; mov eax
, cr4
69 bt eax
, 23 ; check
if CET is enabled
76 _emit
0xE8 ; INCSSP EAX to read original SSP
80 _emit
0xC8 ; READSSP EAX
81 mov
[edx
+ 0x24], eax
; save SSP