Skip to contentSkip to conversation

AArch64: KGDB support

PATCH Superseded vijay.kilari at gmail.com 2 participants 11 messages Nov 5, 2013 – Nov 13, 2013

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v4 cover AArch64: KGDB support

From: Vijaya Kumar K <[email protected]>

Based on the step-handler and break-handler hooks patch from Sandeepa (Patch 1), KGDB debugging support is added for EL1 debug in AArch64 mode. Any updates that come for Patch 1 from Sandeepa will be rebased in next version

With second patch,register layout is updated to be inline with GDB tool. Basic GDB connection, break point set/clear and info commands are supported except step/next debugging

With third patch, step/next debugging support is added, where in pc is updated to point to the instruction to be stepped and stopped.

with fourth patch, the compile time breakpoint instruction reordering is fixed by making kgbd_breakpoint() as noinline

v4:
- Updated kgdb_single_step and kgdb_cpu_doing_single_step variables properly based on gdb state

v3:
- Rebased to v4 version of Sandeepa Prabhu's patch (patch 1)
- Made dynamic break point instruction encoding generic
- Made ESR value encoding generic for dynamic and compile break point
- Used memcpy and memset to copy register contents to gdb buffer
- Fixed reordering of break point instruction by compiler with patch 3
- Rebased against AAach64 upstream kernel

v2:
- Moved break instruction encoding to debug-monitors.h file
- Fixed endianess of compile break instruction encoding
- Updated I/O buffer sizes
- Updated register buffer size
- Remove changes to debug_exception handler in entry.S for
- ELR update and step debugging with update pc instead of ELR
- Rebased against AArch64 upstream kernel

v1:
- Initial patch-set

Sandeepa Prabhu (1):
arm64: support single-step and breakpoint handler hooks

Vijaya Kumar K (3):
AArch64: KGDB: Add Basic KGDB support
AArch64: KGDB: Add step debugging support
KGDB: make kgdb_breakpoint() as noinline

 arch/arm64/include/asm/debug-monitors.h |   67 ++++++
 arch/arm64/include/asm/kgdb.h           |   86 ++++++++
 arch/arm64/kernel/Makefile              |    1 +
 arch/arm64/kernel/debug-monitors.c      |   86 +++++++-
 arch/arm64/kernel/entry.S               |    2 +
 arch/arm64/kernel/kgdb.c                |  338 +++++++++++++++++++++++++++++++
 kernel/debug/debug_core.c               |    2 +-
 7 files changed, 580 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm64/include/asm/kgdb.h
 create mode 100644 arch/arm64/kernel/kgdb.c
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v4 1/4 arm64: support single-step and breakpoint handler hooks

From: Sandeepa Prabhu <[email protected]>

AArch64 Single Steping and Breakpoint debug exceptions will be used by multiple debug framworks like kprobes & kgdb.

This patch implements the hooks for those frameworks to register their own handlers for handling breakpoint and single step events.

Reworked the debug exception handler in entry.S: do_dbg to route software breakpoint (BRK64) exception to do_debug_exception()

---
 arch/arm64/include/asm/debug-monitors.h |   21 ++++++++
 arch/arm64/kernel/debug-monitors.c      |   86 ++++++++++++++++++++++++++++++-
 arch/arm64/kernel/entry.S               |    2 +
 3 files changed, 108 insertions(+), 1 deletion(-)
arch/arm64/include/asm/debug-monitors.h +21 -0
index a2232d0..6231479 100644
@@ -62,6 +62,27 @@ struct task_struct;
 
 #define DBG_ARCH_ID_RESERVED	0	/* In case of ptrace ABI updates. */
 
+#define DBG_HOOK_HANDLED	0
+#define DBG_HOOK_ERROR		1
+
+struct step_hook {
+	struct list_head node;
+	int (*fn)(struct pt_regs *regs, unsigned int esr);
+};
+
+void register_step_hook(struct step_hook *hook);
+void unregister_step_hook(struct step_hook *hook);
+
+struct break_hook {
+	struct list_head node;
+	u32 esr_val;
+	u32 esr_mask;
+	int (*fn)(struct pt_regs *regs, unsigned int esr);
+};
+
+void register_break_hook(struct break_hook *hook);
+void unregister_break_hook(struct break_hook *hook);
+
 u8 debug_monitors_arch(void);
 
 void enable_debug_monitors(enum debug_el el);
