]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg PiSmmCpuDxeSmm: Update SmiEntry function run the same position
authorLiming Gao <liming.gao@intel.com>
Fri, 21 Sep 2018 00:56:01 +0000 (08:56 +0800)
committerLiming Gao <liming.gao@intel.com>
Tue, 25 Sep 2018 00:25:41 +0000 (08:25 +0800)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1191

Before commit e21e355e2ca7fefb15b4df7078f995d3fb9c2b89, jmp _SmiHandler
is commented. And below code, ASM_PFX(CpuSmmDebugEntry) is moved into rax,
then call it. But, this code doesn't work in XCODE5 tool chain. Because XCODE5
doesn't generated the absolute address in the EFI image. So, rax stores the
relative address. Once this logic is moved to another place, it will not work.
;   jmp     _SmiHandler                 ; instruction is not needed
...
    mov     rax, ASM_PFX(CpuSmmDebugEntry)
    call    rax

Commit e21e355e2ca7fefb15b4df7078f995d3fb9c2b89 is to support XCODE5.
One tricky way is selected to fix it. Although SmiEntry logic is copied to
another place and run, but here jmp _SmiHandler is enabled to jmp the original
code place, then call ASM_PFX(CpuSmmDebugEntry) with the relative address.
    mov     rax, strict qword 0         ;   mov     rax, _SmiHandler
_SmiHandlerAbsAddr:
    jmp     rax
...
    call    ASM_PFX(CpuSmmDebugEntry)

Now, BZ 1191 raises the issue that SmiHandler should run in the copied address,
can't run in the common address. So, jmp _SmiHandler is required to be removed,
the code is kept to run in copied address. And, the relative address is
requried to be fixed up to the absolute address. The necessary changes should
not affect the behavior of platforms that already consume PiSmmCpuDxeSmm.
OVMF SMM boot to shell with VS2017, GCC5 and XCODE5 tool chain has been verified.
...
    mov     rax, strict qword 0         ;   call    ASM_PFX(CpuSmmDebugEntry)
CpuSmmDebugEntryAbsAddr:
    call    rax

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmiEntry.nasm

index 315d0f8670757f6cdb93e5a5d0ace0c03971cb10..414b5ab5fa9e014a5aaa9534c10c3c6588323733 100644 (file)
@@ -173,9 +173,6 @@ SmiHandlerIdtrAbsAddr:
     mov     gs, eax\r
     mov     ax, [rbx + DSC_SS]\r
     mov     ss, eax\r
-    mov     rax, strict qword 0         ;   mov     rax, _SmiHandler\r
-_SmiHandlerAbsAddr:\r
-    jmp     rax\r
 \r
 _SmiHandler:\r
     mov     rbx, [rsp + 0x8]             ; rcx <- CpuIndex\r
@@ -189,13 +186,19 @@ _SmiHandler:
     add     rsp, -0x20\r
 \r
     mov     rcx, rbx\r
-    call    ASM_PFX(CpuSmmDebugEntry)\r
+    mov     rax, strict qword 0         ;   call    ASM_PFX(CpuSmmDebugEntry)\r
+CpuSmmDebugEntryAbsAddr:\r
+    call    rax\r
 \r
     mov     rcx, rbx\r
-    call    ASM_PFX(SmiRendezvous)\r
+    mov     rax, strict qword 0         ;   call    ASM_PFX(SmiRendezvous)\r
+SmiRendezvousAbsAddr:\r
+    call    rax\r
 \r
     mov     rcx, rbx\r
-    call    ASM_PFX(CpuSmmDebugExit)\r
+    mov     rax, strict qword 0         ;   call    ASM_PFX(CpuSmmDebugExit)\r
+CpuSmmDebugExitAbsAddr:\r
+    call    rax\r
 \r
     add     rsp, 0x20\r
 \r
@@ -206,7 +209,8 @@ _SmiHandler:
 \r
     add     rsp, 0x200\r
 \r
-    lea     rax, [ASM_PFX(mXdSupported)]\r
+    mov     rax, strict qword 0         ;       lea     rax, [ASM_PFX(mXdSupported)]\r
+mXdSupportedAbsAddr:\r
     mov     al, [rax]\r
     cmp     al, 0\r
     jz      .1\r
@@ -224,13 +228,33 @@ _SmiHandler:
 \r
 ASM_PFX(gcSmiHandlerSize)    DW      $ - _SmiEntryPoint\r
 \r
+;\r
+; Retrieve the address and fill it into mov opcode.\r
+;\r
+; It is called in the driver entry point first.\r
+; It is used to fix up the real address in mov opcode.\r
+; Then, after the code logic is copied to the different location,\r
+; the code can also run.\r
+;\r
 global ASM_PFX(PiSmmCpuSmiEntryFixupAddress)\r
 ASM_PFX(PiSmmCpuSmiEntryFixupAddress):\r
     lea    rax, [ASM_PFX(gSmiHandlerIdtr)]\r
     lea    rcx, [SmiHandlerIdtrAbsAddr]\r
     mov    qword [rcx - 8], rax\r
 \r
-    lea    rax, [_SmiHandler]\r
-    lea    rcx, [_SmiHandlerAbsAddr]\r
+    lea    rax, [ASM_PFX(CpuSmmDebugEntry)]\r
+    lea    rcx, [CpuSmmDebugEntryAbsAddr]\r
+    mov    qword [rcx - 8], rax\r
+\r
+    lea    rax, [ASM_PFX(SmiRendezvous)]\r
+    lea    rcx, [SmiRendezvousAbsAddr]\r
+    mov    qword [rcx - 8], rax\r
+\r
+    lea    rax, [ASM_PFX(CpuSmmDebugExit)]\r
+    lea    rcx, [CpuSmmDebugExitAbsAddr]\r
+    mov    qword [rcx - 8], rax\r
+\r
+    lea    rax, [ASM_PFX(mXdSupported)]\r
+    lea    rcx, [mXdSupportedAbsAddr]\r
     mov    qword [rcx - 8], rax\r
     ret\r