summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseLib/X64
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-06-05 11:21:48 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-06-05 11:21:48 +0000
commitce4c0e31b039cc9948ba06bbaca9d240d70aa7ee (patch)
tree2fbf4e6fc57e0ceeb5674e6f62bc145006d725b9 /MdePkg/Library/BaseLib/X64
parentaa4d03f7fb9c933d7ffc90749ef939161bc5944c (diff)
downloadedk2-platforms-ce4c0e31b039cc9948ba06bbaca9d240d70aa7ee.tar.xz
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
Diffstat (limited to 'MdePkg/Library/BaseLib/X64')
-rw-r--r--MdePkg/Library/BaseLib/X64/DisablePaging64.asm16
1 files changed, 15 insertions, 1 deletions
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