arch/arm64/kernel/debug-monitors.c +85 -1

109 lines not on this page · raw message

arch/arm64/kernel/entry.S +2 -0
index 3881fd1..7fbc510 100644
@@ -288,6 +288,8 @@ el1_dbg:
 	/*
 	 * Debug exception handling
 	 */
+	cmp	x24, #ESR_EL1_EC_BRK64		// if BRK64
+	cinc	x24, x24, eq			// set bit '0'
 	tbz	x24, #0, el1_inv		// EL1 only
 	mrs	x0, far_el1
 	mov	x2, sp				// struct pt_regs
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v4 2/4 AArch64: KGDB: Add Basic KGDB support

In reply to vijay.kilari at gmail.com

From: Vijaya Kumar K <[email protected]>

Add KGDB debug support for kernel debugging.
With this patch, basic KGDB debugging is possible.GDB register layout is updated and GDB tool can establish connection with target and can set/clear breakpoints.

---
 arch/arm64/include/asm/debug-monitors.h |   46 +++++
 arch/arm64/include/asm/kgdb.h           |   86 +++++++++
 arch/arm64/kernel/Makefile              |    1 +
 arch/arm64/kernel/kgdb.c                |  289 +++++++++++++++++++++++++++++++
 4 files changed, 422 insertions(+)
arch/arm64/include/asm/debug-monitors.h +46 -0
index 6231479..d00c440 100644
@@ -26,6 +26,52 @@
 #define DBG_ESR_EVT_HWWP	0x2
 #define DBG_ESR_EVT_BRK		0x6
 
+/*
+ * Break point instruction encoding
+ */
+#define BREAK_INSTR_SIZE		4
+
+/*
+ * ESR values expected for dynamic and compile time BRK instruction
+ */
+#define DBG_ESR_VAL_BRK(x)	(0xf2000000 | ((x) & 0xfffff))
+
+/*
+ * #imm16 values used for BRK instruction generation
+ * 0: for dynamic BRK instruction
+ * 1: for compile time BRK instruction
+ */
+#define KGDB_DYN_DGB_BRK_IMM		0
+#define KDBG_COMPILED_DBG_BRK_IMM	1
+
+/*
+ * BRK instruction encoding
+ * The #imm16 value should be placed at bits[20:5] within BRK ins
+ */
+#define AARCH64_BREAK_MON	0xd4200000
+
+/*
+ * Extract byte from BRK instruction
+ */
+#define KGDB_DYN_DGB_BRK_INS_BYTE(x) \
+	((((AARCH64_BREAK_MON) & 0xffe0001f) >> (x * 8)) & 0xff)
+
+/*
+ * Extract byte from BRK #imm16
+ */
+#define KGBD_DYN_DGB_BRK_IMM_BYTE(x) \
+	(((((KGDB_DYN_DGB_BRK_IMM) & 0xffff) << 5) >> (x * 8)) & 0xff)
+
+#define KGDB_DYN_DGB_BRK_BYTE(x) \
+	(KGDB_DYN_DGB_BRK_INS_BYTE(x) | KGBD_DYN_DGB_BRK_IMM_BYTE(x))
+
+#define  KGDB_DYN_BRK_INS_BYTE0  KGDB_DYN_DGB_BRK_BYTE(0)
+#define  KGDB_DYN_BRK_INS_BYTE1  KGDB_DYN_DGB_BRK_BYTE(1)
+#define  KGDB_DYN_BRK_INS_BYTE2  KGDB_DYN_DGB_BRK_BYTE(2)
+#define  KGDB_DYN_BRK_INS_BYTE3  KGDB_DYN_DGB_BRK_BYTE(3)
+
+#define CACHE_FLUSH_IS_SAFE		1
+
 enum debug_el {
 	DBG_ACTIVE_EL0 = 0,
 	DBG_ACTIVE_EL1,
arch/arm64/include/asm/kgdb.h new file +86 -0

86 lines not on this page · raw message

arch/arm64/kernel/Makefile +1 -0
index 7b4b564..69613bb 100644
@@ -18,6 +18,7 @@ arm64-obj-$(CONFIG_SMP)			+= smp.o smp_spin_table.o smp_psci.o
 arm64-obj-$(CONFIG_HW_PERF_EVENTS)	+= perf_event.o
 arm64-obj-$(CONFIG_HAVE_HW_BREAKPOINT)+= hw_breakpoint.o
 arm64-obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
+arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
 
 obj-y					+= $(arm64-obj-y) vdso/
 obj-m					+= $(arm64-obj-m)
arch/arm64/kernel/kgdb.c new file +289 -0

289 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#3 lore raw

PATCH v4 2/4 AArch64: KGDB: Add Basic KGDB support

Quoted 6 lines · vijay.kilari at gmail.com

From: Vijaya Kumar K <[email protected]>

Add KGDB debug support for kernel debugging.
With this patch, basic KGDB debugging is possible.GDB register layout is updated and GDB tool can establish connection with target and can set/clear breakpoints.

Will

#4 lore raw

PATCH v4 3/4 AArch64: KGDB: Add step debugging support

In reply to vijay.kilari at gmail.com

From: Vijaya Kumar K <[email protected]>

Add KGDB software step debugging support for EL1 debug in AArch64 mode.

KGDB registers step debug handler with debug monitor. On receiving 'step' command from GDB tool, target enables software step debugging and step address is updated. If no step address is received from GDB tool, target assumes next step address is current PC.

Software Step debugging is disabled when 'continue' command is received

---
 arch/arm64/kernel/kgdb.c |   67 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 58 insertions(+), 9 deletions(-)
arch/arm64/kernel/kgdb.c +58 -9
index ec624bc..f10f2ba 100644
@@ -137,13 +137,26 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)
 
 static int compiled_break;
 
