Skip to content

Commit 9b2c750

Browse files
Vineet Guptagregkh
Vineet Gupta
authored andcommitted
ARC: gdbserver breakage in Big-Endian configuration #1
[Based on mainline commit 502a0c775c7f0a: "ARC: pt_regs update imx6-dongle#5"] gdbserver needs @stop_pc, served by ptrace, but fetched from pt_regs differently, based on in_brkpt_traps(), which in turn relies on additional machine state in pt_regs->event bitfield. unsigned long orig_r8:16, event:16; For big endian config, this macro was returning false, despite being in breakpoint Trap exception, causing wrong @stop_pc to be returned to gdb. Issue #1: In BE, @event above is at offset 2 in word, while a STW insn at offset 0 was used to update it. Resort to using ST insn which updates the half-word at right location. Issue imx6-dongle#2: The union involving bitfields causes all the members to be laid out at offset 0. So with fix #1 above, ASM was now updating at offset 2, "C" code was still referencing at offset 0. Fixed by wrapping bitfield in a struct. Reported-by: Noam Camus <[email protected]> Tested-by: Anton Kolesov <[email protected]> Signed-off-by: Vineet Gupta <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6e4fdb8 commit 9b2c750

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

arch/arc/include/asm/ptrace.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ struct pt_regs {
5252

5353
/*to distinguish bet excp, syscall, irq */
5454
union {
55+
struct {
5556
#ifdef CONFIG_CPU_BIG_ENDIAN
5657
/* so that assembly code is same for LE/BE */
5758
unsigned long orig_r8:16, event:16;
5859
#else
5960
unsigned long event:16, orig_r8:16;
6061
#endif
62+
};
6163
long orig_r8_word;
6264
};
6365
};

arch/arc/kernel/entry.S

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ tracesys_exit:
498498
trap_with_param:
499499

500500
; stop_pc info by gdb needs this info
501-
stw orig_r8_IS_BRKPT, [sp, PT_orig_r8]
501+
st orig_r8_IS_BRKPT, [sp, PT_orig_r8]
502502

503503
mov r0, r12
504504
lr r1, [efa]
@@ -723,7 +723,7 @@ not_exception:
723723
; things to what they were, before returning from L2 context
724724
;----------------------------------------------------------------
725725

726-
ldw r9, [sp, PT_orig_r8] ; get orig_r8 to make sure it is
726+
ld r9, [sp, PT_orig_r8] ; get orig_r8 to make sure it is
727727
brne r9, orig_r8_IS_IRQ2, 149f ; infact a L2 ISR ret path
728728

729729
ld r9, [sp, PT_status32] ; get statu32_l2 (saved in pt_regs)

0 commit comments

Comments
 (0)