Commit 37742ed4 authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] x86_64: Add early exception handler

Add an early exception handler on x86-64 to get better debugging output for
crashes before traps_init. 

Requires earlyconsole.
Signed-off-by: default avatarAndi Kleen <ak@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ba97d488
...@@ -176,6 +176,18 @@ initial_code: ...@@ -176,6 +176,18 @@ initial_code:
init_rsp: init_rsp:
.quad init_thread_union+THREAD_SIZE-8 .quad init_thread_union+THREAD_SIZE-8
ENTRY(early_idt_handler)
xorl %eax,%eax
movq 8(%rsp),%rsi # get rip
movq (%rsp),%rdx
movq %cr2,%rcx
leaq early_idt_msg(%rip),%rdi
call early_printk
1: hlt
jmp 1b
early_idt_msg:
.asciz "PANIC: early exception rip %lx error %lx cr2 %lx\n"
.code32 .code32
ENTRY(no_long_mode) ENTRY(no_long_mode)
......
...@@ -11,12 +11,14 @@ ...@@ -11,12 +11,14 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/percpu.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/proto.h> #include <asm/proto.h>
#include <asm/smp.h> #include <asm/smp.h>
#include <asm/bootsetup.h> #include <asm/bootsetup.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/desc.h>
/* Don't add a printk in there. printk relies on the PDA which is not initialized /* Don't add a printk in there. printk relies on the PDA which is not initialized
yet. */ yet. */
...@@ -79,7 +81,11 @@ extern char _end[]; ...@@ -79,7 +81,11 @@ extern char _end[];
void __init x86_64_start_kernel(char * real_mode_data) void __init x86_64_start_kernel(char * real_mode_data)
{ {
char *s; char *s;
int i;
for (i = 0; i < 256; i++)
set_intr_gate(i, early_idt_handler);
asm volatile("lidt %0" :: "m" (idt_descr));
clear_bss(); clear_bss();
pda_init(0); pda_init(0);
copy_bootdata(real_mode_data); copy_bootdata(real_mode_data);
......
...@@ -210,6 +210,8 @@ static inline void load_LDT(mm_context_t *pc) ...@@ -210,6 +210,8 @@ static inline void load_LDT(mm_context_t *pc)
put_cpu(); put_cpu();
} }
extern struct desc_ptr idt_descr;
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
#endif #endif
...@@ -12,6 +12,8 @@ extern void get_cpu_vendor(struct cpuinfo_x86*); ...@@ -12,6 +12,8 @@ extern void get_cpu_vendor(struct cpuinfo_x86*);
extern void start_kernel(void); extern void start_kernel(void);
extern void pda_init(int); extern void pda_init(int);
extern void early_idt_handler(void);
extern void mcheck_init(struct cpuinfo_x86 *c); extern void mcheck_init(struct cpuinfo_x86 *c);
extern void init_memory_mapping(void); extern void init_memory_mapping(void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment