X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FLibrary%2FBaseLib%2FX64%2FLongJump.nasm;h=2b38ef0b25e39051b14d00b05a15bb0cf1001d04;hp=3bac27469e3a8f1108c218807e1ef986318e604e;hb=0aac2f777a688a146050bed47753e2dcf801d3c7;hpb=68edd7dbad77d7170ee0e1c5dbefae93ea9997b1 diff --git a/MdePkg/Library/BaseLib/X64/LongJump.nasm b/MdePkg/Library/BaseLib/X64/LongJump.nasm index 3bac27469e..2b38ef0b25 100644 --- a/MdePkg/Library/BaseLib/X64/LongJump.nasm +++ b/MdePkg/Library/BaseLib/X64/LongJump.nasm @@ -1,6 +1,6 @@ ;------------------------------------------------------------------------------ ; -; Copyright (c) 2006, Intel Corporation. All rights reserved.
+; Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
; This program and the accompanying materials ; are licensed and made available under the terms and conditions of the BSD License ; which accompanies this distribution. The full text of the license may be found at @@ -19,9 +19,13 @@ ; ;------------------------------------------------------------------------------ +%include "Nasm.inc" + DEFAULT REL SECTION .text +extern ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask)) + ;------------------------------------------------------------------------------ ; VOID ; EFIAPI @@ -32,6 +36,27 @@ ;------------------------------------------------------------------------------ global ASM_PFX(InternalLongJump) ASM_PFX(InternalLongJump): + + mov eax, [ASM_PFX(PcdGet32 (PcdControlFlowEnforcementPropertyMask))] + test eax, eax + jz CetDone + mov rax, cr4 + bt eax, 23 ; check if CET is enabled + jnc CetDone + + push rdx ; save rdx + + mov rdx, [rcx + 0xF8] ; rdx = target SSP + READSSP_RAX + sub rdx, rax ; rdx = delta + mov rax, rdx ; rax = delta + + shr rax, 3 ; rax = delta/sizeof(UINT64) + INCSSP_RAX + + pop rdx ; restore rdx +CetDone: + mov rbx, [rcx] mov rsp, [rcx + 8] mov rbp, [rcx + 0x10]