Patch for debug setcontext
Quoted 3 lines · Kumar Gala
I'm guessing, this should really be #if
defined(CONFIG_4xx)||defined(CONFIG_BOOKE)
There are a number of similar cases later in this code as well.
That may be the case, but it is very confusing in entry.S. The dbcr0 register seems to only be defined on 4xx processor, not on book E. Look, for instance, at load_4xx_dbcr0:, it is only defined if 4xx is enabled, not if book E is enabled.
-Corey
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
I misspoke a little. Consider the following code in entry.S:
#ifdef CONFIG_4xx
/* Check whether this process has its own DBCR0 value */
lwz r0,PTRACE(r2)
andi. r0,r0,PT_PTRACED
bnel- load_4xx_dbcr0
#endif
Do we need to add the book E define to this, too?
-Corey
Quoted 7 lines · Corey Minyard
Quoted 3 lines · Kumar Gala
I'm guessing, this should really be #if
defined(CONFIG_4xx)||defined(CONFIG_BOOKE)
There are a number of similar cases later in this code as well.
Quoted 8 lines
That may be the case, but it is very confusing in
entry.S. The dbcr0 register seems to only be defined on 4xx processor, not on book E. Look, for instance, atload_4xx_dbcr0:, it is only defined if 4xx is enabled, not if book E is enabled.-Corey
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Quoted 10 lines · Corey Minyard
Quoted 3 lines · Kumar Gala
I'm guessing, this should really be #if
defined(CONFIG_4xx)||defined(CONFIG_BOOKE)
There are a number of similar cases later in this code as well.That may be the case, but it is very confusing in
entry.S. The dbcr0 register seems to only be defined on 4xx processor, not on book E. Look, for instance, atload_4xx_dbcr0:, it is only defined if 4xx is enabled, not if book E is enabled.
Corey,
I think you may have an old linux-2.6 tree. I remember renaming load_4xx_dbcr0 to just load_dbcr0 because of such issues. Hopefully a newer tree (one with e500 support, if its going head_e500.S) should be cleaner. If not, let me know.
- kumar
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
I'm using stock 2.6.7. Is there a different kernel I should be using?
-Corey
Quoted 15 lines · Kumar Gala
Quoted 10 lines · Corey Minyard
Quoted 3 lines · Kumar Gala
I'm guessing, this should really be #if
defined(CONFIG_4xx)||defined(CONFIG_BOOKE)
There are a number of similar cases later in this code as well.That may be the case, but it is very confusing in
entry.S. The dbcr0 register seems to only be defined on 4xx processor, not on book E. Look, for instance, atload_4xx_dbcr0:, it is only defined if 4xx is enabled, not if book E is enabled.
Quoted 9 lines
Corey,
I think you may have an old linux-2.6 tree. I remember renaming
load_4xx_dbcr0to justload_dbcr0because of such issues. Hopefully a newer tree (one with e500 support, if its goinghead_e500.S) should be cleaner. If not, let me know.- kumar
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
If you can look at on of the 2.6.8-rc releases that would be good. In adding support for e500, I cleaned up some CONFIG_BOOKE references, and changed the load_4xx_dbcr0 code to just load_dbcr0 since it applies to both 4xx and Book-E.
thanks
- kumar
Quoted 30 lines · Corey Minyard
I'm using stock 2.6.7. Is there a different kernel I should be using?
-Corey
Quoted 24 lines · Kumar Gala
Quoted 10 lines · Corey Minyard
Quoted 3 lines · Kumar Gala
I'm guessing, this should really be #if
defined(CONFIG_4xx)||defined(CONFIG_BOOKE)
There are a number of similar cases later in this code as well.That may be the case, but it is very confusing in
entry.S. The dbcr0 register seems to only be defined on 4xx processor, not on book E. Look, for instance, atload_4xx_dbcr0:, it is only defined if 4xx is enabled, not if book E is enabled.Corey,
I think you may have an old linux-2.6 tree. I remember renaming
load_4xx_dbcr0to justload_dbcr0because of such issues. Hopefully a newer tree (one with e500 support, if its goinghead_e500.S) should be cleaner. If not, let me know.- kumar
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
Patch for debug setcontext, relative to 2.6.8
Thanks to Kumar, I moved to a new kernel and it makes more sense now. Patch is attached.
ppc/kernel/entry.S renamed from ppc/kernel/entry.S.sct +17 -13
@@ -111,8 +111,10 @@ addi r11,r1,STACK_FRAME_OVERHEAD stw r11,PT_REGS(r12) #if defined(CONFIG_40x) || defined(CONFIG_BOOKE) - lwz r12,PTRACE-THREAD(r12) - andi. r12,r12,PT_PTRACED + /* Check to see if the dbcr0 register is set up to debug. Use the + single-step bit to do this. */ + lwz r12,THREAD_DBCR0(r12) + andis. r12,r12,DBCR0_IC@h beq+ 3f /* From user and task is ptraced - load up global dbcr0 */ li r12,-1 /* clear all pending debug events */
@@ -242,9 +244,10 @@ bne- syscall_exit_work syscall_exit_cont: #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) - /* If the process has its own DBCR0 value, load it up */ - lwz r0,PTRACE(r2) - andi. r0,r0,PT_PTRACED + /* If the process has its own DBCR0 value, load it up. The single + step bit tells us that dbcr0 should be loaded. */ + lwz r0,THREAD+THREAD_DBCR0(r2) + andis. r10,r0,DBCR0_IC@h bnel- load_dbcr0 #endif stwcx. r0,0,r1 /* to clear the reservation */
@@ -599,9 +602,10 @@ restore_user: #if defined(CONFIG_4xx) || defined(CONFIG_BOOKE) - /* Check whether this process has its own DBCR0 value */ - lwz r0,PTRACE(r2) - andi. r0,r0,PT_PTRACED + /* Check whether this process has its own DBCR0 value. The single + step bit tells us that dbcr0 should be loaded. */ + lwz r0,THREAD+THREAD_DBCR0(r2) + andis. r10,r0,DBCR0_IC@h bnel- load_dbcr0 #endif
@@ -876,17 +880,17 @@ /* * Load the DBCR0 value for a task that is being ptraced, - * having first saved away the global DBCR0. + * having first saved away the global DBCR0. Note that r0 + * has the dbcr0 value to set upon entry to this. */ load_dbcr0: - mfmsr r0 /* first disable debug exceptions */ - rlwinm r0,r0,0,~MSR_DE - mtmsr r0 + mfmsr r10 /* first disable debug exceptions */ + rlwinm r10,r10,0,~MSR_DE + mtmsr r10 isync mfspr r10,SPRN_DBCR0 lis r11,global_dbcr0@ha addi r11,r11,global_dbcr0@l - lwz r0,THREAD+THREAD_DBCR0(r2) stw r10,0(r11) mtspr SPRN_DBCR0,r0 lwz r10,4(r11)
ppc/kernel/misc.S renamed from ppc/kernel/misc.S.sct +1 -1
@@ -1437,7 +1437,7 @@ .long sys_fstatfs64 .long ppc_fadvise64_64 .long sys_ni_syscall /* 255 - rtas (used on ppc64) */ - .long sys_ni_syscall /* 256 reserved for sys_debug_setcontext */ + .long sys_debug_setcontext .long sys_ni_syscall /* 257 reserved for vserver */ .long sys_ni_syscall /* 258 reserved for new sys_remap_file_pages */ .long sys_ni_syscall /* 259 reserved for new sys_mbind */
ppc/kernel/signal.c renamed from ppc/kernel/signal.c.sct +90 -0
96 lines not on this page · raw message
ppc/kernel/traps.c renamed from ppc/kernel/traps.c.sct +1 -1
@@ -543,7 +543,7 @@void SingleStepException (struct pt_regs *regs) { - regs->msr &= ~MSR_SE ;/* Turn off 'trace' bit */ + regs->msr &= ~(MSR_SE |MSR_BE );/* Turn off 'trace' bits */ if (debugger_sstep (regs))return ;_exception (SIGTRAP , regs,TRAP_TRACE ,0 );
asm-ppc/signal.h renamed from asm-ppc/signal.h.sct +19 -0
@@ -157,4 +157,23 @@#define ptrace_signal_deliver (regs, cookie) do { } while (0)#endif /* __KERNEL__ */ +/* +* These are parameters to dbg_sigreturn syscall. They enable or +* disable certain debugging things that can be done from signal +* handlers. The dbg_sigreturn syscall *must* be called from a +* SA_SIGINFO signal so the ucontext can be passed to it. It takes an +* array of struct sig_dbg_op, which has the debug operations to +* perform before returning from the signal. +*/ +struct sig_dbg_op { +int dbg_type; +unsigned long dbg_value; +}; + +/* Enable or disable single-stepping. The value sets the state. */ +#define SIG_DBG_SINGLE_STEPPING 1 + +/* Enable or disable branch tracing. The value sets the state. */ +#define SIG_DBG_BRANCH_TRACING 2 +#endif
asm-ppc/unistd.h renamed from asm-ppc/unistd.h.sct +1 -1
@@ -260,7 +260,7 @@#define __NR_fstatfs64 253#define __NR_fadvise64_64 254#define __NR_rtas 255 -/* Number 256 is reserved for sys_debug_setcontext */ +#define __NR_sys_debug_setcontext 256/* Number 257 is reserved for vserver */ /* Number 258 is reserved for new sys_remap_file_pages */ /* Number 259 is reserved for new sys_mbind */