aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/head64.c2
-rw-r--r--arch/x86/kernel/head_64.S34
-rw-r--r--include/asm-x86/segment.h6
3 files changed, 37 insertions, 5 deletions
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 4a1c1356c41..85c1e6bf802 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -59,7 +59,7 @@ void __init x86_64_start_kernel(char * real_mode_data)
59 zap_identity_mappings(); 59 zap_identity_mappings();
60 60
61 for (i = 0; i < IDT_ENTRIES; i++) 61 for (i = 0; i < IDT_ENTRIES; i++)
62 set_intr_gate(i, early_idt_handler); 62 set_intr_gate(i, &early_idt_handlers[i]);
63 load_idt((const struct desc_ptr *)&idt_descr); 63 load_idt((const struct desc_ptr *)&idt_descr);
64 64
65 early_printk("Kernel alive\n"); 65 early_printk("Kernel alive\n");
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
index c31b1c96a9d..8b4c35cb519 100644
--- a/arch/x86/kernel/head_64.S
+++ b/arch/x86/kernel/head_64.S
@@ -267,14 +267,40 @@ init_rsp:
267bad_address: 267bad_address:
268 jmp bad_address 268 jmp bad_address
269 269
270.macro early_idt_tramp first, last
271 .ifgt \last-\first
272 early_idt_tramp \first, \last-1
273 .endif
274 movl $\last,%esi
275 jmp early_idt_handler
276.endm
277
278 .globl early_idt_handlers
279early_idt_handlers:
280 early_idt_tramp 0, 63
281 early_idt_tramp 64, 127
282 early_idt_tramp 128, 191
283 early_idt_tramp 192, 255
284
270ENTRY(early_idt_handler) 285ENTRY(early_idt_handler)
271 cmpl $2,early_recursion_flag(%rip) 286 cmpl $2,early_recursion_flag(%rip)
272 jz 1f 287 jz 1f
273 incl early_recursion_flag(%rip) 288 incl early_recursion_flag(%rip)
274 xorl %eax,%eax
275 movq 8(%rsp),%rsi # get rip
276 movq (%rsp),%rdx
277 GET_CR2_INTO_RCX 289 GET_CR2_INTO_RCX
290 movq %rcx,%r9
291 xorl %r8d,%r8d # zero for error code
292 movl %esi,%ecx # get vector number
293 # Test %ecx against mask of vectors that push error code.
294 cmpl $31,%ecx
295 ja 0f
296 movl $1,%eax
297 salq %cl,%rax
298 testl $0x27d00,%eax
299 je 0f
300 popq %r8 # get error code
3010: movq 0(%rsp),%rcx # get ip
302 movq 8(%rsp),%rdx # get cs
303 xorl %eax,%eax
278 leaq early_idt_msg(%rip),%rdi 304 leaq early_idt_msg(%rip),%rdi
279 call early_printk 305 call early_printk
280 cmpl $2,early_recursion_flag(%rip) 306 cmpl $2,early_recursion_flag(%rip)
@@ -291,7 +317,7 @@ early_recursion_flag:
291 .long 0 317 .long 0
292 318
293early_idt_msg: 319early_idt_msg:
294 .asciz "PANIC: early exception rip %lx error %lx cr2 %lx\n" 320 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
295early_idt_ripmsg: 321early_idt_ripmsg:
296 .asciz "RIP %s\n" 322 .asciz "RIP %s\n"
297 323
diff --git a/include/asm-x86/segment.h b/include/asm-x86/segment.h
index 57c8d372383..23f0535fec6 100644
--- a/include/asm-x86/segment.h
+++ b/include/asm-x86/segment.h
@@ -195,4 +195,10 @@
195#define GDT_ENTRY_TLS_ENTRIES 3 195#define GDT_ENTRY_TLS_ENTRIES 3
196#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8) 196#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
197 197
198#ifdef __KERNEL__
199#ifndef __ASSEMBLY__
200extern const char early_idt_handlers[IDT_ENTRIES][10];
201#endif
202#endif
203
198#endif 204#endif