x86: Use a simple jump into long mode
With the 64-bit descriptor we can use a jump instruction, rather than pushing things on the stack. Since the processor is in 64-bit mode by this point, pop a 64-bit value from the stack, containing the target address. This simplifies the code slightly, in particular its use of the stack. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -22,6 +22,7 @@ cpu_call64:
|
|||||||
* ecx - target
|
* ecx - target
|
||||||
*/
|
*/
|
||||||
cli
|
cli
|
||||||
|
pushl $0 /* top 64-bits of target */
|
||||||
push %ecx /* arg2 = target */
|
push %ecx /* arg2 = target */
|
||||||
push %edx /* arg1 = setup_base */
|
push %edx /* arg1 = setup_base */
|
||||||
mov %eax, %ebx
|
mov %eax, %ebx
|
||||||
@@ -32,7 +33,8 @@ cpu_call64:
|
|||||||
movl %eax, %cr0
|
movl %eax, %cr0
|
||||||
|
|
||||||
/* Enable PAE mode */
|
/* Enable PAE mode */
|
||||||
movl $(X86_CR4_PAE), %eax
|
movl %cr4, %eax
|
||||||
|
orl $X86_CR4_PAE, %eax
|
||||||
movl %eax, %cr4
|
movl %eax, %cr4
|
||||||
|
|
||||||
/* Enable the boot page tables */
|
/* Enable the boot page tables */
|
||||||
@@ -57,23 +59,18 @@ cpu_call64:
|
|||||||
*/
|
*/
|
||||||
pop %esi /* setup_base */
|
pop %esi /* setup_base */
|
||||||
|
|
||||||
pushl $(X86_GDT_ENTRY_64BIT_CS * X86_GDT_ENTRY_SIZE)
|
|
||||||
leal lret_target, %eax
|
|
||||||
pushl %eax
|
|
||||||
|
|
||||||
/* Enter paged protected Mode, activating Long Mode */
|
/* Enter paged protected Mode, activating Long Mode */
|
||||||
movl %cr0, %eax
|
movl %cr0, %eax
|
||||||
orl $X86_CR0_PG, %eax
|
orl $X86_CR0_PG, %eax
|
||||||
movl %eax, %cr0
|
movl %eax, %cr0
|
||||||
|
|
||||||
/* Jump from 32bit compatibility mode into 64bit mode. */
|
/* Jump from 32bit compatibility mode into 64bit mode. */
|
||||||
lret
|
ljmp $(X86_GDT_ENTRY_64BIT_CS * X86_GDT_ENTRY_SIZE), $lret_target
|
||||||
|
|
||||||
code64:
|
.code64
|
||||||
lret_target:
|
lret_target:
|
||||||
pop %eax /* target */
|
pop %rax /* target */
|
||||||
mov %eax, %eax /* Clear bits 63:32 */
|
jmp *%rax /* Jump to the 64-bit target */
|
||||||
jmp *%eax /* Jump to the 64-bit target */
|
|
||||||
|
|
||||||
.globl call64_stub_size
|
.globl call64_stub_size
|
||||||
call64_stub_size:
|
call64_stub_size:
|
||||||
|
Reference in New Issue
Block a user