]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Cet.nasm
UefiCpuPkg/PiSmmCpu: Add Shadow Stack Support for X86 SMM.
[mirror_edk2.git] / UefiCpuPkg / PiSmmCpuDxeSmm / Ia32 / 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 SECTION .text
16
17 global ASM_PFX(DisableCet)
18 ASM_PFX(DisableCet):
19
20 ; Skip the pushed data for call
21 mov eax, 1
22 INCSSP_EAX
23
24 mov eax, cr4
25 btr eax, 23 ; clear CET
26 mov cr4, eax
27 ret
28
29 global ASM_PFX(EnableCet)
30 ASM_PFX(EnableCet):
31
32 mov eax, cr4
33 bts eax, 23 ; set CET
34 mov cr4, eax
35
36 ; use jmp to skip the check for ret
37 pop eax
38 jmp eax
39