linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v7 0/6] arm64: KGDB Support
@ 2014-01-22 14:42 vijay.kilari at gmail.com
  2014-01-22 14:42 ` [PATCH 1/6] arm64: Add macros to manage processor debug state vijay.kilari at gmail.com
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: vijay.kilari at gmail.com @ 2014-01-22 14:42 UTC (permalink / raw)
  To: linux-arm-kernel

From: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>

Based on the step-handler and break-handler hooks patch from
Sandeepa, KGDB debugging support is added for EL1
debug in AArch64 mode.

In first patch, PSTATE.D is set correctly

In 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 second patch, step/next debugging support is added, where in
pc is updated to point to the instruction to be stepped and
stopped.

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

Tested with ARM64 simulator

v7:
 - Changes made to set PSTATE.D properly
 - Performed KGDB boot tests
 - Fixed compilation warnings in driver/misc/kgbdts.c

Results:

kgdb boot test:

  [32927.237895] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
  [32927.266066] kgdb: Registered I/O driver kgdbts.
  [32927.266419] kgdb: Waiting for connection from remote gdb...
  [32927.268598] kgdbts:RUN plant and detach test
  [32927.270683] kgdbts:RUN sw breakpoint test
  [32927.287659] kgdbts:RUN bad memory access test
  [32927.290322] kgdbts:RUN singlestep test 1000 iterations
  [32927.330342] kgdbts:RUN singlestep [0/1000]
  [32931.286356] kgdbts:RUN singlestep [100/1000]
  [32935.242536] kgdbts:RUN singlestep [200/1000]
  [32939.205392] kgdbts:RUN singlestep [300/1000]
  [32943.169522] kgdbts:RUN singlestep [400/1000]
  [32947.231868] kgdbts:RUN singlestep [500/1000]
  [32951.188008] kgdbts:RUN singlestep [600/1000]
  [32955.332243] kgdbts:RUN singlestep [700/1000]
  [32959.467109] kgdbts:RUN singlestep [800/1000]
  [32963.430888] kgdbts:RUN singlestep [900/1000]
  [32967.346992] kgdbts:RUN do_fork for 100 breakpoints

kgdb test from sysfs:

  ~ # echo V1F1000 > /sys/module/kgdbts/parameters/kgdbts
  [33231.554237] kgdb: Registered I/O driver kgdbts.
  [33231.554677] kgdbts:RUN plant and detach test
  [33231.557072] kgdbts:RUN sw breakpoint test
  [33231.576980] kgdbts:RUN bad memory access test
  [33231.580022] kgdbts:RUN singlestep test 1000 iterations
  [33231.627056] kgdbts:RUN singlestep [0/1000]
  [33235.954027] kgdbts:RUN singlestep [100/1000]
  [33240.429086] kgdbts:RUN singlestep [200/1000]
  [33244.687118] kgdbts:RUN singlestep [300/1000]
  [33248.945191] kgdbts:RUN singlestep [400/1000]
  [33253.203751] kgdbts:RUN singlestep [500/1000]
  [33257.462019] kgdbts:RUN singlestep [600/1000]
  [33261.817809] kgdbts:RUN singlestep [700/1000]
  [33266.081268] kgdbts:RUN singlestep [800/1000]
  [33270.339813] kgdbts:RUN singlestep [900/1000]
  [33274.712404] kgdbts:RUN do_fork for 1000 breakpoints
  ~ #

v6:
 - Change pstate register to 8 bytes to make endian nuetral.
   Use GDB below GDB patch to display pstate in Big endian mode.
   https://sourceware.org/ml/gdb-patches/2013-12/msg00720.html
   Thanks to Andrew.

v5:
 - Updated BRK #imm16 value to 0x400 & 0x401 as per recommendation
   as per Marcus recommendataion
   http://patchwork.ozlabs.org/patch/290801/
 - Rebased to 3.13 AArch64 kernel

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

Vijaya Kumar K (6):
  arm64: Add macros to manage processor debug state
  arm64: KGDB: Add Basic KGDB support
  arm64: KGDB: Add step debugging support
  KGDB: make kgdb_breakpoint() as noinline
  misc: debug: remove compilation warnings
  arm64: KGDB: Add KGDB config

 arch/arm64/Kconfig                      |    1 +
 arch/arm64/include/asm/debug-monitors.h |   65 ++++--
 arch/arm64/include/asm/irqflags.h       |   22 ++
 arch/arm64/include/asm/kgdb.h           |   84 ++++++++
 arch/arm64/kernel/Makefile              |    1 +
 arch/arm64/kernel/debug-monitors.c      |    3 +-
 arch/arm64/kernel/kgdb.c                |  336 +++++++++++++++++++++++++++++++
 drivers/misc/kgdbts.c                   |   12 +-
 kernel/debug/debug_core.c               |    2 +-
 9 files changed, 502 insertions(+), 24 deletions(-)
 create mode 100644 arch/arm64/include/asm/kgdb.h
 create mode 100644 arch/arm64/kernel/kgdb.c

-- 
1.7.9.5

^ permalink raw reply	[flat|nested] 14+ messages in thread
* [PATCH 1/6] arm64: Add macros to manage processor debug state
@ 2014-01-23 15:29 vijay.kilari at gmail.com
  2014-01-24 16:39 ` Will Deacon
  0 siblings, 1 reply; 14+ messages in thread
From: vijay.kilari at gmail.com @ 2014-01-23 15:29 UTC (permalink / raw)
  To: linux-arm-kernel

