]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/PiSmmCpuDxeSmm/X64/Cet.nasm
UefiCpuPkg/PiSmmCpu: Add Shadow Stack Support for X86 SMM.
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / X64 / Cet.nasm
1 ;------------------------------------------------------------------------------ ;
2 ; Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
3 ; This program and the accompanying materials
4 ; are licensed and made available under the terms and conditions of the BSD License
5 ; which accompanies this distribution. The full text of the license may be found at
6 ; http://opensource.org/licenses/bsd-license.php.
7 ;
8 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
10 ;
11 ;-------------------------------------------------------------------------------
12
13 %include "Nasm.inc"
14
15 DEFAULT REL
16 SECTION .text
17
18 global ASM_PFX(DisableCet)
19 ASM_PFX(DisableCet):
20
21 ; Skip the pushed data for call
22 mov rax, 1
23 INCSSP_RAX
24
25 mov rax, cr4
26 btr eax, 23 ; clear CET
27 mov cr4, rax
28 ret
29
30 global ASM_PFX(EnableCet)
31 ASM_PFX(EnableCet):
32
33 mov rax, cr4
34 bts eax, 23 ; set CET
35 mov cr4, rax
36
37 ; use jmp to skip the check for ret
38 pop rax
39 jmp rax
40