+static void kgdb_arch_update_addr(struct pt_regs *regs,
+				char *remcom_in_buffer)
+{
+	unsigned long addr;
+	char *ptr;
+
+	ptr = &remcom_in_buffer[1];
+	if (kgdb_hex2long(&ptr, &addr))
+		kgdb_arch_set_pc(regs, addr);
+	else if (compiled_break == 1)
+		kgdb_arch_set_pc(regs, regs->pc + 4);
+
+	compiled_break = 0;
+}
+
 int kgdb_arch_handle_exception(int exception_vector, int signo,
 			       int err_code, char *remcom_in_buffer,
 			       char *remcom_out_buffer,
 			       struct pt_regs *linux_regs)
 {
-	unsigned long addr;
-	char *ptr;
 	int err;
 
 	switch (remcom_in_buffer[0]) {
@@ -153,6 +166,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
 		 * Packet D (Detach), k (kill). No special handling
 		 * is required here
 		 */
+		atomic_set(&kgdb_cpu_doing_single_step, -1);
+		kgdb_single_step =  0;
 		err = 0;
 		break;
 	case 'c':
@@ -164,16 +179,39 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
 		 * to the next instruction else we will just breakpoint
 		 * over and over again.
 		 */
-		ptr = &remcom_in_buffer[1];
-		if (kgdb_hex2long(&ptr, &addr))
-			kgdb_arch_set_pc(linux_regs, addr);
-		else if (compiled_break == 1)
-			kgdb_arch_set_pc(linux_regs, linux_regs->pc + 4);
+		kgdb_arch_update_addr(linux_regs, remcom_in_buffer);
+		atomic_set(&kgdb_cpu_doing_single_step, -1);
+		kgdb_single_step =  0;
 
-		compiled_break = 0;
+		/*
+		 * Received continue command, disable single step
+		 */
+		if (kernel_active_single_step())
+			kernel_disable_single_step();
 
 		err = 0;
 		break;
+	case 's':
+		/*
+		 * Update step address value with address passed
+		 * with step packet.
+		 * On debug exception return PC is copied to ELR
+		 * So just update PC.
+		 * If no step address is passed, resume from the address
+		 * pointed by PC. Do not update PC
+		 */
+		kgdb_arch_update_addr(linux_regs, remcom_in_buffer);
+		atomic_set(&kgdb_cpu_doing_single_step, raw_smp_processor_id());
+		kgdb_single_step =  1;
+
+		/*
+		 * Enable single step handling
+		 */
+		if (!kernel_active_single_step())
+			kernel_enable_single_step(linux_regs);
+		err = 0;
+		break;
+
 	default:
 		err = -1;
 	}
@@ -194,6 +232,12 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int esr)
 	return 0;
 }
 
