From ce4c0e31b039cc9948ba06bbaca9d240d70aa7ee Mon Sep 17 00:00:00 2001 From: klu2 Date: Fri, 5 Jun 2009 11:21:48 +0000 Subject: [PATCH] Fix the bug that if code is run above 4G, AsmDisablePaging64 will be failure. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8478 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/BaseLib/X64/DisablePaging64.asm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/BaseLib/X64/DisablePaging64.asm b/MdePkg/Library/BaseLib/X64/DisablePaging64.asm index f11f6ff291..502a54c4e5 100644 --- a/MdePkg/Library/BaseLib/X64/DisablePaging64.asm +++ b/MdePkg/Library/BaseLib/X64/DisablePaging64.asm @@ -36,7 +36,17 @@ ;------------------------------------------------------------------------------ InternalX86DisablePaging64 PROC cli - lea r10, @F + lea rsi, @F ; rsi <- The start address of transition code + mov rdi, [rsp + 28h] ; rdi <- New stack + sub rdi, 64 ; rdi <- use 64 byte in stack to hold transition code + mov r10, rdi ; r10 <- The start address of transicition code below 4G + lea rax, mTransitionEnd ; rax <- end of transition code + sub rax, rsi ; rax <- The size of transition piece code + push rcx ; save rcx to stack + mov rcx, rax ; rcx <- The size of transition piece code + rep movsb ; copy transition code to (new stack - 64byte) below 4G + pop rcx ; restore rcx + mov esi, r8d mov edi, r9d mov eax, [rsp + 28h] ; eax <- New Stack @@ -44,6 +54,8 @@ InternalX86DisablePaging64 PROC push r10 DB 48h ; prefix to composite "retq" with next "retf" retf ; Use far return to load CS register from stack + +; Start of transition code @@: mov esp, eax ; set up new stack mov rax, cr0 @@ -64,4 +76,6 @@ InternalX86DisablePaging64 PROC hlt ; no one should get here InternalX86DisablePaging64 ENDP +mTransitionEnd LABEL BYTE + END