Add debugger entry points for MIPS
PATCH 21/31 Add debugger entry points for MIPS
This patch series adds an export which can be set by system debuggers to direct the hard lockup and soft lockup detector to trigger a breakpoint exception and enter a debugger if one is active. It is assumed that if someone sets this variable, then an breakpoint handler of some sort will be actively loaded or registered via the notify die handler chain.
This addition is extremely useful for debugging hard and soft lockups real time and quickly from a console debugger.
--- arch/mips/include/asm/kdebug.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/mips/include/asm/kdebug.h +12 -0
@@ -16,4 +16,16 @@ enum die_val { DIE_UPROBE_XOL, }; + +void arch_breakpoint (void ) +{ + __asm__ __volatile__( +".globl breakinst\n\t" +".set\tnoreorder\n\t" +"nop\n" +"breakinst:\tbreak\n\t" +"nop\n\t" +".set\treorder" ); +} +#endif /* _ASM_MIPS_KDEBUG_H */
Signature · 1 line
1.8.3.1
kbuild test robot
build botreproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Jeffrey,
[auto build test ERROR on v4.5-rc1]
[also build test ERROR on next-20160128]
[cannot apply to tip/x86/core]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Jeffrey-Merkey/Add-hard-soft-lockup-debugger-entry-points/20160129-035852 config: mips-jz4740 (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=mips
All errors (new ones prefixed by >>):
kernel/sys.o: In function `arch_breakpoint':
>> sys.c:(.text+0x880): multiple definition of `arch_breakpoint' kernel/sysctl.o:sysctl.c:(.text+0x134c): first defined here kernel/sys.o: In function `arch_breakpoint': >> sys.c:(.text+0x884): multiple definition of `breakinst'
kernel/sysctl.o:sysctl.c:(.text+0x1350): first defined here kernel/notifier.o: In function `arch_breakpoint':
notifier.c:(.text+0x678): multiple definition of arch_breakpoint' kernel/sysctl.o:sysctl.c:(.text+0x134c): first defined here kernel/notifier.o: In function arch_breakpoint':
notifier.c:(.text+0x67c): multiple definition of breakinst' kernel/sysctl.o:sysctl.c:(.text+0x1350): first defined here kernel/sched/built-in.o: In function arch_breakpoint':
(.text+0x3b0): multiple definition of arch_breakpoint' kernel/sysctl.o:sysctl.c:(.text+0x134c): first defined here kernel/sched/built-in.o: In function arch_breakpoint':
(.text+0x3b4): multiple definition of breakinst' kernel/sysctl.o:sysctl.c:(.text+0x1350): first defined here kernel/kprobes.o: In function arch_breakpoint':
kprobes.c:(.text+0x1690): multiple definition of arch_breakpoint' kernel/sysctl.o:sysctl.c:(.text+0x134c): first defined here kernel/kprobes.o: In function arch_breakpoint':
kprobes.c:(.text+0x1694): multiple definition of `breakinst' kernel/sysctl.o:sysctl.c:(.text+0x1350): first defined here
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 8 lines · Jeffrey Merkey
This patch series adds an export which can be set by system debuggers to direct the hard lockup and soft lockup detector to trigger a breakpoint exception and enter a debugger if one is active. It is assumed that if someone sets this variable, then an breakpoint handler of some sort will be actively loaded or registered via the notify die handler chain.
This addition is extremely useful for debugging hard and soft lockups real time and quickly from a console debugger.
What's the intended use case for this hook and what do you call a console
debugger?
I'm asking because from the debugging perspective the Linux kernel is a
bare metal application and for such the BREAK instruction is not the usual choice on the MIPS target. This instruction is normally used for userland debugging, it traps to the kernel and is handled there. Furthermore there are a few other applications of this instruction defined as a part of the MIPS ABI, also handled by the kernel, determined by the breakpoint code embedded with the instruction word, e.g. to trap integer division errors. See arch/mips/include/uapi/asm/break.h for the codes defined so far.
All this means the trap may not be appropriate for debugging the kernel
itself as you don't want to intercept it or the system won't run correctly. You'd have to hook into the kernel itself to intercept it too.
But if you do have a working debug environment already set up around this
arrangement, then it might be fine after all. In that case I think using a non-zero breakpoint code would make sense though, as 0 is often treated as a random (spurious) trap (it was used by IRIX though). Or do you detect it by the symbol name somehow?
I've got a couple of further notes on the patch itself below.
arch/mips/include/asm/kdebug.h enum die_val { · line 23
Quoted 13 lines
arch/mips/include/asm/kdebug.h +5
-0@@ -16,4 +16,16 @@ enum die_val { DIE_UPROBE_XOL, }; + +void arch_breakpoint (void ) +{ + __asm__ __volatile__( + ".globl breakinst\n\t"
Please keep formatting consistent -- the rest of code below uses `\t' as
the separator, so use it here as well. We don't have an established inline assembly formatting style, so please just keep your chosen one consistent.
arch/mips/include/asm/kdebug.h enum die_val { · line 31
Quoted 8 lines
arch/mips/include/asm/kdebug.h +7
-0+".set\tnoreorder\n\t" +"nop\n" +"breakinst:\tbreak\n\t" +"nop\n\t" + ".set\treorder"); +} +#endif /* _ASM_MIPS_KDEBUG_H */
Why do you need these NOPs around the breakpoint? You also need to markbreakinst' as a function symbol (.aent' might do) or otherwise you'll get garbled disassembly if this is built as microMIPS code.
Maciej
Quoted 68 lines · Maciej W. Rozycki
Quoted 8 lines · Jeffrey Merkey
This patch series adds an export which can be set by system debuggers to direct the hard lockup and soft lockup detector to trigger a breakpoint exception and enter a debugger if one is active. It is assumed that if someone sets this variable, then an breakpoint handler of some sort will be actively loaded or registered via the notify die handler chain.
This addition is extremely useful for debugging hard and soft lockups real time and quickly from a console debugger.
What's the intended use case for this hook and what do you call a console
debugger?I'm asking because from the debugging perspective the Linux kernel is a
bare metal application and for such the BREAK instruction is not the usual choice on the MIPS target. This instruction is normally used for userland debugging, it traps to the kernel and is handled there. Furthermore there are a few other applications of this instruction defined as a part of the MIPS ABI, also handled by the kernel, determined by the breakpoint code embedded with the instruction word, e.g. to trap integer division errors. Seearch/mips/include/uapi/asm/break.hfor the codes defined so far.All this means the trap may not be appropriate for debugging the kernel
itself as you don't want to intercept it or the system won't run correctly. You'd have to hook into the kernel itself to intercept it too.But if you do have a working debug environment already set up around this
arrangement, then it might be fine after all. In that case I think using a non-zero breakpoint code would make sense though, as 0 is often treated as a random (spurious) trap (it was used by IRIX though). Or do you detect it by the symbol name somehow?I've got a couple of further notes on the patch itself below.
Quoted 6 lines
arch/mips/include/asm/kdebug.h +0
-0arch/mips/include/asm/kdebug.h enum die_val { · line 23
Quoted 8 lines
arch/mips/include/asm/kdebug.h +5
-0@@ -16,4 +16,16 @@ enum die_val { DIE_UPROBE_XOL, }; + +void arch_breakpoint (void ) +{ + __asm__ __volatile__( + ".globl breakinst\n\t"Please keep formatting consistent -- the rest of code below uses `\t' as
the separator, so use it here as well. We don't have an established inline assembly formatting style, so please just keep your chosen one consistent.arch/mips/include/asm/kdebug.h enum die_val { · line 31
Quoted 8 lines
arch/mips/include/asm/kdebug.h +7
-0+".set\tnoreorder\n\t" +"nop\n" +"breakinst:\tbreak\n\t" +"nop\n\t" + ".set\treorder"); +} +#endif /* _ASM_MIPS_KDEBUG_H */ Why do you need these NOPs around the breakpoint? You also need to mark
breakinst' as a function symbol (.aent' might do) or otherwise you'll get garbled disassembly if this is built as microMIPS code.
Quoted 2 lines
Maciej
You can drop this patch series, I am rethinking a better way to do this.
Jeff
Quoted 1 line · Jeff Merkey
You can drop this patch series, I am rethinking a better way to do this.
Dropped.
Ralf