+static int kgdb_step_brk_fn(struct pt_regs *regs, unsigned int esr)
+{
+	kgdb_handle_exception(1, SIGTRAP, 0, regs);
+	return 0;
+}
+
 static struct break_hook kgdb_brkpt_hook = {
 	.esr_mask	= 0xffffffff,
 	.esr_val	= DBG_ESR_VAL_BRK(KGDB_DYN_DGB_BRK_IMM),
@@ -206,6 +250,10 @@ static struct break_hook kgdb_compiled_brkpt_hook = {
 	.fn		= kgdb_compiled_brk_fn
 };
 
+static struct step_hook kgdb_step_hook = {
+	.fn		= kgdb_step_brk_fn
+};
+
 static void kgdb_call_nmi_hook(void *ignored)
 {
 	kgdb_nmicallback(raw_smp_processor_id(), get_irq_regs());
@@ -259,7 +307,7 @@ int kgdb_arch_init(void)
 
 	register_break_hook(&kgdb_brkpt_hook);
 	register_break_hook(&kgdb_compiled_brkpt_hook);
-
+	register_step_hook(&kgdb_step_hook);
 	return 0;
 }
 
@@ -272,6 +320,7 @@ void kgdb_arch_exit(void)
 {
 	unregister_break_hook(&kgdb_brkpt_hook);
 	unregister_break_hook(&kgdb_compiled_brkpt_hook);
+	unregister_step_hook(&kgdb_step_hook);
 	unregister_die_notifier(&kgdb_notifier);
 }
 
Signature · 1 line
1.7.9.5
#5 lore raw

PATCH v4 3/4 AArch64: KGDB: Add step debugging support

Quoted 53 lines · vijay.kilari at gmail.com

From: Vijaya Kumar K <[email protected]>

Add KGDB software step debugging support for EL1 debug in AArch64 mode.

KGDB registers step debug handler with debug monitor. On receiving 'step' command from GDB tool, target enables software step debugging and step address is updated. If no step address is received from GDB tool, target assumes next step address is current PC.

Software Step debugging is disabled when 'continue' command is received

---
 arch/arm64/kernel/kgdb.c |   67 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 58 insertions(+), 9 deletions(-)
arch/arm64/kernel/kgdb.c +15 -2
index ec624bc..f10f2ba 100644
@@ -137,13 +137,26 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)
 
 static int compiled_break;
 
