Skip to content

Commit

Permalink
UefiCpuPkg: Use macro CR4_CET_BIT to replace hard code value in Cet.n…
Browse files Browse the repository at this point in the history
…asm.

Signed-off-by: Sheng Wei <[email protected]>
Cc: Eric Dong <[email protected]>
Cc: Ray Ni <[email protected]>
Cc: Laszlo Ersek <[email protected]>
Cc: Wu Jiaxin <[email protected]>
Cc: Tan Dun <[email protected]>
Reviewed-by: Ray Ni <[email protected]>
  • Loading branch information
swei22 authored and mergify[bot] committed Dec 7, 2023
1 parent b5f20ec commit 04d47a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/Cet.nasm
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
;------------------------------------------------------------------------------ ;
; Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
; Copyright (c) 2019 - 2023, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
;-------------------------------------------------------------------------------

%include "Nasm.inc"
%include "Cet.inc"

SECTION .text

Expand All @@ -16,15 +17,15 @@ ASM_PFX(DisableCet):
incsspd eax

mov eax, cr4
btr eax, 23 ; clear CET
btr eax, CR4_CET_BIT ; clear CET
mov cr4, eax
ret

global ASM_PFX(EnableCet)
ASM_PFX(EnableCet):

mov eax, cr4
bts eax, 23 ; set CET
bts eax, CR4_CET_BIT ; set CET
mov cr4, eax

; use jmp to skip the check for ret
Expand Down
7 changes: 4 additions & 3 deletions UefiCpuPkg/PiSmmCpuDxeSmm/X64/Cet.nasm
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
;------------------------------------------------------------------------------ ;
; Copyright (c) 2019 - 2022, Intel Corporation. All rights reserved.<BR>
; Copyright (c) 2019 - 2023, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
;-------------------------------------------------------------------------------

%include "Nasm.inc"
%include "Cet.inc"

DEFAULT REL
SECTION .text
Expand All @@ -17,15 +18,15 @@ ASM_PFX(DisableCet):
incsspq rax

mov rax, cr4
btr eax, 23 ; clear CET
btr eax, CR4_CET_BIT ; clear CET
mov cr4, rax
ret

global ASM_PFX(EnableCet)
ASM_PFX(EnableCet):

mov rax, cr4
bts eax, 23 ; set CET
bts eax, CR4_CET_BIT ; set CET
mov cr4, rax

; use jmp to skip the check for ret
Expand Down

0 comments on commit 04d47a9

Please sign in to comment.