|
@@ -304,20 +304,6 @@ ENTRY(startup_64)
|
|
|
/* Set up the stack */
|
|
|
leaq boot_stack_end(%rbx), %rsp
|
|
|
|
|
|
-#ifdef CONFIG_X86_5LEVEL
|
|
|
- /*
|
|
|
- * Check if we need to enable 5-level paging.
|
|
|
- * RSI holds real mode data and need to be preserved across
|
|
|
- * a function call.
|
|
|
- */
|
|
|
- pushq %rsi
|
|
|
- call l5_paging_required
|
|
|
- popq %rsi
|
|
|
-
|
|
|
- /* If l5_paging_required() returned zero, we're done here. */
|
|
|
- cmpq $0, %rax
|
|
|
- je lvl5
|
|
|
-
|
|
|
/*
|
|
|
* At this point we are in long mode with 4-level paging enabled,
|
|
|
* but we want to enable 5-level paging.
|
|
@@ -325,12 +311,28 @@ ENTRY(startup_64)
|
|
|
* The problem is that we cannot do it directly. Setting LA57 in
|
|
|
* long mode would trigger #GP. So we need to switch off long mode
|
|
|
* first.
|
|
|
+ */
|
|
|
+
|
|
|
+ /*
|
|
|
+ * paging_prepare() sets up the trampoline and checks if we need to
|
|
|
+ * enable 5-level paging.
|
|
|
*
|
|
|
- * NOTE: This is not going to work if bootloader put us above 4G
|
|
|
- * limit.
|
|
|
+ * Address of the trampoline is returned in RAX.
|
|
|
+ * Non zero RDX on return means we need to enable 5-level paging.
|
|
|
*
|
|
|
- * The first step is go into compatibility mode.
|
|
|
+ * RSI holds real mode data and needs to be preserved across
|
|
|
+ * this function call.
|
|
|
*/
|
|
|
+ pushq %rsi
|
|
|
+ call paging_prepare
|
|
|
+ popq %rsi
|
|
|
+
|
|
|
+ /* Save the trampoline address in RCX */
|
|
|
+ movq %rax, %rcx
|
|
|
+
|
|
|
+ /* Check if we need to enable 5-level paging */
|
|
|
+ cmpq $0, %rdx
|
|
|
+ jz lvl5
|
|
|
|
|
|
/* Clear additional page table */
|
|
|
leaq lvl5_pgtable(%rbx), %rdi
|
|
@@ -352,7 +354,6 @@ ENTRY(startup_64)
|
|
|
pushq %rax
|
|
|
lretq
|
|
|
lvl5:
|
|
|
-#endif
|
|
|
|
|
|
/* Zero EFLAGS */
|
|
|
pushq $0
|
|
@@ -490,7 +491,6 @@ relocated:
|
|
|
jmp *%rax
|
|
|
|
|
|
.code32
|
|
|
-#ifdef CONFIG_X86_5LEVEL
|
|
|
compatible_mode:
|
|
|
/* Setup data and stack segments */
|
|
|
movl $__KERNEL_DS, %eax
|
|
@@ -526,7 +526,6 @@ compatible_mode:
|
|
|
movl %eax, %cr0
|
|
|
|
|
|
lret
|
|
|
-#endif
|
|
|
|
|
|
no_longmode:
|
|
|
/* This isn't an x86-64 CPU so hang */
|
|
@@ -585,7 +584,5 @@ boot_stack_end:
|
|
|
.balign 4096
|
|
|
pgtable:
|
|
|
.fill BOOT_PGT_SIZE, 1, 0
|
|
|
-#ifdef CONFIG_X86_5LEVEL
|
|
|
lvl5_pgtable:
|
|
|
.fill PAGE_SIZE, 1, 0
|
|
|
-#endif
|