summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseLib/Ia32
diff options
context:
space:
mode:
authorJason <yun.lou@intel.com>2022-01-10 21:46:27 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-03-01 01:45:47 +0000
commitd3febfd9ade35dc552df6b3607c2b15d26b82867 (patch)
tree806b913dce388388defe7b703d282b3569570cfa /MdePkg/Library/BaseLib/Ia32
parent84338c0d498555f860a480693ee8647a1795fba3 (diff)
downloadedk2-d3febfd9ade35dc552df6b3607c2b15d26b82867.zip
edk2-d3febfd9ade35dc552df6b3607c2b15d26b82867.tar.gz
edk2-d3febfd9ade35dc552df6b3607c2b15d26b82867.tar.bz2
MdePkg: Replace Opcode with the corresponding instructions.
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3790 Replace Opcode with the corresponding instructions. The code changes have been verified with CompareBuild.py tool, which can be used to compare the results of two different EDK II builds to determine if they generate the same binaries. (tool link: https://github.com/mdkinney/edk2/tree/sandbox/CompareBuild) Signed-off-by: Jason Lou <yun.lou@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Diffstat (limited to 'MdePkg/Library/BaseLib/Ia32')
-rw-r--r--MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm20
-rw-r--r--MdePkg/Library/BaseLib/Ia32/LongJump.nasm6
-rw-r--r--MdePkg/Library/BaseLib/Ia32/Monitor.nasm4
-rw-r--r--MdePkg/Library/BaseLib/Ia32/Mwait.nasm4
-rw-r--r--MdePkg/Library/BaseLib/Ia32/RdRand.nasm13
-rw-r--r--MdePkg/Library/BaseLib/Ia32/ReadDr4.nasm6
-rw-r--r--MdePkg/Library/BaseLib/Ia32/ReadDr5.nasm6
-rw-r--r--MdePkg/Library/BaseLib/Ia32/SetJump.nasm6
-rw-r--r--MdePkg/Library/BaseLib/Ia32/WriteDr4.nasm6
-rw-r--r--MdePkg/Library/BaseLib/Ia32/WriteDr5.nasm6
10 files changed, 35 insertions, 42 deletions
diff --git a/MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm b/MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm
index 544e3c3..ef11458 100644
--- a/MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -44,16 +44,12 @@ ASM_PFX(InternalX86EnablePaging64):
mov cr0, eax ; enable paging
retf ; topmost 2 dwords hold the address
.0:
- DB 0x67, 0x48 ; 32-bit address size, 64-bit operand size
- mov ebx, [esp] ; mov rbx, [esp]
- DB 0x67, 0x48
- mov ecx, [esp + 8] ; mov rcx, [esp + 8]
- DB 0x67, 0x48
- mov edx, [esp + 0x10] ; mov rdx, [esp + 10h]
- DB 0x67, 0x48
- mov esp, [esp + 0x18] ; mov rsp, [esp + 18h]
- DB 0x48
- add esp, -0x20 ; add rsp, -20h
- call ebx ; call rbx
+BITS 64
+ mov rbx, [esp]
+ mov rcx, [esp + 8]
+ mov rdx, [esp + 0x10]
+ mov rsp, [esp + 0x18]
+ add rsp, -0x20
+ call rbx
hlt ; no one should get here
diff --git a/MdePkg/Library/BaseLib/Ia32/LongJump.nasm b/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
index f94d10f..6c13dfe 100644
--- a/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/LongJump.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -39,12 +39,12 @@ ASM_PFX(InternalLongJump):
mov edx, [esp + 4] ; edx = JumpBuffer
mov edx, [edx + 24] ; edx = target SSP
- READSSP_EAX
+ rdsspd eax
sub edx, eax ; edx = delta
mov eax, edx ; eax = delta
shr eax, 2 ; eax = delta/sizeof(UINT32)
- INCSSP_EAX
+ incsspd eax
CetDone:
diff --git a/MdePkg/Library/BaseLib/Ia32/Monitor.nasm b/MdePkg/Library/BaseLib/Ia32/Monitor.nasm
index 28dc0ba..70dbe66 100644
--- a/MdePkg/Library/BaseLib/Ia32/Monitor.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/Monitor.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -31,6 +31,6 @@ ASM_PFX(AsmMonitor):
mov eax, [esp + 4]
mov ecx, [esp + 8]
mov edx, [esp + 12]
- DB 0xf, 1, 0xc8 ; monitor
+ monitor
ret
diff --git a/MdePkg/Library/BaseLib/Ia32/Mwait.nasm b/MdePkg/Library/BaseLib/Ia32/Mwait.nasm
index 3956940..2d36a97 100644
--- a/MdePkg/Library/BaseLib/Ia32/Mwait.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/Mwait.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -29,6 +29,6 @@ global ASM_PFX(AsmMwait)
ASM_PFX(AsmMwait):
mov eax, [esp + 4]
mov ecx, [esp + 8]
- DB 0xf, 1, 0xc9 ; mwait
+ mwait
ret
diff --git a/MdePkg/Library/BaseLib/Ia32/RdRand.nasm b/MdePkg/Library/BaseLib/Ia32/RdRand.nasm
index e12b8e9..d818b6e 100644
--- a/MdePkg/Library/BaseLib/Ia32/RdRand.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/RdRand.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2015 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -25,9 +25,8 @@ SECTION .text
;------------------------------------------------------------------------------
global ASM_PFX(InternalX86RdRand16)
ASM_PFX(InternalX86RdRand16):
- ; rdrand ax ; generate a 16 bit RN into ax
+ rdrand eax ; generate a 16 bit RN into ax
; CF=1 if RN generated ok, otherwise CF=0
- db 0xf, 0xc7, 0xf0 ; rdrand r16: "0f c7 /6 ModRM:r/m(w)"
jc rn16_ok ; jmp if CF=1
xor eax, eax ; reg=0 if CF=0
ret ; return with failure status
@@ -45,9 +44,8 @@ rn16_ok:
;------------------------------------------------------------------------------
global ASM_PFX(InternalX86RdRand32)
ASM_PFX(InternalX86RdRand32):
- ; rdrand eax ; generate a 32 bit RN into eax
+ rdrand eax ; generate a 32 bit RN into eax
; CF=1 if RN generated ok, otherwise CF=0
- db 0xf, 0xc7, 0xf0 ; rdrand r32: "0f c7 /6 ModRM:r/m(w)"
jc rn32_ok ; jmp if CF=1
xor eax, eax ; reg=0 if CF=0
ret ; return with failure status
@@ -65,14 +63,13 @@ rn32_ok:
;------------------------------------------------------------------------------
global ASM_PFX(InternalX86RdRand64)
ASM_PFX(InternalX86RdRand64):
- ; rdrand eax ; generate a 32 bit RN into eax
+ rdrand eax ; generate a 32 bit RN into eax
; CF=1 if RN generated ok, otherwise CF=0
- db 0xf, 0xc7, 0xf0 ; rdrand r32: "0f c7 /6 ModRM:r/m(w)"
jnc rn64_ret ; jmp if CF=0
mov edx, dword [esp + 4]
mov [edx], eax
- db 0xf, 0xc7, 0xf0 ; generate another 32 bit RN
+ rdrand eax ; generate another 32 bit RN
jnc rn64_ret ; jmp if CF=0
mov [edx + 4], eax
diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr4.nasm b/MdePkg/Library/BaseLib/Ia32/ReadDr4.nasm
index 81c681d..1c312b6 100644
--- a/MdePkg/Library/BaseLib/Ia32/ReadDr4.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/ReadDr4.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -31,8 +31,8 @@ ASM_PFX(AsmReadDr4):
; this register will cause a #UD exception.
;
; MS assembler doesn't support this instruction since no one would use it
- ; under normal circustances. Here opcode is used.
+ ; under normal circustances.
;
- DB 0xf, 0x21, 0xe0
+ mov eax, dr4
ret
diff --git a/MdePkg/Library/BaseLib/Ia32/ReadDr5.nasm b/MdePkg/Library/BaseLib/Ia32/ReadDr5.nasm
index e2deacb..07a1b44 100644
--- a/MdePkg/Library/BaseLib/Ia32/ReadDr5.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/ReadDr5.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -31,8 +31,8 @@ ASM_PFX(AsmReadDr5):
; this register will cause a #UD exception.
;
; MS assembler doesn't support this instruction since no one would use it
- ; under normal circustances. Here opcode is used.
+ ; under normal circustances.
;
- DB 0xf, 0x21, 0xe8
+ mov eax, dr5
ret
diff --git a/MdePkg/Library/BaseLib/Ia32/SetJump.nasm b/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
index 364613b..2577373 100644
--- a/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/SetJump.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -46,8 +46,8 @@ ASM_PFX(SetJump):
jnc CetDone
mov eax, 1
- INCSSP_EAX ; to read original SSP
- READSSP_EAX
+ incsspd eax ; to read original SSP
+ rdsspd eax
mov [edx + 0x24], eax ; save SSP
CetDone:
diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr4.nasm b/MdePkg/Library/BaseLib/Ia32/WriteDr4.nasm
index 0d23fca..b8479b3 100644
--- a/MdePkg/Library/BaseLib/Ia32/WriteDr4.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/WriteDr4.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -32,8 +32,8 @@ ASM_PFX(AsmWriteDr4):
; this register will cause a #UD exception.
;
; MS assembler doesn't support this instruction since no one would use it
- ; under normal circustances. Here opcode is used.
+ ; under normal circustances.
;
- DB 0xf, 0x23, 0xe0
+ mov dr4, eax
ret
diff --git a/MdePkg/Library/BaseLib/Ia32/WriteDr5.nasm b/MdePkg/Library/BaseLib/Ia32/WriteDr5.nasm
index bc5f424..3545561 100644
--- a/MdePkg/Library/BaseLib/Ia32/WriteDr5.nasm
+++ b/MdePkg/Library/BaseLib/Ia32/WriteDr5.nasm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
; SPDX-License-Identifier: BSD-2-Clause-Patent
;
; Module Name:
@@ -32,8 +32,8 @@ ASM_PFX(AsmWriteDr5):
; this register will cause a #UD exception.
;
; MS assembler doesn't support this instruction since no one would use it
- ; under normal circustances. Here opcode is used.
+ ; under normal circustances.
;
- DB 0xf, 0x23, 0xe8
+ mov dr5, eax
ret