[edk2-devel] [PATCH v6 6/6] MdePkg: Use macro CR4_CET_BIT to replace hard code value.

Sheng Wei posted 6 patches 2 years, 2 months ago
There is a newer version of this series
[edk2-devel] [PATCH v6 6/6] MdePkg: Use macro CR4_CET_BIT to replace hard code value.
Posted by Sheng Wei 2 years, 2 months ago
The macro is used in file LongJump.nasm and SetJump.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: Laszlo Ersek <lersek@redhat.com>
---
 MdePkg/Library/BaseLib/Ia32/LongJump.nasm | 3 ++-
 MdePkg/Library/BaseLib/Ia32/SetJump.nasm  | 3 ++-
 MdePkg/Library/BaseLib/X64/LongJump.nasm  | 3 ++-
 MdePkg/Library/BaseLib/X64/SetJump.nasm   | 3 ++-
 4 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/BaseLib/Ia32/LongJump.nasm b/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
index 6c13dfe307..df1bf9749e 100644
--- a/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
@@ -14,6 +14,7 @@
 ;------------------------------------------------------------------------------
 
 %include "Nasm.inc"
+%include "Cet.inc"
 
     SECTION .text
 
@@ -34,7 +35,7 @@ ASM_PFX(InternalLongJump):
     test    eax, eax
     jz      CetDone
     mov     eax, cr4
-    bt      eax, 23                ; check if CET is enabled
+    bt      eax, CR4_CET_BIT       ; check if CET is enabled
     jnc     CetDone
 
     mov     edx, [esp + 4]         ; edx = JumpBuffer
diff --git a/MdePkg/Library/BaseLib/Ia32/SetJump.nasm b/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
index 2577373241..0c484f6852 100644
--- a/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
@@ -14,6 +14,7 @@
 ;------------------------------------------------------------------------------
 
 %include "Nasm.inc"
+%include "Cet.inc"
 
     SECTION .text
 
@@ -42,7 +43,7 @@ ASM_PFX(SetJump):
     test    eax, eax
     jz      CetDone
     mov     eax, cr4
-    bt      eax, 23                ; check if CET is enabled
+    bt      eax, CR4_CET_BIT       ; check if CET is enabled
     jnc     CetDone
 
     mov     eax, 1
diff --git a/MdePkg/Library/BaseLib/X64/LongJump.nasm b/MdePkg/Library/BaseLib/X64/LongJump.nasm
index 2002f65cba..021b49e855 100644
--- a/MdePkg/Library/BaseLib/X64/LongJump.nasm
+++ b/MdePkg/Library/BaseLib/X64/LongJump.nasm
@@ -14,6 +14,7 @@
 ;------------------------------------------------------------------------------
 
 %include "Nasm.inc"
+%include "Cet.inc"
 
     DEFAULT REL
     SECTION .text
@@ -35,7 +36,7 @@ ASM_PFX(InternalLongJump):
     test    eax, eax
     jz      CetDone
     mov     rax, cr4
-    bt      eax, 23                      ; check if CET is enabled
+    bt      eax, CR4_CET_BIT             ; check if CET is enabled
     jnc     CetDone
 
     push    rdx                          ; save rdx
diff --git a/MdePkg/Library/BaseLib/X64/SetJump.nasm b/MdePkg/Library/BaseLib/X64/SetJump.nasm
index 5943a5ebe5..d2c0991e66 100644
--- a/MdePkg/Library/BaseLib/X64/SetJump.nasm
+++ b/MdePkg/Library/BaseLib/X64/SetJump.nasm
@@ -14,6 +14,7 @@
 ;------------------------------------------------------------------------------
 
 %include "Nasm.inc"
+%include "Cet.inc"
 
     DEFAULT REL
     SECTION .text
@@ -44,7 +45,7 @@ ASM_PFX(SetJump):
     test    eax, eax
     jz      CetDone
     mov     rax, cr4
-    bt      eax, 23                      ; check if CET is enabled
+    bt      eax, CR4_CET_BIT             ; check if CET is enabled
     jnc     CetDone
 
     mov     rax, 1
-- 
2.26.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111520): https://edk2.groups.io/g/devel/message/111520
Mute This Topic: https://groups.io/mt/102724277/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v6 6/6] MdePkg: Use macro CR4_CET_BIT to replace hard code value.
Posted by Ni, Ray 2 years, 2 months ago
Reviewed-by: Ray Ni <ray.ni@intel.com>

Thanks,
Ray
> -----Original Message-----
> From: Sheng, W <w.sheng@intel.com>
> Sent: Tuesday, November 21, 2023 3:03 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric <eric.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Laszlo
> Ersek <lersek@redhat.com>; Wu, Jiaxin <jiaxin.wu@intel.com>; Tan, Dun
> <dun.tan@intel.com>
> Subject: [PATCH v6 6/6] MdePkg: Use macro CR4_CET_BIT to replace hard
> code value.
> 
> The macro is used in file LongJump.nasm and SetJump.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: Laszlo Ersek <lersek@redhat.com>
> ---
>  MdePkg/Library/BaseLib/Ia32/LongJump.nasm | 3 ++-
>  MdePkg/Library/BaseLib/Ia32/SetJump.nasm  | 3 ++-
>  MdePkg/Library/BaseLib/X64/LongJump.nasm  | 3 ++-
>  MdePkg/Library/BaseLib/X64/SetJump.nasm   | 3 ++-
>  4 files changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
> b/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
> index 6c13dfe307..df1bf9749e 100644
> --- a/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
> +++ b/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
> @@ -14,6 +14,7 @@
>  ;------------------------------------------------------------------------------
> 
> 
> 
>  %include "Nasm.inc"
> 
> +%include "Cet.inc"
> 
> 
> 
>      SECTION .text
> 
> 
> 
> @@ -34,7 +35,7 @@ ASM_PFX(InternalLongJump):
>      test    eax, eax
> 
>      jz      CetDone
> 
>      mov     eax, cr4
> 
> -    bt      eax, 23                ; check if CET is enabled
> 
> +    bt      eax, CR4_CET_BIT       ; check if CET is enabled
> 
>      jnc     CetDone
> 
> 
> 
>      mov     edx, [esp + 4]         ; edx = JumpBuffer
> 
> diff --git a/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
> b/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
> index 2577373241..0c484f6852 100644
> --- a/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
> +++ b/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
> @@ -14,6 +14,7 @@
>  ;------------------------------------------------------------------------------
> 
> 
> 
>  %include "Nasm.inc"
> 
> +%include "Cet.inc"
> 
> 
> 
>      SECTION .text
> 
> 
> 
> @@ -42,7 +43,7 @@ ASM_PFX(SetJump):
>      test    eax, eax
> 
>      jz      CetDone
> 
>      mov     eax, cr4
> 
> -    bt      eax, 23                ; check if CET is enabled
> 
> +    bt      eax, CR4_CET_BIT       ; check if CET is enabled
> 
>      jnc     CetDone
> 
> 
> 
>      mov     eax, 1
> 
> diff --git a/MdePkg/Library/BaseLib/X64/LongJump.nasm
> b/MdePkg/Library/BaseLib/X64/LongJump.nasm
> index 2002f65cba..021b49e855 100644
> --- a/MdePkg/Library/BaseLib/X64/LongJump.nasm
> +++ b/MdePkg/Library/BaseLib/X64/LongJump.nasm
> @@ -14,6 +14,7 @@
>  ;------------------------------------------------------------------------------
> 
> 
> 
>  %include "Nasm.inc"
> 
> +%include "Cet.inc"
> 
> 
> 
>      DEFAULT REL
> 
>      SECTION .text
> 
> @@ -35,7 +36,7 @@ ASM_PFX(InternalLongJump):
>      test    eax, eax
> 
>      jz      CetDone
> 
>      mov     rax, cr4
> 
> -    bt      eax, 23                      ; check if CET is enabled
> 
> +    bt      eax, CR4_CET_BIT             ; check if CET is enabled
> 
>      jnc     CetDone
> 
> 
> 
>      push    rdx                          ; save rdx
> 
> diff --git a/MdePkg/Library/BaseLib/X64/SetJump.nasm
> b/MdePkg/Library/BaseLib/X64/SetJump.nasm
> index 5943a5ebe5..d2c0991e66 100644
> --- a/MdePkg/Library/BaseLib/X64/SetJump.nasm
> +++ b/MdePkg/Library/BaseLib/X64/SetJump.nasm
> @@ -14,6 +14,7 @@
>  ;------------------------------------------------------------------------------
> 
> 
> 
>  %include "Nasm.inc"
> 
> +%include "Cet.inc"
> 
> 
> 
>      DEFAULT REL
> 
>      SECTION .text
> 
> @@ -44,7 +45,7 @@ ASM_PFX(SetJump):
>      test    eax, eax
> 
>      jz      CetDone
> 
>      mov     rax, cr4
> 
> -    bt      eax, 23                      ; check if CET is enabled
> 
> +    bt      eax, CR4_CET_BIT             ; check if CET is enabled
> 
>      jnc     CetDone
> 
> 
> 
>      mov     rax, 1
> 
> --
> 2.26.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111530): https://edk2.groups.io/g/devel/message/111530
Mute This Topic: https://groups.io/mt/102724277/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-