diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 12:29:44 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-23 12:29:44 -0400 |
| commit | a20ae85abaefb02cc0edf19c34f78d19437c1cf1 (patch) | |
| tree | 13174b718a7f7b955b7d79f5427506ad62a3054e /kernel/debug | |
| parent | f0a5ec0e8da4521036799ced340172b2732845a8 (diff) | |
| parent | 1ba0c1720eb0de2d0f3abf84c0b128d10af520d1 (diff) | |
Merge tag 'for_linus-3.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb
Pull KGDB/KDB updates from Jason Wessel:
"Fixes:
- Fix KDB keyboard repeat scan codes and leaked keyboard events
- Fix kernel crash with kdb_printf() for users who compile new
kdb_printf()'s in early code
- Return all segment registers to gdb on x86_64
Features:
- KDB/KGDB hook the reboot notifier and end user can control if it
stops, detaches or does nothing (updated docs as well)
- Notify users who use CONFIG_DEBUG_RODATA to use hw breakpoints"
* tag 'for_linus-3.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jwessel/kgdb:
kdb: Add message about CONFIG_DEBUG_RODATA on failure to install breakpoint
kdb: Avoid using dbg_io_ops until it is initialized
kgdb,debug_core: add the ability to control the reboot notifier
KDB: Fix usability issues relating to the 'enter' key.
kgdb,debug-core,gdbstub: Hook the reboot notifier for debugger detach
kgdb: Respect that flush op is optional
kgdb: x86: Return all segment registers also in 64-bit mode
Diffstat (limited to 'kernel/debug')
| -rw-r--r-- | kernel/debug/debug_core.c | 33 | ||||
| -rw-r--r-- | kernel/debug/gdbstub.c | 10 | ||||
| -rw-r--r-- | kernel/debug/kdb/kdb_bp.c | 7 | ||||
| -rw-r--r-- | kernel/debug/kdb/kdb_io.c | 2 | ||||
| -rw-r--r-- | kernel/debug/kdb/kdb_keyboard.c | 95 | ||||
| -rw-r--r-- | kernel/debug/kdb/kdb_main.c | 3 | ||||
| -rw-r--r-- | kernel/debug/kdb/kdb_private.h | 7 |
7 files changed, 133 insertions, 24 deletions
diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c index 0d7c08784efb..3f88a45e6f0a 100644 --- a/kernel/debug/debug_core.c +++ b/kernel/debug/debug_core.c | |||
| @@ -41,6 +41,7 @@ | |||
| 41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
| 42 | #include <linux/sched.h> | 42 | #include <linux/sched.h> |
| 43 | #include <linux/sysrq.h> | 43 | #include <linux/sysrq.h> |
| 44 | #include <linux/reboot.h> | ||
| 44 | #include <linux/init.h> | 45 | #include <linux/init.h> |
| 45 | #include <linux/kgdb.h> | 46 | #include <linux/kgdb.h> |
| 46 | #include <linux/kdb.h> | 47 | #include <linux/kdb.h> |
| @@ -75,6 +76,8 @@ static int exception_level; | |||
| 75 | struct kgdb_io *dbg_io_ops; | 76 | struct kgdb_io *dbg_io_ops; |
| 76 | static DEFINE_SPINLOCK(kgdb_registration_lock); | 77 | static DEFINE_SPINLOCK(kgdb_registration_lock); |
| 77 | 78 | ||
| 79 | /* Action for the reboot notifiter, a global allow kdb to change it */ | ||
| 80 | static int kgdbreboot; | ||
| 78 | /* kgdb console driver is loaded */ | 81 | /* kgdb console driver is loaded */ |
| 79 | static int kgdb_con_registered; | 82 | static int kgdb_con_registered; |
| 80 | /* determine if kgdb console output should be used */ | 83 | /* determine if kgdb console output should be used */ |
| @@ -96,6 +99,7 @@ static int __init opt_kgdb_con(char *str) | |||
| 96 | early_param("kgdbcon", opt_kgdb_con); | 99 | early_param("kgdbcon", opt_kgdb_con); |
| 97 | 100 | ||
| 98 | module_param(kgdb_use_con, int, 0644); | 101 | module_param(kgdb_use_con, int, 0644); |
| 102 | module_param(kgdbreboot, int, 0644); | ||
| 99 | 103 | ||
| 100 | /* | 104 | /* |
| 101 | * Holds information about breakpoints in a kernel. These breakpoints are | 105 | * Holds information about breakpoints in a kernel. These breakpoints are |
| @@ -784,6 +788,33 @@ void __init dbg_late_init(void) | |||
| 784 | kdb_init(KDB_INIT_FULL); | 788 | kdb_init(KDB_INIT_FULL); |
| 785 | } | 789 | } |
| 786 | 790 | ||
| 791 | static int | ||
| 792 | dbg_notify_reboot(struct notifier_block *this, unsigned long code, void *x) | ||
| 793 | { | ||
| 794 | /* | ||
| 795 | * Take the following action on reboot notify depending on value: | ||
| 796 | * 1 == Enter debugger | ||
| 797 | * 0 == [the default] detatch debug client | ||
| 798 | * -1 == Do nothing... and use this until the board resets | ||
| 799 | */ | ||
| 800 | switch (kgdbreboot) { | ||
| 801 | case 1: | ||
| 802 | kgdb_breakpoint(); | ||
| 803 | case -1: | ||
| 804 | goto done; | ||
| 805 | } | ||
| 806 | if (!dbg_kdb_mode) | ||
| 807 | gdbstub_exit(code); | ||
| 808 | done: | ||
| 809 | return NOTIFY_DONE; | ||
| 810 | } | ||
| 811 | |||
| 812 | static struct notifier_block dbg_reboot_notifier = { | ||
| 813 | .notifier_call = dbg_notify_reboot, | ||
| 814 | .next = NULL, | ||
| 815 | .priority = INT_MAX, | ||
| 816 | }; | ||
| 817 | |||
| 787 | static void kgdb_register_callbacks(void) | 818 | static void kgdb_register_callbacks(void) |
| 788 | { | 819 | { |
| 789 | if (!kgdb_io_module_registered) { | 820 | if (!kgdb_io_module_registered) { |
| @@ -791,6 +822,7 @@ static void kgdb_register_callbacks(void) | |||
| 791 | kgdb_arch_init(); | 822 | kgdb_arch_init(); |
| 792 | if (!dbg_is_early) | 823 | if (!dbg_is_early) |
| 793 | kgdb_arch_late(); | 824 | kgdb_arch_late(); |
| 825 | register_reboot_notifier(&dbg_reboot_notifier); | ||
| 794 | atomic_notifier_chain_register(&panic_notifier_list, | 826 | atomic_notifier_chain_register(&panic_notifier_list, |
| 795 | &kgdb_panic_event_nb); | 827 | &kgdb_panic_event_nb); |
| 796 | #ifdef CONFIG_MAGIC_SYSRQ | 828 | #ifdef CONFIG_MAGIC_SYSRQ |
| @@ -812,6 +844,7 @@ static void kgdb_unregister_callbacks(void) | |||
| 812 | */ | 844 | */ |
| 813 | if (kgdb_io_module_registered) { | 845 | if (kgdb_io_module_registered) { |
| 814 | kgdb_io_module_registered = 0; | 846 | kgdb_io_module_registered = 0; |
| 847 | unregister_reboot_notifier(&dbg_reboot_notifier); | ||
| 815 | atomic_notifier_chain_unregister(&panic_notifier_list, | 848 | atomic_notifier_chain_unregister(&panic_notifier_list, |
| 816 | &kgdb_panic_event_nb); | 849 | &kgdb_panic_event_nb); |
| 817 | kgdb_arch_exit(); | 850 | kgdb_arch_exit(); |
diff --git a/kernel/debug/gdbstub.c b/kernel/debug/gdbstub.c index c22d8c28ad84..ce615e064482 100644 --- a/kernel/debug/gdbstub.c +++ b/kernel/debug/gdbstub.c | |||
| @@ -1111,6 +1111,13 @@ void gdbstub_exit(int status) | |||
| 1111 | unsigned char checksum, ch, buffer[3]; | 1111 | unsigned char checksum, ch, buffer[3]; |
| 1112 | int loop; | 1112 | int loop; |
| 1113 | 1113 | ||
| 1114 | if (!kgdb_connected) | ||
| 1115 | return; | ||
| 1116 | kgdb_connected = 0; | ||
| 1117 | |||
| 1118 | if (!dbg_io_ops || dbg_kdb_mode) | ||
| 1119 | return; | ||
| 1120 | |||
| 1114 | buffer[0] = 'W'; | 1121 | buffer[0] = 'W'; |
| 1115 | buffer[1] = hex_asc_hi(status); | 1122 | buffer[1] = hex_asc_hi(status); |
| 1116 | buffer[2] = hex_asc_lo(status); | 1123 | buffer[2] = hex_asc_lo(status); |
| @@ -1129,5 +1136,6 @@ void gdbstub_exit(int status) | |||
| 1129 | dbg_io_ops->write_char(hex_asc_lo(checksum)); | 1136 | dbg_io_ops->write_char(hex_asc_lo(checksum)); |
| 1130 | 1137 | ||
| 1131 | /* make sure the output is flushed, lest the bootloader clobber it */ | 1138 | /* make sure the output is flushed, lest the bootloader clobber it */ |
| 1132 | dbg_io_ops->flush(); | 1139 | if (dbg_io_ops->flush) |
| 1140 | dbg_io_ops->flush(); | ||
| 1133 | } | 1141 | } |
diff --git a/kernel/debug/kdb/kdb_bp.c b/kernel/debug/kdb/kdb_bp.c index 20059ef4459a..8418c2f8ec5d 100644 --- a/kernel/debug/kdb/kdb_bp.c +++ b/kernel/debug/kdb/kdb_bp.c | |||
| @@ -153,6 +153,13 @@ static int _kdb_bp_install(struct pt_regs *regs, kdb_bp_t *bp) | |||
| 153 | } else { | 153 | } else { |
| 154 | kdb_printf("%s: failed to set breakpoint at 0x%lx\n", | 154 | kdb_printf("%s: failed to set breakpoint at 0x%lx\n", |
| 155 | __func__, bp->bp_addr); | 155 | __func__, bp->bp_addr); |
| 156 | #ifdef CONFIG_DEBUG_RODATA | ||
| 157 | if (!bp->bp_type) { | ||
| 158 | kdb_printf("Software breakpoints are unavailable.\n" | ||
| 159 | " Change the kernel CONFIG_DEBUG_RODATA=n\n" | ||
| 160 | " OR use hw breaks: help bph\n"); | ||
| 161 | } | ||
| 162 | #endif | ||
| 156 | return 1; | 163 | return 1; |
| 157 | } | 164 | } |
| 158 | return 0; | 165 | return 0; |
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 4802eb5840e1..9b5f17da1c56 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c | |||
| @@ -689,7 +689,7 @@ kdb_printit: | |||
| 689 | if (!dbg_kdb_mode && kgdb_connected) { | 689 | if (!dbg_kdb_mode && kgdb_connected) { |
| 690 | gdbstub_msg_write(kdb_buffer, retlen); | 690 | gdbstub_msg_write(kdb_buffer, retlen); |
| 691 | } else { | 691 | } else { |
| 692 | if (!dbg_io_ops->is_console) { | 692 | if (dbg_io_ops && !dbg_io_ops->is_console) { |
| 693 | len = strlen(kdb_buffer); | 693 | len = strlen(kdb_buffer); |
| 694 | cp = kdb_buffer; | 694 | cp = kdb_buffer; |
| 695 | while (len--) { | 695 | while (len--) { |
diff --git a/kernel/debug/kdb/kdb_keyboard.c b/kernel/debug/kdb/kdb_keyboard.c index 4bca634975c0..118527aa60ea 100644 --- a/kernel/debug/kdb/kdb_keyboard.c +++ b/kernel/debug/kdb/kdb_keyboard.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */ | 25 | #define KBD_STAT_MOUSE_OBF 0x20 /* Mouse output buffer full */ |
| 26 | 26 | ||
| 27 | static int kbd_exists; | 27 | static int kbd_exists; |
| 28 | static int kbd_last_ret; | ||
| 28 | 29 | ||
| 29 | /* | 30 | /* |
| 30 | * Check if the keyboard controller has a keypress for us. | 31 | * Check if the keyboard controller has a keypress for us. |
| @@ -90,8 +91,11 @@ int kdb_get_kbd_char(void) | |||
| 90 | return -1; | 91 | return -1; |
| 91 | } | 92 | } |
| 92 | 93 | ||
| 93 | if ((scancode & 0x80) != 0) | 94 | if ((scancode & 0x80) != 0) { |
| 95 | if (scancode == 0x9c) | ||
| 96 | kbd_last_ret = 0; | ||
| 94 | return -1; | 97 | return -1; |
| 98 | } | ||
| 95 | 99 | ||
| 96 | scancode &= 0x7f; | 100 | scancode &= 0x7f; |
| 97 | 101 | ||
| @@ -178,35 +182,82 @@ int kdb_get_kbd_char(void) | |||
| 178 | return -1; /* ignore unprintables */ | 182 | return -1; /* ignore unprintables */ |
| 179 | } | 183 | } |
| 180 | 184 | ||
| 181 | if ((scancode & 0x7f) == 0x1c) { | 185 | if (scancode == 0x1c) { |
| 182 | /* | 186 | kbd_last_ret = 1; |
| 183 | * enter key. All done. Absorb the release scancode. | 187 | return 13; |
| 184 | */ | 188 | } |
| 189 | |||
| 190 | return keychar & 0xff; | ||
