History

[PATCH] kdump: Save trap information for later analysis

If we are faulting in kernel it is quite possible this will lead to a panic. Save trap number, cr2 (in case of page fault) and error_code in the current thread (these fields already exist for signal delivery but are not used here). This helps later kdump crash analyzing from user-space (a script has been submitted to dig this info out in gdb).

Alexander Nyberg committed 21 years ago

Commit 4f339ec1 parent 6e274d12 files · +11 −4Browse files

Unified · Split

2 files
  1. arch/i386/kernel/traps.c +8 −4
  2. arch/i386/mm/fault.c +3 −0
arch/i386/kernel/traps.c+8−4
@@ -369,6 +369,10 @@ static inline void die_if_kernel(const char * str, struct pt_regs * regs, long e · 368 unmodified lines
369369 static void do_trap(int trapnr, int signr, char *str, int vm86,
370370 struct pt_regs * regs, long error_code, siginfo_t *info)
371371 {
372+ struct task_struct *tsk = current;
373+ tsk->thread.error_code = error_code;
374+ tsk->thread.trap_no = trapnr;
375+
372376 if (regs->eflags & VM_MASK) {
373377 if (vm86)
374378 goto vm86_trap;
@@ -379,9 +383,6 @@ static void do_trap(int trapnr, int signr, char *str, int vm86, · 4 unmodified lines
379383 goto kernel_trap;
380384
381385 trap_signal: {
382− struct task_struct *tsk = current;
383− tsk->thread.error_code = error_code;
384− tsk->thread.trap_no = trapnr;
385386 if (info)
386387 force_sig_info(signr, info, tsk);
387388 else
@@ -494,6 +495,9 @@ fastcall void do_general_protection(struct pt_regs * regs, long error_code) · 106 unmodified lines
494495 }
495496 put_cpu();
496497
498+ current->thread.error_code = error_code;
499+ current->thread.trap_no = 13;
500+
497501 if (regs->eflags & VM_MASK)
498502 goto gp_in_vm86;
499503
@@ -897,9 +901,9 @@ fastcall void do_simd_coprocessor_error(struct pt_regs * regs, · 397 unmodified lines
897901 error_code);
898902 return;
899903 }
900− die_if_kernel("cache flush denied", regs, error_code);
901904 current->thread.trap_no = 19;
902905 current->thread.error_code = error_code;
906+ die_if_kernel("cache flush denied", regs, error_code);
903907 force_sig(SIGSEGV, current);
904908 }
905909 }
arch/i386/mm/fault.c+3−0
@@ -463,6 +463,9 @@ no_context: · 462 unmodified lines
463463 printk(KERN_ALERT "*pte = %08lx\n", page);
464464 }
465465 #endif
466+ tsk->thread.cr2 = address;
467+ tsk->thread.trap_no = 14;
468+ tsk->thread.error_code = error_code;
466469 die("Oops", regs, error_code);
467470 bust_spinlocks(0);
468471 do_exit(SIGKILL);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t