From: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>

Add macros to enable and disable to manage PSTATE.D
for debugging. The macros local_dbg_save and local_dbg_restore
are moved to irqflags.h file

KGDB boot tests fail because of PSTATE.D is masked.
unmask it for debugging support

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@caviumnetworks.com>
---
 arch/arm64/include/asm/debug-monitors.h |   17 -----------
 arch/arm64/include/asm/irqflags.h       |   48 +++++++++++++++++++++++++++++++
 arch/arm64/kernel/debug-monitors.c      |    1 +
 3 files changed, 49 insertions(+), 17 deletions(-)

diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h
index 6231479..ee9f28e 100644
--- a/arch/arm64/include/asm/debug-monitors.h
+++ b/arch/arm64/include/asm/debug-monitors.h
@@ -43,23 +43,6 @@ enum debug_el {
 #ifndef __ASSEMBLY__
 struct task_struct;
 
-#define local_dbg_save(flags)							\
-	do {									\
-		typecheck(unsigned long, flags);				\
-		asm volatile(							\
-		"mrs	%0, daif			// local_dbg_save\n"	\
-		"msr	daifset, #8"						\
-		: "=r" (flags) : : "memory");					\
-	} while (0)
-
-#define local_dbg_restore(flags)						\
-	do {									\
-		typecheck(unsigned long, flags);				\
-		asm volatile(							\
-		"msr	daif, %0			// local_dbg_restore\n"	\
-		: : "r" (flags) : "memory");					\
-	} while (0)
-
 #define DBG_ARCH_ID_RESERVED	0	/* In case of ptrace ABI updates. */
 
 #define DBG_HOOK_HANDLED	0
diff --git a/arch/arm64/include/asm/irqflags.h b/arch/arm64/include/asm/irqflags.h
index b2fcfbc..f9b013e 100644
--- a/arch/arm64/include/asm/irqflags.h
+++ b/arch/arm64/include/asm/irqflags.h
@@ -90,5 +90,53 @@ static inline int arch_irqs_disabled_flags(unsigned long flags)
 	return flags & PSR_I_BIT;
 }
 
+/*
+ * save and restore debug state
+ */
+static inline unsigned long arch_local_dbg_save(void)
+{
+	unsigned long flags;
+	asm volatile(
+		"mrs	%0, daif	// arch_local_dbg_save"
+		"msr	daifset, #8"
+		: "=r" (flags) : : "memory");
+	return flags;
+}
+
+static inline void arch_local_dbg_restore(unsigned long flags)
+{
+	asm volatile(
+		"msr	daif, %0	// arch_local_dbg_restore"
+		:
+		: "r" (flags)
+		: "memory");
+}
+
+#define raw_local_dbg_save(flags)			\
+	do {						\
+		typecheck(unsigned long, flags);	\
+		flags = arch_local_dbg_save();		\
+	} while (0)
+
+#define raw_local_dbg_restore(flags)			\
+	do {						\
+		typecheck(unsigned long, flags);	\
+		arch_local_dbg_restore(flags);		\
+	} while (0)
+
+#define local_dbg_save(flags)				\
+	do {						\
+		raw_local_dbg_save(flags);		\
+	} while (0)
+
+#define local_dbg_restore(flags)			\
+	do {						\
+		typecheck(unsigned long, flags);	\
+		raw_local_dbg_restore(flags);		\
+	} while (0)
+
+#define local_dbg_enable()	asm("msr	daifclr, #8" : : : "memory")
+#define local_dbg_disable()	asm("msr	daifset, #8" : : : "memory")
+
 #endif
 #endif
diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
index 23586bd..a86e5b1 100644
--- a/arch/arm64/kernel/debug-monitors.c
+++ b/arch/arm64/kernel/debug-monitors.c
@@ -138,6 +138,7 @@ static void clear_os_lock(void *unused)
 {
 	asm volatile("msr oslar_el1, %0" : : "r" (0));
 	isb();
+	local_dbg_enable();
 }
 
 static int os_lock_notify(struct notifier_block *self,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-01-28 11:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-22 14:42 [PATCH v7 0/6] arm64: KGDB Support vijay.kilari at gmail.com
2014-01-22 14:42 ` [PATCH 1/6] arm64: Add macros to manage processor debug state vijay.kilari at gmail.com
2014-01-22 17:31   ` Will Deacon
2014-01-23  4:46     ` Vijay Kilari
2014-01-23  9:57       ` Will Deacon
2014-01-22 14:42 ` [PATCH v7 2/6] arm64: KGDB: Add Basic KGDB support vijay.kilari at gmail.com
2014-01-22 14:42 ` [PATCH v7 3/6] arm64: KGDB: Add step debugging support vijay.kilari at gmail.com
2014-01-22 14:42 ` [PATCH v7 4/6] KGDB: make kgdb_breakpoint() as noinline vijay.kilari at gmail.com
2014-01-22 14:42 ` [PATCH v7 5/6] misc: debug: remove compilation warnings vijay.kilari at gmail.com
2014-01-22 16:11   ` Catalin Marinas
2014-01-22 14:42 ` [PATCH v7 6/6] arm64: KGDB: Add KGDB config vijay.kilari at gmail.com
  -- strict thread matches above, loose matches on Subject: below --
2014-01-23 15:29 [PATCH 1/6] arm64: Add macros to manage processor debug state vijay.kilari at gmail.com
2014-01-24 16:39 ` Will Deacon
2014-01-28 11:33   ` Vijay Kilari

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).