aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/realmode/rm/trampoline_64.S
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/realmode/rm/trampoline_64.S')
-rw-r--r--arch/x86/realmode/rm/trampoline_64.S67
1 files changed, 28 insertions, 39 deletions
diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
index 7459c52f0c25..f71ea0800d3d 100644
--- a/arch/x86/realmode/rm/trampoline_64.S
+++ b/arch/x86/realmode/rm/trampoline_64.S
@@ -52,7 +52,7 @@ ENTRY(trampoline_data)
52 # write marker for master knows we're running 52 # write marker for master knows we're running
53 53
54 # Setup stack 54 # Setup stack
55 movw $trampoline_stack_end, %sp 55 movl $rm_stack_end, %esp
56 56
57 call verify_cpu # Verify the cpu supports long mode 57 call verify_cpu # Verify the cpu supports long mode
58 testl %eax, %eax # Check for return code 58 testl %eax, %eax # Check for return code
@@ -68,8 +68,11 @@ ENTRY(trampoline_data)
68 lidtl tidt # load idt with 0, 0 68 lidtl tidt # load idt with 0, 0
69 lgdtl tgdt # load gdt with whatever is appropriate 69 lgdtl tgdt # load gdt with whatever is appropriate
70 70
71 mov $X86_CR0_PE, %ax # protected mode (PE) bit 71 movw $__KERNEL_DS, %dx # Data segment descriptor
72 lmsw %ax # into protected mode 72
73 # Enable protected mode
74 movl $X86_CR0_PE, %eax # protected mode (PE) bit
75 movl %eax, %cr0 # into protected mode
73 76
74 # flush prefetch and jump to startup_32 77 # flush prefetch and jump to startup_32
75 ljmpl $__KERNEL32_CS, $pa_startup_32 78 ljmpl $__KERNEL32_CS, $pa_startup_32
@@ -83,27 +86,27 @@ no_longmode:
83 .code32 86 .code32
84 .balign 4 87 .balign 4
85ENTRY(startup_32) 88ENTRY(startup_32)
86 movl $__KERNEL_DS, %eax # Initialize the %ds segment register 89 movl %edx, %ss
87 movl %eax, %ds 90 addl $pa_real_mode_base, %esp
91 movl %edx, %ds
92 movl %edx, %es
93 movl %edx, %fs
94 movl %edx, %gs
88 95
89 movl $X86_CR4_PAE, %eax 96 movl $X86_CR4_PAE, %eax
90 movl %eax, %cr4 # Enable PAE mode 97 movl %eax, %cr4 # Enable PAE mode
91 98
92 movl pa_startup_64_smp, %esi 99 # Setup trampoline 4 level pagetables
93 movl pa_startup_64_smp_high, %edi 100 movl $pa_level3_ident_pgt, %eax
94
95 # Setup trampoline 4 level pagetables
96 leal pa_trampoline_level4_pgt, %eax
97 movl %eax, %cr3 101 movl %eax, %cr3
98 102
99 movl $MSR_EFER, %ecx 103 movl $MSR_EFER, %ecx
100 movl $(1 << _EFER_LME), %eax # Enable Long Mode 104 movl $((1 << _EFER_LME) | (1 << _EFER_NX)), %eax # Enable Long Mode
101 xorl %edx, %edx 105 xorl %edx, %edx
102 wrmsr 106 wrmsr
103 107
104 # Enable paging and in turn activate Long Mode 108 # Enable paging and in turn activate Long Mode
105 # Enable protected mode 109 movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
106 movl $(X86_CR0_PG | X86_CR0_PE), %eax
107 movl %eax, %cr0 110 movl %eax, %cr0
108 111
109 /* 112 /*
@@ -119,10 +122,7 @@ ENTRY(startup_32)
119 .balign 4 122 .balign 4
120ENTRY(startup_64) 123ENTRY(startup_64)
121 # Now jump into the kernel using virtual addresses 124 # Now jump into the kernel using virtual addresses
122 movl %edi, %eax 125 jmpq *startup_64_smp(%rip)
123 shlq $32, %rax
124 addl %esi, %eax
125 jmp *%rax
126 126
127 .section ".rodata","a" 127 .section ".rodata","a"
128 .balign 16 128 .balign 16
@@ -132,10 +132,10 @@ tidt:
132 132
133 # Duplicate the global descriptor table 133 # Duplicate the global descriptor table
134 # so the kernel can live anywhere 134 # so the kernel can live anywhere
135 .balign 4 135 .balign 16
136 .globl tgdt 136 .globl tgdt
137tgdt: 137tgdt:
138 .short tgdt_end - tgdt # gdt limit 138 .short tgdt_end - tgdt - 1 # gdt limit
139 .long pa_tgdt 139 .long pa_tgdt
140 .short 0 140 .short 0
141 .quad 0x00cf9b000000ffff # __KERNEL32_CS 141 .quad 0x00cf9b000000ffff # __KERNEL32_CS
@@ -143,23 +143,12 @@ tgdt:
143 .quad 0x00cf93000000ffff # __KERNEL_DS 143 .quad 0x00cf93000000ffff # __KERNEL_DS
144tgdt_end: 144tgdt_end:
145 145
146 .data 146 .bss
147 .balign 4 147
148GLOBAL(trampoline_status) 148 .balign PAGE_SIZE
149 .long 0 149GLOBAL(level3_ident_pgt) .space 511*8
150 150GLOBAL(level3_kernel_pgt) .space 8
151trampoline_stack: 151
152 .org 0x1000 152 .balign 8
153trampoline_stack_end: 153GLOBAL(startup_64_smp) .space 8
154 154GLOBAL(trampoline_status) .space 4
155 .globl level3_ident_pgt
156 .globl level3_kernel_pgt
157GLOBAL(trampoline_level4_pgt)
158 level3_ident_pgt: .quad 0
159 .fill 510,8,0
160 level3_kernel_pgt: .quad 0
161
162 .globl startup_64_smp
163 .globl startup_64_smp_high
164startup_64_smp: .long 0
165startup_64_smp_high: .long 0