Skip to contentSkip to conversation

Fix kgdb on little endian ppc64le

PATCH Applied Balbir Singh 3 participants 6 messages Feb 1, 2016 – Feb 22, 2016 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix kgdb on little endian ppc64le

From: Balbir Singh <[email protected]>

I spent some time trying to use kgdb and debugged my inability to resume from kgdb_handle_breakpoint(). NIP is not incremented and that leads to a loop in the debugger.

I've tested this lightly on a virtual instance with KDB enabled. After the patch, I am able to get the "go" command to work as expected

---
 arch/powerpc/kernel/kgdb.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/kernel/kgdb.c +4 -0
index e77c3cc..92c8f80 100644
@@ -445,7 +445,11 @@ int kgdb_arch_handle_exception(int vector, int signo, int err_code,
  * Global data
  */
 struct kgdb_arch arch_kgdb_ops = {
+#ifdef __LITTLE_ENDIAN__
+	.gdb_bpt_instr = {0x08, 0x10, 0x82, 0x7d},
+#else
 	.gdb_bpt_instr = {0x7d, 0x82, 0x10, 0x08},
+#endif /* __LITTLE_ENDIAN__ */
 };
 
 static int kgdb_not_implemented(struct pt_regs *regs)
Signature · 1 line
2.5.0
#1 lore raw
Quoted 11 lines · Balbir Singh

From: Balbir Singh <[email protected]>

I spent some time trying to use kgdb and debugged my inability to resume from kgdb_handle_breakpoint(). NIP is not incremented and that leads to a loop in the debugger.

I've tested this lightly on a virtual instance with KDB enabled. After the patch, I am able to get the "go" command to work as expected

Should this be Cc'd to stable?

Signature · 3 lines
Andrew Donnellan              Software Engineer, OzLabs
[email protected]  Australia Development Lab, Canberra
+61 2 6201 8874 (work)        IBM Australia Limited
#2 lore raw
Quoted 7 lines · On Mon, 1 Feb 2016 21:39:00 +1100 Andrew Donnellan…
Quoted 6 lines · Balbir Singh

From: Balbir Singh <[email protected]>

I spent some time trying to use kgdb and debugged my inability to resume from kgdb_handle_breakpoint(). NIP is not incremented and that leads to a loop in the debugger.

Quoted 9 lines
Quoted 5 lines

I've tested this lightly on a virtual instance with KDB enabled. After the patch, I am able to get the "go" command to work as expected

Should this be Cc'd to stable?

Good suggestion, Michael? I can repost this to stable if required?

Balbir Singh.

#3 lore raw
In reply to Balbir Singh
Quoted 9 lines · Balbir Singh

From: Balbir Singh <[email protected]>

I spent some time trying to use kgdb and debugged my inability to resume from kgdb_handle_breakpoint(). NIP is not incremented and that leads to a loop in the debugger.

I've tested this lightly on a virtual instance with KDB enabled. After the patch, I am able to get the "go" command to work as expected

The test suite isn't working for me (I think?), so I think maybe we need something more?

KGDB: Registered I/O driver kgdbts
kgdbts:RUN plant and detach test

Entering kdb (current=0xc0000001fefc0000, pid 1) on processor 12 due to Keyboard Entry [12]kdb> kgdbts:RUN sw breakpoint test
kgdbts: BP mismatch c00000000018e2cc expected c00000000061c510
KGDB: re-enter exception: ALL breakpoints killed

  CPU: 12 PID: 1 Comm: swapper/0 Not tainted 4.5.0-rc3-00006-g893791ee8b01 #5
  Call Trace:
  [c0000001fb082e10] [c0000000009c4608] dump_stack+0xb0/0xf0 (unreliable)
  [c0000001fb082e50] [c00000000018fa8c] kgdb_handle_exception+0x2ac/0x2c0
  [c0000001fb082f20] [c0000000000405f4] kgdb_handle_breakpoint+0x64/0xa0
  [c0000001fb082f50] [c0000000009bcee4] program_check_exception+0x144/0x370
  [c0000001fb082fc0] [c000000000006244] program_check_common+0x144/0x180
  --- interrupt: 700 at check_and_rewind_pc+0x100/0x130
      LR = check_and_rewind_pc+0xfc/0x130
  [c0000001fb083340] [c00000000061bfc0] validate_simple_test+0x60/0x170
  [c0000001fb083370] [c00000000061c784] run_simple_test+0x194/0x3c0
  [c0000001fb0833f0] [c00000000061c17c] kgdbts_put_char+0x4c/0x70
  [c0000001fb083420] [c0000000001902e0] put_packet+0x130/0x210
  [c0000001fb083470] [c000000000191338] gdb_serial_stub+0x478/0x1110
  [c0000001fb083560] [c00000000018f19c] kgdb_cpu_enter+0x3fc/0x800
  [c0000001fb083660] [c00000000018f970] kgdb_handle_exception+0x190/0x2c0
  [c0000001fb083730] [c0000000000405f4] kgdb_handle_breakpoint+0x64/0xa0
  [c0000001fb083760] [c0000000009bcee4] program_check_exception+0x144/0x370
  [c0000001fb0837d0] [c000000000006244] program_check_common+0x144/0x180
  --- interrupt: 700 at kgdb_breakpoint+0x3c/0x70
      LR = run_breakpoint_test+0xa4/0x120
  [c0000001fb083ac0] [0000000000000000]           (null) (unreliable)
  [c0000001fb083ae0] [c00000000061d714] run_breakpoint_test+0xa4/0x120
  [c0000001fb083b50] [c00000000061dcb4] configure_kgdbts+0x2c4/0x6e0
  [c0000001fb083c30] [c00000000000b3d0] do_one_initcall+0xd0/0x250
  [c0000001fb083d00] [c000000000cc42f8] kernel_init_freeable+0x270/0x350
  [c0000001fb083dc0] [c00000000000bd3c] kernel_init+0x2c/0x150
  [c0000001fb083e30] [c0000000000095b0] ret_from_kernel_thread+0x5c/0xac
  Kernel panic - not syncing: Recursive entry to debugger
  CPU: 12 PID: 1 Comm: swapper/0 Not tainted 4.5.0-rc3-00006-g893791ee8b01 #5
  Call Trace:
  [c0000001fb082d70] [c0000000009c4608] dump_stack+0xb0/0xf0 (unreliable)
  [c0000001fb082db0] [c0000000009c2edc] panic+0x138/0x300
  [c0000001fb082e50] [c00000000018fa9c] kgdb_handle_exception+0x2bc/0x2c0
  [c0000001fb082f20] [c0000000000405f4] kgdb_handle_breakpoint+0x64/0xa0
  [c0000001fb082f50] [c0000000009bcee4] program_check_exception+0x144/0x370
  [c0000001fb082fc0] [c000000000006244] program_check_common+0x144/0x180
  --- interrupt: 700 at check_and_rewind_pc+0x100/0x130
      LR = check_and_rewind_pc+0xfc/0x130
  [c0000001fb083340] [c00000000061bfc0] validate_simple_test+0x60/0x170
  [c0000001fb083370] [c00000000061c784] run_simple_test+0x194/0x3c0
  [c0000001fb0833f0] [c00000000061c17c] kgdbts_put_char+0x4c/0x70
  [c0000001fb083420] [c0000000001902e0] put_packet+0x130/0x210
  [c0000001fb083470] [c000000000191338] gdb_serial_stub+0x478/0x1110
  [c0000001fb083560] [c00000000018f19c] kgdb_cpu_enter+0x3fc/0x800
  [c0000001fb083660] [c00000000018f970] kgdb_handle_exception+0x190/0x2c0
  [c0000001fb083730] [c0000000000405f4] kgdb_handle_breakpoint+0x64/0xa0
  [c0000001fb083760] [c0000000009bcee4] program_check_exception+0x144/0x370
  [c0000001fb0837d0] [c000000000006244] program_check_common+0x144/0x180
  --- interrupt: 700 at kgdb_breakpoint+0x3c/0x70
      LR = run_breakpoint_test+0xa4/0x120
  [c0000001fb083ac0] [0000000000000000]           (null) (unreliable)
  [c0000001fb083ae0] [c00000000061d714] run_breakpoint_test+0xa4/0x120
  [c0000001fb083b50] [c00000000061dcb4] configure_kgdbts+0x2c4/0x6e0
  [c0000001fb083c30] [c00000000000b3d0] do_one_initcall+0xd0/0x250
  [c0000001fb083d00] [c000000000cc42f8] kernel_init_freeable+0x270/0x350
  [c0000001fb083dc0] [c00000000000bd3c] kernel_init+0x2c/0x150
  [c0000001fb083e30] [c0000000000095b0] ret_from_kernel_thread+0x5c/0xac
  Rebooting in 10 seconds..

cheers

#4 lore raw
Quoted 74 lines · Michael Ellerman
Quoted 9 lines · Balbir Singh

From: Balbir Singh <[email protected]>

I spent some time trying to use kgdb and debugged my inability to resume from kgdb_handle_breakpoint(). NIP is not incremented and that leads to a loop in the debugger.

I've tested this lightly on a virtual instance with KDB enabled. After the patch, I am able to get the "go" command to work as expected

The test suite isn't working for me (I think?), so I think maybe we need something more?

  KGDB: Registered I/O driver kgdbts
  kgdbts:RUN plant and detach test

  Entering kdb (current=0xc0000001fefc0000, pid 1) on processor 12 due to Keyboard Entry
  [12]kdb> kgdbts:RUN sw breakpoint test
  kgdbts: BP mismatch c00000000018e2cc expected c00000000061c510
  KGDB: re-enter exception: ALL breakpoints killed

  CPU: 12 PID: 1 Comm: swapper/0 Not tainted 4.5.0-rc3-00006-g893791ee8b01 #5
  Call Trace:
  [c0000001fb082e10] [c0000000009c4608] dump_stack+0xb0/0xf0 (unreliable)
  [c0000001fb082e50] [c00000000018fa8c] kgdb_handle_exception+0x2ac/0x2c0
  [c0000001fb082f20] [c0000000000405f4] kgdb_handle_breakpoint+0x64/0xa0
  [c0000001fb082f50] [c0000000009bcee4] program_check_exception+0x144/0x370
  [c0000001fb082fc0] [c000000000006244] program_check_common+0x144/0x180
  --- interrupt: 700 at check_and_rewind_pc+0x100/0x130
      LR = check_and_rewind_pc+0xfc/0x130
  [c0000001fb083340] [c00000000061bfc0] validate_simple_test+0x60/0x170
  [c0000001fb083370] [c00000000061c784] run_simple_test+0x194/0x3c0
  [c0000001fb0833f0] [c00000000061c17c] kgdbts_put_char+0x4c/0x70
  [c0000001fb083420] [c0000000001902e0] put_packet+0x130/0x210
  [c0000001fb083470] [c000000000191338] gdb_serial_stub+0x478/0x1110
  [c0000001fb083560] [c00000000018f19c] kgdb_cpu_enter+0x3fc/0x800
  [c0000001fb083660] [c00000000018f970] kgdb_handle_exception+0x190/0x2c0
  [c0000001fb083730] [c0000000000405f4] kgdb_handle_breakpoint+0x64/0xa0
  [c0000001fb083760] [c0000000009bcee4] program_check_exception+0x144/0x370
  [c0000001fb0837d0] [c000000000006244] program_check_common+0x144/0x180
  --- interrupt: 700 at kgdb_breakpoint+0x3c/0x70
      LR = run_breakpoint_test+0xa4/0x120

  [c0000001fb083ac0] [0000000000000000]           (null) (unreliable) [c0000001fb083ae0] [c00000000061d714] run_breakpoint_test+0xa4/0x120 [c0000001fb083b50] [c00000000061dcb4] configure_kgdbts+0x2c4/0x6e0 [c0000001fb083c30] [c00000000000b3d0] do_one_initcall+0xd0/0x250 [c0000001fb083d00] [c000000000cc42f8] kernel_init_freeable+0x270/0x350 [c0000001fb083dc0] [c00000000000bd3c] kernel_init+0x2c/0x150 [c0000001fb083e30] [c0000000000095b0] ret_from_kernel_thread+0x5c/0xac

  Kernel panic - not syncing: Recursive entry to debugger
  CPU: 12 PID: 1 Comm: swapper/0 Not tainted 4.5.0-rc3-00006-g893791ee8b01 #5
  Call Trace:
  [c0000001fb082d70] [c0000000009c4608] dump_stack+0xb0/0xf0 (unreliable)
  [c0000001fb082db0] [c0000000009c2edc] panic+0x138/0x300
  [c0000001fb082e50] [c00000000018fa9c] kgdb_handle_exception+0x2bc/0x2c0
  [c0000001fb082f20] [c0000000000405f4] kgdb_handle_breakpoint+0x64/0xa0
  [c0000001fb082f50] [c0000000009bcee4] program_check_exception+0x144/0x370
  [c0000001fb082fc0] [c000000000006244] program_check_common+0x144/0x180
  --- interrupt: 700 at check_and_rewind_pc+0x100/0x130
      LR = check_and_rewind_pc+0xfc/0x130
  [c0000001fb083340] [c00000000061bfc0] validate_simple_test+0x60/0x170
  [c0000001fb083370] [c00000000061c784] run_simple_test+0x194/0x3c0
  [c0000001fb0833f0] [c00000000061c17c] kgdbts_put_char+0x4c/0x70
  [c0000001fb083420] [c0000000001902e0] put_packet+0x130/0x210
  [c0000001fb083470] [c000000000191338] gdb_serial_stub+0x478/0x1110
  [c0000001fb083560] [c00000000018f19c] kgdb_cpu_enter+0x3fc/0x800
  [c0000001fb083660] [c00000000018f970] kgdb_handle_exception+0x190/0x2c0
  [c0000001fb083730] [c0000000000405f4] kgdb_handle_breakpoint+0x64/0xa0
  [c0000001fb083760] [c0000000009bcee4] program_check_exception+0x144/0x370
  [c0000001fb0837d0] [c000000000006244] program_check_common+0x144/0x180
  --- interrupt: 700 at kgdb_breakpoint+0x3c/0x70
      LR = run_breakpoint_test+0xa4/0x120
Quoted 9 lines

  [c0000001fb083ac0] [0000000000000000]           (null) (unreliable) [c0000001fb083ae0] [c00000000061d714] run_breakpoint_test+0xa4/0x120 [c0000001fb083b50] [c00000000061dcb4] configure_kgdbts+0x2c4/0x6e0 [c0000001fb083c30] [c00000000000b3d0] do_one_initcall+0xd0/0x250 [c0000001fb083d00] [c000000000cc42f8] kernel_init_freeable+0x270/0x350 [c0000001fb083dc0] [c00000000000bd3c] kernel_init+0x2c/0x150 [c0000001fb083e30] [c0000000000095b0] ret_from_kernel_thread+0x5c/0xac Rebooting in 10 seconds..

I tried the tests with and without my changes and they both fail. I suspect its broken on ppc64le on which I am testing. The tests require more work to fix. I'll see if I can find some time to work on them. This patch is independent of the current breakage

Thanks for testing the patch.

Balbir Singh

reviewer Applied
#5 lore raw
In reply to Balbir Singh
Quoted 11 lines · Balbir Singh

From: Balbir Singh <[email protected]>

I spent some time trying to use kgdb and debugged my inability to resume from kgdb_handle_breakpoint(). NIP is not incremented and that leads to a loop in the debugger.

I've tested this lightly on a virtual instance with KDB enabled. After the patch, I am able to get the "go" command to work as expected

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/94e3d923592fcfe5585c18a0af

cheers