mdb: correct kprobes int3 trap
PATCH 2/26 mdb: correct kprobes int3 trap
Centralized external definitions into include files and corrected the file to conform to Linux coding practices. fixed word wrap problems with patches.
Corrected kprobes section for int3 trap where CONFIG_MDB is always true.
arch/x86/kernel/traps_32.c +42 -3
@@ -46,6 +46,10 @@#include <linux/edac.h> #endif +#ifdef CONFIG_MDB +#include <linux/mdb.h> +#endif // CONFIG_MDB +#include <asm/arch_hooks.h> #include <asm/stacktrace.h> #include <asm/processor.h>
@@ -452,8 +456,15 @@*/ void die (const char *str,struct pt_regs *regs,long err) { -unsigned long flags =oops_begin (); +#ifdef CONFIG_MDB +unsigned long flags; + mdb_oops = (unsigned char *)str; +mdb (SOFTWARE_EXCEPTION , err, regs); + flags =oops_begin (); +#else +unsigned long flags =oops_begin (); +#endif // CONFIG_MDB if (die_nest_count <3 ) {report_bug (regs->ip, regs);
@@ -573,9 +584,9 @@ } DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip) -#ifndef CONFIG_KPROBES +#if !defined(CONFIG_KPROBES ) && !defined(CONFIG_MDB ) DO_VM86_ERROR(3, SIGTRAP, "int3", int3) -#endif +#endif // CONFIG_MDB DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow) DO_VM86_ERROR(5, SIGSEGV, "bounds", bounds)DO_ERROR_INFO (6 ,SIGILL ,"invalid opcode" , invalid_op,ILL_ILLOPN , regs->ip,0 )
@@ -718,6 +729,9 @@ {if (notify_die (DIE_NMIUNKNOWN ,"nmi" , regs, reason,2 ,SIGINT ) ==NOTIFY_STOP )return ; +#ifdef CONFIG_MDB +mdb (NMI_EXCEPTION , reason, regs);// nmi is code 2 +#endif // CONFIG_MDB #ifdef CONFIG_MCA /* * Might actually be able to figure out what the guilty party
@@ -756,6 +770,9 @@printk (" on CPU%d, ip %08lx, registers:\n" ,smp_processor_id (), regs->ip);show_registers (regs); +#ifdef CONFIG_MDB +mdb (NMI_EXCEPTION ,0 , regs);// nmi is code 2 +#endif // CONFIG_MDB if (do_panic)panic ("Non maskable interrupt" );console_silent ();
@@ -785,6 +802,10 @@if (!cpu) reason =get_nmi_reason (); +#if defined(CONFIG_SMP ) && defined(CONFIG_MDB ) +if (mdb (NMI_EXCEPTION ,0 , regs)) +return ; +#endif // CONFIG_MDB if (!(reason &0xc0 )) {if (notify_die (DIE_NMI_IPI ,"nmi_ipi" , regs, reason,2 ,SIGINT ) ==NOTIFY_STOP )
@@ -850,6 +871,10 @@#ifdef CONFIG_KPROBES void __kprobes do_int3 (struct pt_regs *regs,long error_code) { +#ifdef CONFIG_MDB +if (mdb (BREAKPOINT_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB trace_hardirqs_fixup (); if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
@@ -865,6 +890,16 @@ }#endif +#if !defined(CONFIG_KPROBES ) +fastcall void do_int3(struct pt_regs * regs, long error_code) +{ +#if defined(CONFIG_MDB ) +if (mdb (BREAKPOINT_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB +do_trap (3 ,SIGTRAP ,"int3" ,1 , regs, error_code,NULL ); +} +#endif /* * Our handling of the processor debug registers is non-trivial. * We do not clear them on entry and exit from the kernel. Therefore
@@ -895,6 +930,10 @@trace_hardirqs_fixup ();get_debugreg (condition,6 ); +#ifdef CONFIG_MDB +if (mdb (DEBUGGER_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB /* * The processor cleared BTF, so don't mark that we need it set.
Hi Jeffery,
Could you explain what is MDB and how it works?
And please check your patch style by using scripts/checkpatch.pl. Your cording style seem to be different from linux coding style...
Thank you,
Quoted 126 lines · [email protected] wrote:
Centralized external definitions into include files and corrected the file to conform to Linux coding practices. fixed word wrap problems with patches.
Corrected kprobes section for int3 trap where
CONFIG_MDBis always true.Signed-off-by Jeffrey Vernon Merkey ([email protected])arch/x86/kernel/traps_32.c +42
-4@@ -46,6 +46,10 @@#include <linux/edac.h> #endif +#ifdef CONFIG_MDB +#include <linux/mdb.h> +#endif // CONFIG_MDB +#include <asm/arch_hooks.h> #include <asm/stacktrace.h> #include <asm/processor.h> @@ -452,8 +456,15 @@*/ void die (const char *str,struct pt_regs *regs,long err) { -unsigned long flags =oops_begin (); +#ifdef CONFIG_MDB +unsigned long flags; + mdb_oops = (unsigned char *)str; +mdb (SOFTWARE_EXCEPTION , err, regs); + flags =oops_begin (); +#else +unsigned long flags =oops_begin (); +#endif // CONFIG_MDB if (die_nest_count <3 ) {report_bug (regs->ip, regs);@@ -573,9 +584,9 @@ } DO_VM86_ERROR_INFO(0, SIGFPE, "divide error", divide_error, FPE_INTDIV, regs->ip) -#ifndef CONFIG_KPROBES +#if !defined(CONFIG_KPROBES ) && !defined(CONFIG_MDB ) DO_VM86_ERROR(3, SIGTRAP, "int3", int3) -#endif +#endif // CONFIG_MDB DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow) DO_VM86_ERROR(5, SIGSEGV, "bounds", bounds)DO_ERROR_INFO (6 ,SIGILL ,"invalid opcode" , invalid_op,ILL_ILLOPN , regs->ip,0 )@@ -718,6 +729,9 @@ {if (notify_die (DIE_NMIUNKNOWN ,"nmi" , regs, reason,2 ,SIGINT ) ==NOTIFY_STOP )return ; +#ifdef CONFIG_MDB +mdb (NMI_EXCEPTION , reason, regs);// nmi is code 2 +#endif // CONFIG_MDB #ifdef CONFIG_MCA /* * Might actually be able to figure out what the guilty party @@ -756,6 +770,9 @@printk (" on CPU%d, ip %08lx, registers:\n" ,smp_processor_id (), regs->ip);show_registers (regs); +#ifdef CONFIG_MDB +mdb (NMI_EXCEPTION ,0 , regs);// nmi is code 2 +#endif // CONFIG_MDB if (do_panic)panic ("Non maskable interrupt" );console_silent ();@@ -785,6 +802,10 @@if (!cpu) reason =get_nmi_reason (); +#if defined(CONFIG_SMP ) && defined(CONFIG_MDB ) +if (mdb (NMI_EXCEPTION ,0 , regs)) +return ; +#endif // CONFIG_MDB if (!(reason &0xc0 )) {if (notify_die (DIE_NMI_IPI ,"nmi_ipi" , regs, reason,2 ,SIGINT ) ==NOTIFY_STOP )@@ -850,6 +871,10 @@#ifdef CONFIG_KPROBES void __kprobes do_int3 (struct pt_regs *regs,long error_code) { +#ifdef CONFIG_MDB +if (mdb (BREAKPOINT_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB trace_hardirqs_fixup (); if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)@@ -865,6 +890,16 @@ }#endif +#if !defined(CONFIG_KPROBES ) +fastcall void do_int3(struct pt_regs * regs, long error_code) +{ +#if defined(CONFIG_MDB ) +if (mdb (BREAKPOINT_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB +do_trap (3 ,SIGTRAP ,"int3" ,1 , regs, error_code,NULL ); +} +#endif /* * Our handling of the processor debug registers is non-trivial. * We do not clear them on entry and exit from the kernel. Therefore @@ -895,6 +930,10 @@trace_hardirqs_fixup ();get_debugreg (condition,6 ); +#ifdef CONFIG_MDB +if (mdb (DEBUGGER_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB /* * The processor cleared BTF, so don't mark that we need it set. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Signature · 7 lines
Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: [email protected]
Quoted 3 lines
Hi Jeffery,
Could you explain what is MDB and how it works?
MDB is a kernel debugger that uses the same general architecture as the kernel debugger in Netware. Unlike the variants of GNU debuggers, MDB is geared towards folks from the intel/microsoft worlds who are more accustomed to the old school Intel assembler model and not the GNU variant that looks like an angry typewriter cursing at the screen (%#*&!, etc.).
MDB has some features not yet in this first patch, but I will be adding to subsequent patches like the ability to create time based traces of execution of code just like an ice does so you can set trigger breakpoints (kdb does not, nor kgdb), then go back ad look what happened in windows of time, as well as a much easier interface, smaller size, more flexible and pluggable command architecture -- a best of all -- it works and does not crash every other release or on every third vendors PC architecture like kdb does all the time.
It has been in use by me since 1997, when I wrote it after I left Novell. It is mature, hardened, and very stable -- and follows an architecture prove in the industry for over 20 years on Netware.
Quoted 4 lines
And please check your patch style by using
scripts/checkpatch.pl. Your cording style seem to be different from linux coding style...Thank you,
I was unaware of checkpatch.pl, but will run it later today and submit a git6 patch for any areas not in compliance with linux coding standards.
Jeff
Quoted 143 lines
Quoted 125 lines · [email protected] wrote:
Centralized external definitions into include files and corrected the file to conform to Linux coding practices. fixed word wrap problems with patches.
Corrected kprobes section for int3 trap where
CONFIG_MDBis always true.Signed-off-by Jeffrey Vernon Merkey ([email protected])arch/x86/kernel/traps_32.c +14
-3@@ -46,6 +46,10 @@#include <linux/edac.h> #endif +#ifdef CONFIG_MDB +#include <linux/mdb.h> +#endif // CONFIG_MDB +#include <asm/arch_hooks.h> #include <asm/stacktrace.h> #include <asm/processor.h> @@ -452,8 +456,15 @@*/ void die (const char *str,struct pt_regs *regs,long err) { -unsigned long flags =oops_begin (); +#ifdef CONFIG_MDB +unsigned long flags; + mdb_oops = (unsigned char *)str; +mdb (SOFTWARE_EXCEPTION , err, regs); + flags =oops_begin (); +#else +unsigned long flags =oops_begin (); +#endif // CONFIG_MDB if (die_nest_count <3 ) {report_bug (regs->ip, regs);@@ -573,9 +584,9 @@ }DO_VM86_ERROR_INFO (0 ,SIGFPE ,"divide error" , divide_error,FPE_INTDIV , regs->ip) -#ifndef CONFIG_KPROBES +#if !defined(CONFIG_KPROBES ) && !defined(CONFIG_MDB ) DO_VM86_ERROR(3, SIGTRAP, "int3", int3) -#endif +#endif // CONFIG_MDB DO_VM86_ERROR(4, SIGSEGV, "overflow", overflow)DO_VM86_ERROR (5 ,SIGSEGV ,"bounds" , bounds)DO_ERROR_INFO(6, SIGILL, "invalid opcode",
invalid_op,ILL_ILLOPN,regs->ip, 0)arch/x86/kernel/traps_32.c +3
-0@@ -718,6 +729,9 @@ {if (notify_die (DIE_NMIUNKNOWN ,"nmi" , regs, reason,2 ,SIGINT ) ==NOTIFY_STOP )return ; +#ifdef CONFIG_MDB +mdb (NMI_EXCEPTION , reason, regs);// nmi is code 2 +#endif // CONFIG_MDB #ifdef CONFIG_MCA /* arch/x86/kernel/traps_32.c +25
-1* Might actually be able to figure out what the guilty party @@ -756,6 +770,9 @@printk (" on CPU%d, ip %08lx, registers:\n" ,smp_processor_id (), regs->ip);show_registers (regs); +#ifdef CONFIG_MDB +mdb (NMI_EXCEPTION ,0 , regs);// nmi is code 2 +#endif // CONFIG_MDB if (do_panic)panic ("Non maskable interrupt" );console_silent ();@@ -785,6 +802,10 @@if (!cpu) reason =get_nmi_reason (); +#if defined(CONFIG_SMP ) && defined(CONFIG_MDB ) +if (mdb (NMI_EXCEPTION ,0 , regs)) +return ; +#endif // CONFIG_MDB if (!(reason &0xc0 )) {if (notify_die (DIE_NMI_IPI ,"nmi_ipi" , regs, reason,2 ,SIGINT ) ==NOTIFY_STOP )@@ -850,6 +871,10 @@#ifdef CONFIG_KPROBES void __kprobes do_int3 (struct pt_regs *regs,long error_code) { +#ifdef CONFIG_MDB +if (mdb (BREAKPOINT_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB trace_hardirqs_fixup (); if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)@@ -865,6 +890,16 @@ }#endif +#if !defined(CONFIG_KPROBES ) +fastcall void do_int3(struct pt_regs * regs, long error_code) +{ +#if defined(CONFIG_MDB ) +if (mdb (BREAKPOINT_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB +do_trap (3 ,SIGTRAP ,"int3" ,1 , regs, error_code,NULL ); +} +#endif /* * Our handling of the processor debug registers is non-trivial. * We do not clear them on entry and exit from the kernel. Therefore @@ -895,6 +930,10 @@trace_hardirqs_fixup ();get_debugreg (condition,6 ); +#ifdef CONFIG_MDB +if (mdb (DEBUGGER_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB /* * The processor cleared BTF, so don't mark that we need it set. -- Quoted 5 lines
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/--
Masami HiramatsuSoftware Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Divisione-mail: [email protected]
[email protected] wrote on 2008-08-05:
Quoted 2 lines
I was unaware of checkpatch.pl, but will run it later today and submit a git6 patch for any areas not in compliance with linux coding standards.
I guess you got complaints from scripts/checkpatch.pl for at least 3/4 of all lines by now. Some or many of the complaints will probably look silly. Have a look at Documentation/CodingStyle then because it gives context for many of the complaints. It also gives some rules of thumb for things which checkpatch.pl cannot check, e.g. legibility of global names.
From what I saw, there are _many_ whitespace "deviations" in your code (which perhaps scripts/Lindent can help to adjust), upper case vs. lower case in names, and occasional functions which are deeper nested than probably necessary, as already mentioned.
Signature · 3 lines
Stefan Richter -=====-==--- =--- --==- http://arcgraph.de/sr/
A message that is not in the archive (sent off-list or not yet received): 44714.166.70.238.45.1218029717.squirrel@webmail.wolfmountaingroup.com
Quoted 2 lines · [email protected] wrote:
Haven't gotten any complaints on this code so far actually from checkpatch.pl since it does not seem to exist in the 2.6.27 tree. (????)
It should exist in the scripts/ subdirectory. Check whether execute permission is set for the file.
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=scripts/checkpatch.pl
Signature · 3 lines
Stefan Richter -=====-==--- =--- --==- http://arcgraph.de/sr/
Quoted 11 lines · [email protected] wrote:
Quoted 3 lines
Hi Jeffery,
Could you explain what is MDB and how it works?
MDB is a kernel debugger that uses the same general architecture as the kernel debugger in Netware. Unlike the variants of GNU debuggers, MDB is geared towards folks from the intel/microsoft worlds who are more accustomed to the old school Intel assembler model and not the GNU variant that looks like an angry typewriter cursing at the screen (%#*&!, etc.).
Would you have any document about MDB, or project-site url? I think it is hard for anyone to understand what you like to do only from these big patchset.
Quoted 8 lines
MDB has some features not yet in this first patch, but I will be adding to subsequent patches like the ability to create time based traces of execution of code just like an ice does so you can set trigger breakpoints (kdb does not, nor kgdb), then go back ad look what happened in windows of time, as well as a much easier interface, smaller size, more flexible and pluggable command architecture -- a best of all -- it works and does not crash every other release or on every third vendors PC architecture like kdb does all the time.
Would you have talked with kdb/kgdb people?
Since linux kernel already have kgdb, I think you might better talk about merging your functionality (and stability) to kgdb, or at least talk about what part both debugger can share.
Quoted 3 lines
It has been in use by me since 1997, when I wrote it after I left Novell. It is mature, hardened, and very stable -- and follows an architecture prove in the industry for over 20 years on Netware.
Out of curiously, is there anyone except for you using MDB?
Thank you,
Quoted 5 lines
Quoted 4 lines
And please check your patch style by using
scripts/checkpatch.pl. Your cording style seem to be different from linux coding style...Thank you,
Signature · 7 lines
Masami Hiramatsu Software Engineer Hitachi Computer Products (America) Inc. Software Solutions Division e-mail: [email protected]
Quoted 13 lines
Quoted 11 lines · [email protected] wrote:
Quoted 3 lines
Hi Jeffery,
Could you explain what is MDB and how it works?
MDB is a kernel debugger that uses the same general architecture as the kernel debugger in Netware. Unlike the variants of GNU debuggers, MDB is geared towards folks from the intel/microsoft worlds who are more accustomed to the old school Intel assembler model and not the GNU variant that looks like an angry typewriter cursing at the screen (%#*&!, etc.).
Quoted 3 lines
Would you have any document about MDB, or project-site url? I think it is hard for anyone to understand what you like to do only from these big patchset.
If you install the patch and enter the debugger, you will find quite excellent documentation **inside** the debugger. start with "help help" at the debugger console.
Quoted 19 lines
Quoted 13 lines
MDB has some features not yet in this first patch, but I will be adding to
subsequent patches like the ability to create time based traces of execution of code just like an ice does so you can set trigger breakpoints
(kdb does not, nor kgdb), then go back ad look what happened in windows of
time, as well as a much easier interface, smaller size, more flexible and
pluggable command architecture -- a best of all -- it works and does not crash every other release or on every third vendors PC architecture like kdb does all the time.Would you have talked with kdb/kgdb people?
Since linux kernel already have kgdb, I think you might better talk about merging your functionality (and stability) to kgdb, or at least talk about what part both debugger can share.
Quoted 8 lines
Quoted 4 lines
It has been in use by me since 1997, when I wrote it after I left Novell.
It is mature, hardened, and very stable -- and follows an architecture prove in the industry for over 20 years on Netware.Out of curiously, is there anyone except for you using MDB?
Thank you,
Network General (now NetScout)
Several Others I do not have authority to name because of NDA agreements.
Jeff
Quoted 18 lines
Quoted 6 lines
Quoted 5 lines
And please check your patch style by using
scripts/checkpatch.pl. Your cording style seem to be different from linux coding style...Thank you,
--
Masami HiramatsuSoftware Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Divisione-mail: [email protected]
On Tue, Aug 05, 2008 at 12:26:35AM -0600, [email protected] wrote:
...
arch/x86/kernel/traps_32.c line 880
Quoted 11 lines
arch/x86/kernel/traps_32.c +4
-0@@ -850,6 +871,10 @@#ifdef CONFIG_KPROBES void __kprobes do_int3 (struct pt_regs *regs,long error_code) { +#ifdef CONFIG_MDB +if (mdb (BREAKPOINT_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB trace_hardirqs_fixup (); if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
Kprobes needs to be the first consumer of these exceptions (via notify_die); if the exception was due to a kprobe, it does its thing without requiring any user intervention. Here, for example, you can get into mdb for a kprobe breakpoint hit.
Please move the mdb hooks to after kprobes has been notified. Better still, integrate mdb to use the notify_die infrastructure and use a lower priority than what kprobes does for it.
Ananth
Quoted 21 lines
On Tue, Aug 05, 2008 at 12:26:35AM -0600, [email protected] wrote:
...arch/x86/kernel/traps_32.c line 880
Quoted 11 lines
arch/x86/kernel/traps_32.c +4
-0@@ -850,6 +871,10 @@#ifdef CONFIG_KPROBES void __kprobes do_int3 (struct pt_regs *regs,long error_code) { +#ifdef CONFIG_MDB +if (mdb (BREAKPOINT_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB trace_hardirqs_fixup (); if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)Kprobes needs to be the first consumer of these exceptions (via
notify_die); if the exception was due to a kprobe, it does its thing without requiring any user intervention. Here, for example, you can get into mdb for a kprobe breakpoint hit.
Quoted 6 lines
Please move the mdb hooks to after kprobes has been notified. Better still, integrate mdb to use the
notify_dieinfrastructure and use a lower priority than what kprobes does for it.Ananth
I have removed these hooks already and converted to debugger to use notify_die -- finished it last night as per Andi's suggestions. This code section has already been removed from reboot.c and traps_XX.c.
I'll post the new patch with the module based debugger later today.
Jeff
Quoted 12 lines · On Tue, Aug 5, 2008 at 11:56 AM, <[email protected]> wrote:
arch/x86/kernel/traps_32.c +4
-0@@ -850,6 +871,10 @@#ifdef CONFIG_KPROBES void __kprobes do_int3 (struct pt_regs *regs,long error_code) { +#ifdef CONFIG_MDB +if (mdb (BREAKPOINT_EXCEPTION , error_code, regs)) +return ; +#endif // CONFIG_MDB trace_hardirqs_fixup (); if (notify_die(DIE_INT3, "int3", regs, error_code, 3, SIGTRAP)
arch/x86/kernel/traps_32.c line 891
Quoted 2 lines
arch/x86/kernel/traps_32.c +0
-0@@ -865,6 +890,16 @@ }#endif
If the mdb() call modifies the IF flag in regs, then it should probably be called after trace_hardirqs_fixup. Best to keep it behind notify_die() ensuring that kprobes handles all breakpoints first. Otherwise at least the mdb function (and others in its call chain) should be marked as __kprobes.
-- Abhishek Sagar