Use rsp instead of esp to save 64-bit stack pointer.
authorElvin Li <elvin.li@intel.com>
Tue, 29 Oct 2013 06:52:25 +0000 (06:52 +0000)
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 29 Oct 2013 06:52:25 +0000 (06:52 +0000)
Signed-off-by: Elvin Li <elvin.li@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14812 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BaseLib/X64/Thunk16.S
MdePkg/Library/BaseLib/X64/Thunk16.asm

index a521aff..f592a28 100644 (file)
@@ -146,8 +146,8 @@ L_64Eip:    .space      4
 L_SavedCs:  .space      2\r
 L_64BitCode:\r
     .byte   0x90\r
-    .byte   0x67,0xbc                  # mov esp, imm32\r
-L_SavedSp:  .space      4              # restore stack\r
+    .byte   0x48,0xbc                  # mov rsp, imm64\r
+L_SavedSp:  .space      8              # restore stack\r
     nop\r
     ret\r
 \r
@@ -307,7 +307,7 @@ ASM_PFX(InternalAsmThunk16):
     pushq   %r8\r
     movl    %cs, %r8d\r
     movw    %r8w, (L_SavedCs - L_SavedCr4)(%rcx)\r
-    movl    %esp, (L_SavedSp - L_SavedCr4)(%rcx)\r
+    movq    %rsp, (L_SavedSp - L_SavedCr4)(%rcx)\r
     .byte   0xff, 0x69                  #  jmp (_EntryPoint - L_SavedCr4)(%rcx)\r
     .set    Ltemp1, _EntryPoint - L_SavedCr4\r
     .byte   Ltemp1\r
index 0105134..e01de27 100644 (file)
@@ -142,8 +142,8 @@ SavedCr0    DD      ?
 SavedCs     DW      ?\r
 @64BitCode:\r
     db      090h \r
-    db      067h, 0bch                 ; mov esp, imm32\r
-SavedSp     DD   ?                     ; restore stack\r
+    db      048h, 0bch                 ; mov rsp, imm64\r
+SavedSp     DQ   ?                     ; restore stack\r
     nop\r
     ret\r
 _BackFromUserCode   ENDP\r
@@ -294,7 +294,7 @@ InternalAsmThunk16  PROC    USES    rbp rbx rsi rdi
     push    r8\r
     mov     r8d, cs\r
     mov     [rcx + (SavedCs - SavedCr4)], r8w\r
-    mov     [rcx + (SavedSp - SavedCr4)], esp\r
+    mov     [rcx + (SavedSp - SavedCr4)], rsp\r
     jmp     fword ptr [rcx + (_EntryPoint - SavedCr4)]\r
 @RetFromRealMode:\r
     popfq\r