UefiCpuPkg: Use macro CR4_CET_BIT to replace hard code value in Cet.nasm.

Signed-off-by: Sheng Wei <w.sheng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Tan Dun <dun.tan@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
Sheng Wei 2023-11-09 16:21:06 +08:00 committed by mergify[bot]
parent b5f20eca8a
commit 04d47a9bf0
2 changed files with 8 additions and 6 deletions

View File

@ -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 ; SPDX-License-Identifier: BSD-2-Clause-Patent
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "Nasm.inc" %include "Nasm.inc"
%include "Cet.inc"
SECTION .text SECTION .text
@ -16,7 +17,7 @@ ASM_PFX(DisableCet):
incsspd eax incsspd eax
mov eax, cr4 mov eax, cr4
btr eax, 23 ; clear CET btr eax, CR4_CET_BIT ; clear CET
mov cr4, eax mov cr4, eax
ret ret
@ -24,7 +25,7 @@ global ASM_PFX(EnableCet)
ASM_PFX(EnableCet): ASM_PFX(EnableCet):
mov eax, cr4 mov eax, cr4
bts eax, 23 ; set CET bts eax, CR4_CET_BIT ; set CET
mov cr4, eax mov cr4, eax
; use jmp to skip the check for ret ; use jmp to skip the check for ret

View File

@ -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 ; SPDX-License-Identifier: BSD-2-Clause-Patent
; ;
;------------------------------------------------------------------------------- ;-------------------------------------------------------------------------------
%include "Nasm.inc" %include "Nasm.inc"
%include "Cet.inc"
DEFAULT REL DEFAULT REL
SECTION .text SECTION .text
@ -17,7 +18,7 @@ ASM_PFX(DisableCet):
incsspq rax incsspq rax
mov rax, cr4 mov rax, cr4
btr eax, 23 ; clear CET btr eax, CR4_CET_BIT ; clear CET
mov cr4, rax mov cr4, rax
ret ret
@ -25,7 +26,7 @@ global ASM_PFX(EnableCet)
ASM_PFX(EnableCet): ASM_PFX(EnableCet):
mov rax, cr4 mov rax, cr4
bts eax, 23 ; set CET bts eax, CR4_CET_BIT ; set CET
mov cr4, rax mov cr4, rax
; use jmp to skip the check for ret ; use jmp to skip the check for ret