+static void kgdb_arch_update_addr(struct pt_regs *regs,
+				char *remcom_in_buffer)
+{
+	unsigned long addr;
+	char *ptr;
+
+	ptr = &remcom_in_buffer[1];
+	if (kgdb_hex2long(&ptr, &addr))
+		kgdb_arch_set_pc(regs, addr);
+	else if (compiled_break == 1)
+		kgdb_arch_set_pc(regs, regs->pc + 4);
+
+	compiled_break = 0;
+}
+
 int kgdb_arch_handle_exception(int exception_vector, int signo,
 			       int err_code, char *remcom_in_buffer,
 			       char *remcom_out_buffer,
 			       struct pt_regs *linux_regs)
 {
-	unsigned long addr;
-	char *ptr;
 	int err;
 
 	switch (remcom_in_buffer[0]) {

arch/arm64/kernel/kgdb.c int kgdb_arch_handle_exception(int exception_vector, int signo, · line 170

Quoted 5 lines
arch/arm64/kernel/kgdb.c +2 -0
@@ -153,6 +166,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
 		 * Packet D (Detach), k (kill). No special handling
 		 * is required here
 		 */
+		atomic_set(&kgdb_cpu_doing_single_step, -1);
+		kgdb_single_step =  0;

This looks really weird: you have two variables, which you attempt to keep in sync, only one of them is an atomic access and you don't have any locking or memory barriers between them, so it must be ok if they're not in-sync. In which case, why do we have two variables?

Will

#6 lore raw

PATCH v4 3/4 AArch64: KGDB: Add step debugging support

Quoted 52 lines · Will Deacon
Quoted 51 lines · vijay.kilari at gmail.com

From: Vijaya Kumar K <[email protected]>

Add KGDB software step debugging support for EL1 debug in AArch64 mode.

KGDB registers step debug handler with debug monitor. On receiving 'step' command from GDB tool, target enables software step debugging and step address is updated. If no step address is received from GDB tool, target assumes next step address is current PC.

Software Step debugging is disabled when 'continue' command is received

---
 arch/arm64/kernel/kgdb.c |   67 +++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 58 insertions(+), 9 deletions(-)
arch/arm64/kernel/kgdb.c +15 -2
index ec624bc..f10f2ba 100644
@@ -137,13 +137,26 @@ void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long pc)
 
 static int compiled_break;
 
+static void kgdb_arch_update_addr(struct pt_regs *regs,
+                             char *remcom_in_buffer)
+{
+     unsigned long addr;
+     char *ptr;
+
+     ptr = &remcom_in_buffer[1];
+     if (kgdb_hex2long(&ptr, &addr))
+             kgdb_arch_set_pc(regs, addr);
+     else if (compiled_break == 1)
+             kgdb_arch_set_pc(regs, regs->pc + 4);
+
+     compiled_break = 0;
+}
+
 int kgdb_arch_handle_exception(int exception_vector, int signo,
                             int err_code, char *remcom_in_buffer,
                             char *remcom_out_buffer,
                             struct pt_regs *linux_regs)
 {
-     unsigned long addr;
-     char *ptr;
      int err;
 
Quoted 13 lines

arch/arm64/kernel/kgdb.c int kgdb_arch_handle_exception(int exception_vector, int signo, · line 170

Quoted 7 lines
arch/arm64/kernel/kgdb.c +2 -0
      switch (remcom_in_buffer[0]) {
@@ -153,6 +166,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
               * Packet D (Detach), k (kill). No special handling
               * is required here
               */
+             atomic_set(&kgdb_cpu_doing_single_step, -1);
+             kgdb_single_step =  0;

This looks really weird: you have two variables, which you attempt to keep in sync, only one of them is an atomic access and you don't have any locking or memory barriers between them, so it must be ok if they're not in-sync. In which case, why do we have two variables?

IMHO, two variables are being used by kgdb framework
The variables 'kgdb_cpu_doing_single_step' holds the cpu on which step debugging
is happening. With this, when during step debugging, it ensures that on next step debug exception only this CPU aquires master lock and step debugging is performed.

The variable 'kgdb_single_step' is used to know if step debugging is ongoing or not.
If so, the non-primary cpu's are not released untill the continue command is received
So, with this the cpu's are not released and acquired for every step command

Quoted 1 line

Will

#7 lore raw

PATCH v4 3/4 AArch64: KGDB: Add step debugging support

Quoted 21 lines · Vijay Kilari
Quoted 13 lines · Will Deacon

arch/arm64/kernel/kgdb.c int kgdb_arch_handle_exception(int exception_vector, int signo, · line 170

Quoted 6 lines · vijay.kilari at gmail.com
arch/arm64/kernel/kgdb.c +2 -0
@@ -153,6 +166,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
               * Packet D (Detach), k (kill). No special handling
               * is required here
               */
+             atomic_set(&kgdb_cpu_doing_single_step, -1);
+             kgdb_single_step =  0;

This looks really weird: you have two variables, which you attempt to keep in sync, only one of them is an atomic access and you don't have any locking or memory barriers between them, so it must be ok if they're not in-sync. In which case, why do we have two variables?

IMHO, two variables are being used by kgdb framework
The variables 'kgdb_cpu_doing_single_step' holds the cpu on which step debugging
is happening. With this, when during step debugging, it ensures that on next step debug exception only this CPU aquires master lock and step debugging is performed.

Quoted 5 lines

The variable 'kgdb_single_step' is used to know if step debugging is ongoing or not.
If so, the non-primary cpu's are not released untill the continue command is received
So, with this the cpu's are not released and acquired for every step command

Ok, but in what situation would you have both kgdb_cpu_doing_single_step == -1 and kgdb_single_step == 1 (ignoring races between setting the two variables)?

In other words, can we reduce this to a single variable?

Will

#8 lore raw

PATCH v4 3/4 AArch64: KGDB: Add step debugging support

Quoted 28 lines · Will Deacon
Quoted 21 lines · Vijay Kilari
Quoted 13 lines · Will Deacon

arch/arm64/kernel/kgdb.c int kgdb_arch_handle_exception(int exception_vector, int signo, · line 170

Quoted 6 lines · vijay.kilari at gmail.com
arch/arm64/kernel/kgdb.c +2 -0
@@ -153,6 +166,8 @@ int kgdb_arch_handle_exception(int exception_vector, int signo,
               * Packet D (Detach), k (kill). No special handling
               * is required here
               */
+             atomic_set(&kgdb_cpu_doing_single_step, -1);
+             kgdb_single_step =  0;

This looks really weird: you have two variables, which you attempt to keep in sync, only one of them is an atomic access and you don't have any locking or memory barriers between them, so it must be ok if they're not in-sync. In which case, why do we have two variables?

IMHO, two variables are being used by kgdb framework
The variables 'kgdb_cpu_doing_single_step' holds the cpu on which step debugging
is happening. With this, when during step debugging, it ensures that on next step debug exception only this CPU aquires master lock and step debugging is performed.

Quoted 5 lines

The variable 'kgdb_single_step' is used to know if step debugging is ongoing or not.
If so, the non-primary cpu's are not released untill the continue command is received
So, with this the cpu's are not released and acquired for every step command

Quoted 5 lines

Ok, but in what situation would you have both kgdb_cpu_doing_single_step == -1 and kgdb_single_step == 1 (ignoring races between setting the two variables)?

In other words, can we reduce this to a single variable?

More elaborately,
The kgdb_cpu_doing_single_step holds the cpu number which is used to store the task information that is currently being step debugged in the corresponding cpu structure. so we cannot get rid of this variable. Also this variable tells which cpu should take the exception for step debugging so it waits for this paricular cpu to get the chance to take exception in case if exception has been taken by other cpu.

The kgdb_single_step variable, it only tells if cpu's that don't get debug exception
should be released & acquired for every step debug or not

So, both variables are used for different purpose. we can make an attempt to make to use one variable, but I think, the flexibility is lost. Moreover, I see that these variables are declared in generic kgdb code and different architectures use this based on their requirement.

The race will not happen because, only one cpu will be executing this function at
any point of the time and all other cpu's will be spinning.

Quoted 1 line

Will

#9 lore raw

PATCH v4 4/4 KGDB: make kgdb_breakpoint() as noinline

In reply to vijay.kilari at gmail.com

From: Vijaya Kumar K <[email protected]>

The function kgdb_breakpoint() sets up break point at compile time by calling arch_kgdb_breakpoint(); Though this call is surrounded by wmb() barrier, the compile can still re-order the break point, because this scheduling barrier is not a code motion barrier in gcc.

Making kgdb_breakpoint() as noinline solves this problem of code reording around break point instruction and also avoids problem of being called as inline function from other places

More details about discussion on this can be found here
http://comments.gmane.org/gmane.linux.ports.arm.kernel/269732

---
 kernel/debug/debug_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/debug/debug_core.c +1 -1
index 0506d44..359ce6a 100644
@@ -1006,7 +1006,7 @@ int dbg_io_get_char(void)
  * otherwise as a quick means to stop program execution and "break" into
  * the debugger.
  */
-void kgdb_breakpoint(void)
+noinline void kgdb_breakpoint(void)
 {
 	atomic_inc(&kgdb_setting_breakpoint);
 	wmb(); /* Sync point before breakpoint */
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v4 4/4 KGDB: make kgdb_breakpoint() as noinline

Quoted 14 lines · vijay.kilari at gmail.com

From: Vijaya Kumar K <[email protected]>

The function kgdb_breakpoint() sets up break point at compile time by calling arch_kgdb_breakpoint(); Though this call is surrounded by wmb() barrier, the compile can still re-order the break point, because this scheduling barrier is not a code motion barrier in gcc.

Making kgdb_breakpoint() as noinline solves this problem of code reording around break point instruction and also avoids problem of being called as inline function from other places

Quoted 4 lines

More details about discussion on this can be found here
http://comments.gmane.org/gmane.linux.ports.arm.kernel/269732

I thought I already acked this?

Will