diff options
author | Shenglei Zhang <shenglei.zhang@intel.com> | 2019-03-05 11:08:29 +0800 |
---|---|---|
committer | Liming Gao <liming.gao@intel.com> | 2019-04-15 09:12:44 +0800 |
commit | 174232fa9a90cfc224432ff5cb05872cb86daa3f (patch) | |
tree | f7ffcf8c30a2c0736f9e45b193a58bbac4d98781 /MdePkg/Library/BaseLib/Ia32 | |
parent | 34131e1b5c09b92c2801749212d9c3595e5f62d7 (diff) | |
download | edk2-174232fa9a90cfc224432ff5cb05872cb86daa3f.zip edk2-174232fa9a90cfc224432ff5cb05872cb86daa3f.tar.gz edk2-174232fa9a90cfc224432ff5cb05872cb86daa3f.tar.bz2 |
MdePkg/BaseLib: Remove LongJump.c and SetJump.c
MdePkg BaseLib still uses the inline X86 assembly code
in C code files.For now, inline SetJump/LongJump() can be removed.
https://bugzilla.tianocore.org/show_bug.cgi?id=1163
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdePkg/Library/BaseLib/Ia32')
-rw-r--r-- | MdePkg/Library/BaseLib/Ia32/LongJump.c | 70 | ||||
-rw-r--r-- | MdePkg/Library/BaseLib/Ia32/SetJump.c | 95 |
2 files changed, 0 insertions, 165 deletions
diff --git a/MdePkg/Library/BaseLib/Ia32/LongJump.c b/MdePkg/Library/BaseLib/Ia32/LongJump.c deleted file mode 100644 index cf5fc5b..0000000 --- a/MdePkg/Library/BaseLib/Ia32/LongJump.c +++ /dev/null @@ -1,70 +0,0 @@ -/** @file
- Implementation of _LongJump() on IA-32.
-
- Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-
-#include "BaseLibInternals.h"
-
-
-/**
- Restores the CPU context that was saved with SetJump().
-
- Restores the CPU context from the buffer specified by JumpBuffer.
- This function never returns to the caller.
- Instead is resumes execution based on the state of JumpBuffer.
-
- @param JumpBuffer A pointer to CPU context buffer.
- @param Value The value to return when the SetJump() context is restored.
-
-**/
-__declspec (naked)
-VOID
-EFIAPI
-InternalLongJump (
- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
- IN UINTN Value
- )
-{
- _asm {
- mov eax, [PcdGet32 (PcdControlFlowEnforcementPropertyMask)]
- test eax, eax
- jz CetDone
- _emit 0x0F
- _emit 0x20
- _emit 0xE0 ; mov eax, cr4
- bt eax, 23 ; check if CET is enabled
- jnc CetDone
-
- mov edx, [esp + 4] ; edx = JumpBuffer
- mov edx, [edx + 24] ; edx = target SSP
- _emit 0xF3
- _emit 0x0F
- _emit 0x1E
- _emit 0xC8 ; READSSP EAX
- sub edx, eax ; edx = delta
- mov eax, edx ; eax = delta
-
- shr eax, 2 ; eax = delta/sizeof(UINT32)
- _emit 0xF3
- _emit 0x0F
- _emit 0xAE
- _emit 0xE8 ; INCSSP EAX
-
-CetDone:
-
- pop eax ; skip return address
- pop edx ; edx <- JumpBuffer
- pop eax ; eax <- Value
- mov ebx, [edx]
- mov esi, [edx + 4]
- mov edi, [edx + 8]
- mov ebp, [edx + 12]
- mov esp, [edx + 16]
- jmp dword ptr [edx + 20]
- }
-}
-
diff --git a/MdePkg/Library/BaseLib/Ia32/SetJump.c b/MdePkg/Library/BaseLib/Ia32/SetJump.c deleted file mode 100644 index 4a28490..0000000 --- a/MdePkg/Library/BaseLib/Ia32/SetJump.c +++ /dev/null @@ -1,95 +0,0 @@ -/** @file
- Implementation of SetJump() on IA-32.
-
- Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-
-#include "BaseLibInternals.h"
-
-/**
- Worker function that checks ASSERT condition for JumpBuffer
-
- Checks ASSERT condition for JumpBuffer.
-
- If JumpBuffer is NULL, then ASSERT().
- For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
-
- @param JumpBuffer A pointer to CPU context buffer.
-
-**/
-VOID
-EFIAPI
-InternalAssertJumpBuffer (
- IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
- );
-
-/**
- Saves the current CPU context that can be restored with a call to LongJump()
- and returns 0.
-
- Saves the current CPU context in the buffer specified by JumpBuffer and
- returns 0. The initial call to SetJump() must always return 0. Subsequent
- calls to LongJump() cause a non-zero value to be returned by SetJump().
-
- If JumpBuffer is NULL, then ASSERT().
- For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
-
- @param JumpBuffer A pointer to CPU context buffer.
-
- @retval 0 Indicates a return from SetJump().
-
-**/
-_declspec (naked)
-RETURNS_TWICE
-UINTN
-EFIAPI
-SetJump (
- OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
- )
-{
- _asm {
- push [esp + 4]
- call InternalAssertJumpBuffer
- pop ecx
- pop ecx
- mov edx, [esp]
-
- xor eax, eax
- mov [edx + 24], eax ; save 0 to SSP
-
- mov eax, [PcdGet32 (PcdControlFlowEnforcementPropertyMask)]
- test eax, eax
- jz CetDone
- _emit 0x0F
- _emit 0x20
- _emit 0xE0 ; mov eax, cr4
- bt eax, 23 ; check if CET is enabled
- jnc CetDone
-
- mov eax, 1
- _emit 0xF3
- _emit 0x0F
- _emit 0xAE
- _emit 0xE8 ; INCSSP EAX to read original SSP
- _emit 0xF3
- _emit 0x0F
- _emit 0x1E
- _emit 0xC8 ; READSSP EAX
- mov [edx + 0x24], eax ; save SSP
-
-CetDone:
-
- mov [edx], ebx
- mov [edx + 4], esi
- mov [edx + 8], edi
- mov [edx + 12], ebp
- mov [edx + 16], esp
- mov [edx + 20], ecx
- xor eax, eax
- jmp ecx
- }
-}
-
|