summaryrefslogtreecommitdiff
path: root/UefiCpuPkg/PiSmmCpuDxeSmm/X64
diff options
context:
space:
mode:
authorYao, Jiewen <jiewen.yao@intel.com>2015-11-25 08:51:15 +0000
committerjyao1 <jyao1@Edk2>2015-11-25 08:51:15 +0000
commitf45f2d4ad4d803eb33c608bca8242992f1841fec (patch)
treebe1c3e7e9487cf8deb505a87b076bb64329bb952 /UefiCpuPkg/PiSmmCpuDxeSmm/X64
parent0b256fb1dd7ca267d6e448768e519f54f97f347a (diff)
downloadedk2-platforms-f45f2d4ad4d803eb33c608bca8242992f1841fec.tar.xz
Move SmmDebug feature from ASM to C.
SmmDebug feature is implemented in ASM, which is not easy to maintain. So we move it to C function. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: "Yao, Jiewen" <jiewen.yao@intel.com> Reviewed-by: "Kinney, Michael D" <michael.d.kinney@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18946 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'UefiCpuPkg/PiSmmCpuDxeSmm/X64')
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S39
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm47
2 files changed, 28 insertions, 58 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
index 95e6dfa814..b488b74b70 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.S
@@ -24,7 +24,6 @@ ASM_GLOBAL ASM_PFX(gcSmiHandlerSize)
ASM_GLOBAL ASM_PFX(gSmiCr3)
ASM_GLOBAL ASM_PFX(gSmiStack)
ASM_GLOBAL ASM_PFX(gSmbase)
-ASM_GLOBAL ASM_PFX(FeaturePcdGet (PcdCpuSmmDebug))
ASM_GLOBAL ASM_PFX(gSmiHandlerIdtr)
#
@@ -163,20 +162,7 @@ LongMode: # long mode (64-bit code) starts here
# jmp _SmiHandler ; instruction is not needed
_SmiHandler:
- movabsq $ASM_PFX(FeaturePcdGet (PcdCpuSmmDebug)), %rax
- cmpb $0, (%rax)
- jz L1
-
- .byte 0x48, 0x8b, 0x0d # mov rcx, [rip + disp32]
- .long SSM_DR6 - (. + 4 - _SmiEntryPoint + 0x8000)
- .byte 0x48, 0x8b, 0x15 # mov rdx, [rip + disp32]
- .long SSM_DR7 - (. + 4 - _SmiEntryPoint + 0x8000)
- movq %rcx, %dr6
- movq %rdx, %dr7
-L1:
-
- movabsq $ASM_PFX(SmiRendezvous), %rax
- movq (%rsp), %rcx
+ movq (%rsp), %rbx
# Save FP registers
subq $0x208, %rsp
@@ -184,7 +170,19 @@ L1:
fxsave (%rsp)
addq $-0x20, %rsp
+
+ movq %rbx, %rcx
+ movabsq $ASM_PFX(CpuSmmDebugEntry), %rax
call *%rax
+
+ movq %rbx, %rcx
+ movabsq $ASM_PFX(SmiRendezvous), %rax
+ call *%rax
+
+ movq %rbx, %rcx
+ movabsq $ASM_PFX(CpuSmmDebugExit), %rax
+ call *%rax
+
addq $0x20, %rsp
#
@@ -193,17 +191,6 @@ L1:
.byte 0x48 # FXRSTOR64
fxrstor (%rsp)
- movabsq $ASM_PFX(FeaturePcdGet (PcdCpuSmmDebug)), %rax
- cmpb $0, (%rax)
- jz L2
-
- movq %dr7, %rdx
- movq %dr6, %rcx
- .byte 0x48, 0x89, 0x15 # mov [rip + disp32], rdx
- .long SSM_DR7 - (. + 4 - _SmiEntryPoint + 0x8000)
- .byte 0x48, 0x89, 0x0d # mov [rip + disp32], rcx
- .long SSM_DR6 - (. + 4 - _SmiEntryPoint + 0x8000)
-L2:
rsm
ASM_PFX(gcSmiHandlerSize): .word . - _SmiEntryPoint
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
index 4d53db5b00..4f5c03c5cf 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.asm
@@ -22,12 +22,13 @@
; Variables referenced by C code
;
EXTERNDEF SmiRendezvous:PROC
+EXTERNDEF CpuSmmDebugEntry:PROC
+EXTERNDEF CpuSmmDebugExit:PROC
EXTERNDEF gcSmiHandlerTemplate:BYTE
EXTERNDEF gcSmiHandlerSize:WORD
EXTERNDEF gSmiCr3:DWORD
EXTERNDEF gSmiStack:DWORD
EXTERNDEF gSmbase:DWORD
-EXTERNDEF FeaturePcdGet (PcdCpuSmmDebug):BYTE
EXTERNDEF gSmiHandlerIdtr:FWORD
@@ -157,26 +158,7 @@ Base:
; jmp _SmiHandler ; instruction is not needed
_SmiHandler:
-;
-; The following lines restore DR6 & DR7 before running C code. They are useful
-; when you want to enable hardware breakpoints in SMM.
-;
-; NOTE: These lines might not be appreciated in runtime since they might
-; conflict with OS debugging facilities. Turn them off in RELEASE.
-;
- mov rax, offset FeaturePcdGet (PcdCpuSmmDebug) ;Get absolute address. Avoid RIP relative addressing
- cmp byte ptr [rax], 0
- jz @1
-
- DB 48h, 8bh, 0dh ; mov rcx, [rip + disp32]
- DD SSM_DR6 - ($ + 4 - _SmiEntryPoint + 8000h)
- DB 48h, 8bh, 15h ; mov rdx, [rip + disp32]
- DD SSM_DR7 - ($ + 4 - _SmiEntryPoint + 8000h)
- mov dr6, rcx
- mov dr7, rdx
-@1:
- mov rcx, [rsp] ; rcx <- CpuIndex
- mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous
+ mov rbx, [rsp] ; rbx <- CpuIndex
;
; Save FP registers
@@ -186,7 +168,19 @@ _SmiHandler:
fxsave [rsp]
add rsp, -20h
+
+ mov rcx, rbx
+ mov rax, CpuSmmDebugEntry
+ call rax
+
+ mov rcx, rbx
+ mov rax, SmiRendezvous ; rax <- absolute addr of SmiRedezvous
+ call rax
+
+ mov rcx, rbx
+ mov rax, CpuSmmDebugExit
call rax
+
add rsp, 20h
;
@@ -195,17 +189,6 @@ _SmiHandler:
DB 48h ; FXRSTOR64
fxrstor [rsp]
- mov rax, offset FeaturePcdGet (PcdCpuSmmDebug) ;Get absolute address. Avoid RIP relative addressing
- cmp byte ptr [rax], 0
- jz @2
-
- mov rdx, dr7
- mov rcx, dr6
- DB 48h, 89h, 15h ; mov [rip + disp32], rdx
- DD SSM_DR7 - ($ + 4 - _SmiEntryPoint + 8000h)
- DB 48h, 89h, 0dh ; mov [rip + disp32], rcx
- DD SSM_DR6 - ($ + 4 - _SmiEntryPoint + 8000h)
-@2:
rsm
gcSmiHandlerSize DW $ - _SmiEntryPoint