From 9b431cbe425d2fffcd3bfd0de8c33a6374f53ab1 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 14 Jul 2021 12:51:07 +0200 Subject: [PATCH] Kernel: Avoid unnecessary jump in the boot code The 32-bit boot code jumps to 0xc0000000 + entry address once page tables are set up. This is unnecessary for 64-bit mode because we'll do another far jump just moments later. --- Kernel/Arch/x86/common/Boot/boot.S | 37 ++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/Kernel/Arch/x86/common/Boot/boot.S b/Kernel/Arch/x86/common/Boot/boot.S index 8cd939f5f2..2eadc29e26 100644 --- a/Kernel/Arch/x86/common/Boot/boot.S +++ b/Kernel/Arch/x86/common/Boot/boot.S @@ -522,23 +522,6 @@ pae_supported: mov $stack_top, %esp and $-16, %esp - /* jmp to an address above the 3GB mark */ - movl $1f,%eax - jmp *%eax -1: - movl %cr3, %eax - movl %eax, %cr3 - - /* unmap the 0-1MB range, which isn't used after jmp-ing up here */ - movl $256, %ecx - movl $(boot_pd0_pt0 - KERNEL_BASE), %edi - xorl %eax, %eax - -1: - movl %eax, 0(%edi) - addl $8, %edi - loop 1b - /* jump into C++ land */ addl $KERNEL_BASE, %ebx movl %ebx, multiboot_info_ptr @@ -556,8 +539,28 @@ pae_supported: mov %ax, %es mov %ax, %fs mov %ax, %gs + + mov %cr3, %rax + mov %rax, %cr3 +#else + /* jmp to an address above the 3GB mark */ + movl $1f,%eax + jmp *%eax +1: + movl %cr3, %eax + movl %eax, %cr3 #endif + /* unmap the 0-1MB range, which isn't used after jmp-ing up here */ + movl $256, %ecx + movl $(boot_pd0_pt0 - KERNEL_BASE), %edi + xorl %eax, %eax + +1: + movl %eax, 0(%edi) + addl $8, %edi + loop 1b + call init #if ARCH(X86_64) add $4, %rsp