summaryrefslogtreecommitdiff
path: root/MdePkg/Library/BaseLib/X64/DisablePaging64.S
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2010-03-01 05:35:20 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2010-03-01 05:35:20 +0000
commitbe04587c86ad728413586feeb648a5fd586adb24 (patch)
tree06747abe6bb4b8699d66a474f1ca2cfcafd97781 /MdePkg/Library/BaseLib/X64/DisablePaging64.S
parent3df4b6e7e96f671a0fc045119e44130936666030 (diff)
downloadedk2-platforms-be04587c86ad728413586feeb648a5fd586adb24.tar.xz
Remove assumption that the transition code for transitioning from 64-bit to 32-bit mode is 64 bytes. Instead compute the size based on the implementation in the ASM file.
Update logic to align new 32-bit stack on a 4 byte boundary Update logic to prevent one slot overlap between the transition code and the new stack. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10133 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdePkg/Library/BaseLib/X64/DisablePaging64.S')
-rw-r--r--MdePkg/Library/BaseLib/X64/DisablePaging64.S15
1 files changed, 9 insertions, 6 deletions
diff --git a/MdePkg/Library/BaseLib/X64/DisablePaging64.S b/MdePkg/Library/BaseLib/X64/DisablePaging64.S
index 017d6ce945..a467fea260 100644
--- a/MdePkg/Library/BaseLib/X64/DisablePaging64.S
+++ b/MdePkg/Library/BaseLib/X64/DisablePaging64.S
@@ -40,10 +40,12 @@ ASM_PFX(InternalX86DisablePaging64):
cli
lea L1(%rip), %rsi # rsi <- The start address of transition code
mov 0x28(%rsp), %edi # rdi <- New stack
- sub $64, %edi # rdi <- use 64 byte in stack to hold transition code
- mov %edi, %r10d # r10 <- The start address of transicition code below 4G
lea _mTransitionEnd(%rip), %rax # rax <- end of transition code
sub %rsi, %rax # rax <- The size of transition piece code
+ add $4, %rax # round rax up to the next 4 byte boundary
+ and $0x0fffffffc, %rax
+ sub %rax, %rdi # rdi <- use stack to hold transition code
+ mov %edi, %r10d # r10 <- The start address of transicition code below 4G
push %rcx # save rcx to stack
mov %rax, %rcx # rcx <- The size of transition piece code
rep
@@ -52,18 +54,19 @@ ASM_PFX(InternalX86DisablePaging64):
mov %r8d, %esi
mov %r9d, %edi
- mov 0x28(%rsp), %eax # eax <- New Stack
+ mov %r10d, %eax
+ sub $4, %eax
push %rcx # push Cs to stack
- push %r10
+ push %r10 # push address of transition code on stack
.byte 0x48, 0xcb # retq: Use far return to load CS register from stack
# (Use raw byte code since some GNU assemblers generates incorrect code for "retq")
L1:
mov %eax,%esp # set up new stack
mov %cr0,%rax
- btr $0x1f,%eax
+ btr $0x1f,%eax # clear CR0.PG
mov %rax,%cr0 # disable paging
- mov %rdx,%rbx # save EntryPoint to rbx, for rdmsr will overwrite rdx
+ mov %edx,%ebx # save EntryPoint to ebx, for rdmsr will overwrite edx
mov $0xc0000080,%ecx
rdmsr
and $0xfe,%ah # clear LME