From: "Jan Beulich" <JBeulich@novell.com>
To: "Andreas Kleen" <ak@suse.de>
Cc: <linux-kernel@vger.kernel.org>, <discuss@x86-64.org>
Subject: [PATCH] x86-64: make trap information available to die notification handlers
Date: Tue, 08 Nov 2005 15:23:18 +0100 [thread overview]
Message-ID: <4370C2E5.76F0.0078.0@novell.com> (raw)
In-Reply-To: 4370AFF0.76F0.0078.0@novell.com
[-- Attachment #1: Type: text/plain, Size: 273 bytes --]
This adjusts things so that handlers of the die() notifier will have
sufficient information about the trap currently being handled. It also
adjusts the notify_die() prototype to (again) match that of i386.
From: Jan Beulich <jbeulich@novell.com>
(actual patch attached)
[-- Attachment #2: linux-2.6.14-x86_64-die-trap-info.patch --]
[-- Type: application/octet-stream, Size: 4393 bytes --]
This adjusts things so that handlers of the die() notifier will have
sufficient information about the trap currently being handled. It also
adjusts the notify_die() prototype to (again) match that of i386.
From: Jan Beulich <jbeulich@novell.com>
--- 2.6.14/arch/x86_64/kernel/traps.c 2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14-x86_64-die-trap-info/arch/x86_64/kernel/traps.c 2005-11-07 09:33:53.000000000 +0100
@@ -382,7 +382,7 @@ void __die(const char * str, struct pt_r
printk("DEBUG_PAGEALLOC");
#endif
printk("\n");
- notify_die(DIE_OOPS, (char *)str, regs, err, 255, SIGSEGV);
+ notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
show_registers(regs);
/* Executive summary in case the oops scrolled away */
printk(KERN_ALERT "RIP ");
@@ -426,6 +426,8 @@ static void __kprobes do_trap(int trapnr
struct pt_regs * regs, long error_code,
siginfo_t *info)
{
+ struct task_struct *tsk = current;
+
conditional_sti(regs);
#ifdef CONFIG_CHECKING
@@ -441,17 +443,16 @@ static void __kprobes do_trap(int trapnr
}
#endif
- if (user_mode(regs)) {
- struct task_struct *tsk = current;
+ tsk->thread.error_code = error_code;
+ tsk->thread.trap_no = trapnr;
+ if (user_mode(regs)) {
if (exception_trace && unhandled_signal(tsk, signr))
printk(KERN_INFO
"%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
tsk->comm, tsk->pid, str,
regs->rip,regs->rsp,error_code);
- tsk->thread.error_code = error_code;
- tsk->thread.trap_no = trapnr;
if (info)
force_sig_info(signr, info, tsk);
else
@@ -511,6 +512,8 @@ DO_ERROR( 8, SIGSEGV, "double fault", do
asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
long error_code)
{
+ struct task_struct *tsk = current;
+
conditional_sti(regs);
#ifdef CONFIG_CHECKING
@@ -527,17 +530,16 @@ asmlinkage void __kprobes do_general_pro
}
#endif
- if (user_mode(regs)) {
- struct task_struct *tsk = current;
+ tsk->thread.error_code = error_code;
+ tsk->thread.trap_no = 13;
+ if (user_mode(regs)) {
if (exception_trace && unhandled_signal(tsk, SIGSEGV))
printk(KERN_INFO
"%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
tsk->comm, tsk->pid,
regs->rip,regs->rsp,error_code);
- tsk->thread.error_code = error_code;
- tsk->thread.trap_no = 13;
force_sig(SIGSEGV, tsk);
return;
}
@@ -748,6 +750,7 @@ static int kernel_math_error(struct pt_r
}
notify_die(DIE_GPF, str, regs, 0, 16, SIGFPE);
/* Illegal floating point operation in the kernel */
+ current->thread.trap_no = 16;
die(str, regs, 0);
return 0;
}
--- 2.6.14/arch/x86_64/mm/fault.c 2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14-x86_64-die-trap-info/arch/x86_64/mm/fault.c 2005-11-07 14:27:42.000000000 +0100
@@ -222,10 +222,15 @@ static noinline void pgtable_bad(unsigne
unsigned long error_code)
{
unsigned long flags = oops_begin();
+ struct task_struct *tsk;
printk(KERN_ALERT "%s: Corrupted page table at address %lx\n",
current->comm, address);
dump_pagetable(address);
+ tsk = current;
+ tsk->thread.cr2 = address;
+ tsk->thread.trap_no = 14;
+ tsk->thread.error_code = error_code;
__die("Bad pagetable", regs, error_code);
oops_end(flags);
do_exit(SIGKILL);
@@ -533,6 +538,9 @@ no_context:
printk_address(regs->rip);
printk("\n");
dump_pagetable(address);
+ tsk->thread.cr2 = address;
+ tsk->thread.trap_no = 14;
+ tsk->thread.error_code = error_code;
__die("Oops", regs, error_code);
/* Executive summary in case the body of the oops scrolled away */
printk(KERN_EMERG "CR2: %016lx\n", address);
--- 2.6.14/include/asm-x86_64/kdebug.h 2005-10-28 02:02:08.000000000 +0200
+++ 2.6.14-x86_64-die-trap-info/include/asm-x86_64/kdebug.h 2005-11-07 10:31:52.000000000 +0100
@@ -35,9 +35,16 @@ enum die_val {
DIE_PAGE_FAULT,
};
-static inline int notify_die(enum die_val val,char *str,struct pt_regs *regs,long err,int trap, int sig)
-{
- struct die_args args = { .regs=regs, .str=str, .err=err, .trapnr=trap,.signr=sig };
+static inline int notify_die(enum die_val val, const char *str,
+ struct pt_regs *regs, long err, int trap, int sig)
+{
+ struct die_args args = {
+ .regs = regs,
+ .str = str,
+ .err = err,
+ .trapnr = trap,
+ .signr = sig
+ };
return notifier_call_chain(&die_chain, val, &args);
}
next prev parent reply other threads:[~2005-11-08 14:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-08 13:02 [PATCH] x86-64: separate unwind info generation from CONFIG_DEBUG_INFO Jan Beulich
2005-11-08 14:21 ` [PATCH] x86-64: fix bound check IDT gate Jan Beulich
2005-11-08 14:22 ` [PATCH] x86-64: remove dead die_if_kernel() Jan Beulich
2005-11-08 14:23 ` Jan Beulich [this message]
2005-11-08 14:23 ` [PATCH] x86-64: adjust double fault handling Jan Beulich
2005-11-08 14:24 ` [PATCH] x86-64: remove unprotected iret Jan Beulich
2005-11-10 3:38 ` [discuss] " Andi Kleen
2005-11-08 14:25 ` [PATCH] x86-64: adjust page fault handling Jan Beulich
2005-11-09 16:10 ` [PATCH] x86-64: adjust ia32entry.S Jan Beulich
2005-11-11 15:34 ` Andi Kleen
2005-11-11 15:50 ` Jan Beulich
2005-11-11 15:53 ` [discuss] " Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4370C2E5.76F0.0078.0@novell.com \
--to=jbeulich@novell.com \
--cc=ak@suse.de \
--cc=discuss@x86-64.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox