From: Jason Wessel <jason.wessel@windriver.com>
To: Sonic Zhang <sonic.adi@gmail.com>
Cc: "Zhang, Sonic" <Sonic.Zhang@analog.com>,
Mike Frysinger <vapier.adi@gmail.com>,
kgdb-bugreport@lists.sourceforge.net,
linux-kernel@vger.kernel.org, mingo@elte.hu
Subject: Re: [Kgdb-bugreport] [PATCH 09/37] kgdb,blackfin: Add in kgdb_arch_set_pc for blackfin
Date: Wed, 06 Jan 2010 13:43:31 -0600 [thread overview]
Message-ID: <4B44E7E3.10305@windriver.com> (raw)
In-Reply-To: <4e5ebad50912301845p35b1ea98l2f91c2a209ee863a@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1330 bytes --]
Sonic Zhang wrote:
> I have to recall my last wrong patch.
>
> In blackfin, kgdb is running in delayed exception IRQ5 other than in
> exception IRQ3 directly. Register reti other than retx in pt_regs is
> the kgdb return address. So, don't put PC in gdb_regs into retx.
>
> Sonic Zhang
>
> Index: arch/blackfin/kernel/kgdb.c
> ============================
> --- arch/blackfin/kernel/kgdb.c (revision 8105)
> +++ arch/blackfin/kernel/kgdb.c (revision 8106)
> @@ -147,7 +147,7 @@
> regs->lb1 = gdb_regs[BFIN_LB1];
> regs->usp = gdb_regs[BFIN_USP];
> regs->syscfg = gdb_regs[BFIN_SYSCFG];
> - regs->retx = gdb_regs[BFIN_PC];
> + regs->retx = gdb_regs[BFIN_RETX];
> regs->retn = gdb_regs[BFIN_RETN];
> regs->rete = gdb_regs[BFIN_RETE];
> regs->pc = gdb_regs[BFIN_PC];
>
>
Sonic,
I pulled in this patch, and made the changes the Mike talked about with
respect to cleaning up the arch specific kgdb.c for blackfin. See the
attached patch.
Your patch and the one here will go into kgdb-next and onto linux-next.
At some point you sent a patch for cpu switching that was blackfin
specific. There is new generic code in the debug core for doing this
without exiting the debug context. At some point you should test this
and figure out if something further needs to be done that is blackfin
specific.
Thanks,
Jason.
[-- Attachment #2: blackfin_kgdb_cleanup.patch --]
[-- Type: text/x-diff, Size: 9441 bytes --]
From: Jason Wessel <jason.wessel@windriver.com>
Subject: [PATCH] maccess,blackfin,kgdb: Cleanup probe_kernel_read/write
Blackfin needs it own arch specific probe_kernel_read() and
probe_kernel_write().
This was moved out of the kgdb code and into the
arch/blackfin/maccess.c, because it is a generic kernel api.
The arch specific kgdb.c for blackfin was cleaned of all functions
which exist in the kgdb core that do the same thing after resolving
the probe_kernel_read() and probe_kernel_write(). This also
eliminated the need for most of the #include's.
CC: Mike Frysinger <vapier@gentoo.org>
CC: Sonic Zhang <sonic.adi@gmail.com>
Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
---
arch/blackfin/kernel/kgdb.c | 205 --------------------------------------------
arch/blackfin/mm/Makefile | 2
arch/blackfin/mm/maccess.c | 97 ++++++++++++++++++++
mm/maccess.c | 2
4 files changed, 99 insertions(+), 207 deletions(-)
--- a/arch/blackfin/kernel/kgdb.c
+++ b/arch/blackfin/kernel/kgdb.c
@@ -6,23 +6,9 @@
* Licensed under the GPL-2 or later.
*/
-#include <linux/string.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/smp.h>
-#include <linux/spinlock.h>
-#include <linux/delay.h>
#include <linux/ptrace.h> /* for linux pt_regs struct */
#include <linux/kgdb.h>
-#include <linux/console.h>
-#include <linux/init.h>
-#include <linux/errno.h>
-#include <linux/irq.h>
#include <linux/uaccess.h>
-#include <asm/system.h>
-#include <asm/traps.h>
-#include <asm/blackfin.h>
-#include <asm/dma.h>
void pt_regs_to_gdb_regs(unsigned long *gdb_regs, struct pt_regs *regs)
{
@@ -424,182 +410,6 @@ struct kgdb_arch arch_kgdb_ops = {
.correct_hw_break = bfin_correct_hw_break,
};
-static int hex(char ch)
-{
- if ((ch >= 'a') && (ch <= 'f'))
- return ch - 'a' + 10;
- if ((ch >= '0') && (ch <= '9'))
- return ch - '0';
- if ((ch >= 'A') && (ch <= 'F'))
- return ch - 'A' + 10;
- return -1;
-}
-
-static int validate_memory_access_address(unsigned long addr, int size)
-{
- if (size < 0 || addr == 0)
- return -EFAULT;
- return bfin_mem_access_type(addr, size);
-}
-
-static int bfin_probe_kernel_read(char *dst, char *src, int size)
-{
- unsigned long lsrc = (unsigned long)src;
- int mem_type;
-
- mem_type = validate_memory_access_address(lsrc, size);
- if (mem_type < 0)
- return mem_type;
-
- if (lsrc >= SYSMMR_BASE) {
- if (size == 2 && lsrc % 2 == 0) {
- u16 mmr = bfin_read16(src);
- memcpy(dst, &mmr, sizeof(mmr));
- return 0;
- } else if (size == 4 && lsrc % 4 == 0) {
- u32 mmr = bfin_read32(src);
- memcpy(dst, &mmr, sizeof(mmr));
- return 0;
- }
- } else {
- switch (mem_type) {
- case BFIN_MEM_ACCESS_CORE:
- case BFIN_MEM_ACCESS_CORE_ONLY:
- return probe_kernel_read(dst, src, size);
- /* XXX: should support IDMA here with SMP */
- case BFIN_MEM_ACCESS_DMA:
- if (dma_memcpy(dst, src, size))
- return 0;
- break;
- case BFIN_MEM_ACCESS_ITEST:
- if (isram_memcpy(dst, src, size))
- return 0;
- break;
- }
- }
-
- return -EFAULT;
-}
-
-static int bfin_probe_kernel_write(char *dst, char *src, int size)
-{
- unsigned long ldst = (unsigned long)dst;
- int mem_type;
-
- mem_type = validate_memory_access_address(ldst, size);
- if (mem_type < 0)
- return mem_type;
-
- if (ldst >= SYSMMR_BASE) {
- if (size == 2 && ldst % 2 == 0) {
- u16 mmr;
- memcpy(&mmr, src, sizeof(mmr));
- bfin_write16(dst, mmr);
- return 0;
- } else if (size == 4 && ldst % 4 == 0) {
- u32 mmr;
- memcpy(&mmr, src, sizeof(mmr));
- bfin_write32(dst, mmr);
- return 0;
- }
- } else {
- switch (mem_type) {
- case BFIN_MEM_ACCESS_CORE:
- case BFIN_MEM_ACCESS_CORE_ONLY:
- return probe_kernel_write(dst, src, size);
- /* XXX: should support IDMA here with SMP */
- case BFIN_MEM_ACCESS_DMA:
- if (dma_memcpy(dst, src, size))
- return 0;
- break;
- case BFIN_MEM_ACCESS_ITEST:
- if (isram_memcpy(dst, src, size))
- return 0;
- break;
- }
- }
-
- return -EFAULT;
-}
-
-/*
- * Convert the memory pointed to by mem into hex, placing result in buf.
- * Return a pointer to the last char put in buf (null). May return an error.
- */
-int kgdb_mem2hex(char *mem, char *buf, int count)
-{
- char *tmp;
- int err;
-
- /*
- * We use the upper half of buf as an intermediate buffer for the
- * raw memory copy. Hex conversion will work against this one.
- */
- tmp = buf + count;
-
- err = bfin_probe_kernel_read(tmp, mem, count);
- if (!err) {
- while (count > 0) {
- buf = pack_hex_byte(buf, *tmp);
- tmp++;
- count--;
- }
-
- *buf = 0;
- }
-
- return err;
-}
-
-/*
- * Copy the binary array pointed to by buf into mem. Fix $, #, and
- * 0x7d escaped with 0x7d. Return a pointer to the character after
- * the last byte written.
- */
-int kgdb_ebin2mem(char *buf, char *mem, int count)
-{
- char *tmp_old, *tmp_new;
- int size;
-
- tmp_old = tmp_new = buf;
-
- for (size = 0; size < count; ++size) {
- if (*tmp_old == 0x7d)
- *tmp_new = *(++tmp_old) ^ 0x20;
- else
- *tmp_new = *tmp_old;
- tmp_new++;
- tmp_old++;
- }
-
- return bfin_probe_kernel_write(mem, buf, count);
-}
-
-/*
- * Convert the hex array pointed to by buf into binary to be placed in mem.
- * Return a pointer to the character AFTER the last byte written.
- * May return an error.
- */
-int kgdb_hex2mem(char *buf, char *mem, int count)
-{
- char *tmp_raw, *tmp_hex;
-
- /*
- * We use the upper half of buf as an intermediate buffer for the
- * raw memory that is converted from hex.
- */
- tmp_raw = buf + count * 2;
-
- tmp_hex = tmp_raw - 1;
- while (tmp_hex >= buf) {
- tmp_raw--;
- *tmp_raw = hex(*tmp_hex--);
- *tmp_raw |= hex(*tmp_hex--) << 4;
- }
-
- return bfin_probe_kernel_write(mem, tmp_raw, count);
-}
-
#define IN_MEM(addr, size, l1_addr, l1_size) \
({ \
unsigned long __addr = (unsigned long)(addr); \
@@ -629,21 +439,6 @@ int kgdb_validate_break_address(unsigned
return -EFAULT;
}
-int kgdb_arch_set_breakpoint(unsigned long addr, char *saved_instr)
-{
- int err = bfin_probe_kernel_read(saved_instr, (char *)addr,
- BREAK_INSTR_SIZE);
- if (err)
- return err;
- return bfin_probe_kernel_write((char *)addr, arch_kgdb_ops.gdb_bpt_instr,
- BREAK_INSTR_SIZE);
-}
-
-int kgdb_arch_remove_breakpoint(unsigned long addr, char *bundle)
-{
- return bfin_probe_kernel_write((char *)addr, bundle, BREAK_INSTR_SIZE);
-}
-
void kgdb_arch_set_pc(struct pt_regs *regs, unsigned long ip)
{
regs->retx = ip;
--- a/arch/blackfin/mm/Makefile
+++ b/arch/blackfin/mm/Makefile
@@ -2,4 +2,4 @@
# arch/blackfin/mm/Makefile
#
-obj-y := sram-alloc.o isram-driver.o init.o
+obj-y := sram-alloc.o isram-driver.o init.o maccess.o
--- /dev/null
+++ b/arch/blackfin/mm/maccess.c
@@ -0,0 +1,97 @@
+/*
+ * safe read and write memory routines callable while atomic
+ *
+ * Copyright 2005-2008 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <linux/uaccess.h>
+#include <asm/dma.h>
+
+static int validate_memory_access_address(unsigned long addr, int size)
+{
+ if (size < 0 || addr == 0)
+ return -EFAULT;
+ return bfin_mem_access_type(addr, size);
+}
+
+long probe_kernel_read(void *dst, void *src, size_t size)
+{
+ unsigned long lsrc = (unsigned long)src;
+ int mem_type;
+
+ mem_type = validate_memory_access_address(lsrc, size);
+ if (mem_type < 0)
+ return mem_type;
+
+ if (lsrc >= SYSMMR_BASE) {
+ if (size == 2 && lsrc % 2 == 0) {
+ u16 mmr = bfin_read16(src);
+ memcpy(dst, &mmr, sizeof(mmr));
+ return 0;
+ } else if (size == 4 && lsrc % 4 == 0) {
+ u32 mmr = bfin_read32(src);
+ memcpy(dst, &mmr, sizeof(mmr));
+ return 0;
+ }
+ } else {
+ switch (mem_type) {
+ case BFIN_MEM_ACCESS_CORE:
+ case BFIN_MEM_ACCESS_CORE_ONLY:
+ return probe_kernel_read(dst, src, size);
+ /* XXX: should support IDMA here with SMP */
+ case BFIN_MEM_ACCESS_DMA:
+ if (dma_memcpy(dst, src, size))
+ return 0;
+ break;
+ case BFIN_MEM_ACCESS_ITEST:
+ if (isram_memcpy(dst, src, size))
+ return 0;
+ break;
+ }
+ }
+
+ return -EFAULT;
+}
+
+long notrace probe_kernel_write(void *dst, void *src, size_t size)
+{
+ unsigned long ldst = (unsigned long)dst;
+ int mem_type;
+
+ mem_type = validate_memory_access_address(ldst, size);
+ if (mem_type < 0)
+ return mem_type;
+
+ if (ldst >= SYSMMR_BASE) {
+ if (size == 2 && ldst % 2 == 0) {
+ u16 mmr;
+ memcpy(&mmr, src, sizeof(mmr));
+ bfin_write16(dst, mmr);
+ return 0;
+ } else if (size == 4 && ldst % 4 == 0) {
+ u32 mmr;
+ memcpy(&mmr, src, sizeof(mmr));
+ bfin_write32(dst, mmr);
+ return 0;
+ }
+ } else {
+ switch (mem_type) {
+ case BFIN_MEM_ACCESS_CORE:
+ case BFIN_MEM_ACCESS_CORE_ONLY:
+ return probe_kernel_write(dst, src, size);
+ /* XXX: should support IDMA here with SMP */
+ case BFIN_MEM_ACCESS_DMA:
+ if (dma_memcpy(dst, src, size))
+ return 0;
+ break;
+ case BFIN_MEM_ACCESS_ITEST:
+ if (isram_memcpy(dst, src, size))
+ return 0;
+ break;
+ }
+ }
+
+ return -EFAULT;
+}
--- a/mm/maccess.c
+++ b/mm/maccess.c
@@ -14,7 +14,7 @@
* Safely read from address @src to the buffer at @dst. If a kernel fault
* happens, handle that and return -EFAULT.
*/
-long probe_kernel_read(void *dst, void *src, size_t size)
+long __weak probe_kernel_read(void *dst, void *src, size_t size)
{
long ret;
mm_segment_t old_fs = get_fs();
next prev parent reply other threads:[~2010-01-06 19:43 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-23 21:19 [PATCH 0/37] kgdb, kdb and atomic kernel modesetting series Jason Wessel
2009-12-23 21:19 ` [PATCH 01/37] softlockup: add sched_clock_tick() to avoid kernel warning on kgdb resume Jason Wessel
2009-12-23 21:19 ` [PATCH 02/37] x86,hw_breakpoint,kgdb: kgdb to use hw_breakpoint API Jason Wessel
2009-12-23 21:19 ` [PATCH 03/37] Move kernel/kgdb.c to kernel/debug/debug_core.c Jason Wessel
2009-12-23 21:19 ` [PATCH 04/37] Separate the gdbstub from the debug core Jason Wessel
2009-12-23 21:19 ` [PATCH 05/37] kdb: core for kgdb back end Jason Wessel
2009-12-23 21:19 ` [PATCH 06/37] kgdb: eliminate kgdb_wait(), all cpus enter the same way Jason Wessel
2009-12-23 21:19 ` [PATCH 07/37] kgdb,sparc: Add in kgdb_arch_set_pc for sparc Jason Wessel
2009-12-23 21:19 ` [PATCH 08/37] kgdb,sh: update superh kgdb exception handling Jason Wessel
2009-12-23 21:19 ` [PATCH 09/37] kgdb,blackfin: Add in kgdb_arch_set_pc for blackfin Jason Wessel
2009-12-23 21:19 ` [PATCH 10/37] kgdb: Make mem access function weak in kgdb.c and kgdb.h Jason Wessel
2009-12-23 21:19 ` [PATCH 11/37] kgdb: Fix kernel-doc format error in kgdb.h Jason Wessel
2009-12-23 21:19 ` [PATCH 12/37] kgdb: core changes to support kdb Jason Wessel
2009-12-23 21:19 ` [PATCH 13/37] kgdb,8250,pl011: Return immediately from console poll Jason Wessel
2009-12-23 21:19 ` [PATCH 14/37] sh,sh-sci: Use NO_POLL_CHAR in the SCIF polled console code Jason Wessel
2009-12-23 21:19 ` [PATCH 15/37] sparc,sunzilog: Add console polling support for sunzilog serial driver Jason Wessel
2009-12-23 21:19 ` [PATCH 16/37] kgdb: gdb "monitor" -> kdb passthrough Jason Wessel
2009-12-23 21:19 ` [PATCH 17/37] kgdboc,keyboard: Keyboard driver for kdb with kgdb Jason Wessel
2009-12-23 21:19 ` [PATCH 18/37] kgdb: remove post_primary_code references Jason Wessel
2009-12-23 21:19 ` [PATCH 19/37] x86,kgdb: Add low level debug hook Jason Wessel
2009-12-23 21:19 ` [PATCH 20/37] arm,kgdb: Add hook to catch an oops with debugger Jason Wessel
2009-12-23 21:19 ` [PATCH 21/37] powerpc,kgdb: Introduce low level trap catching Jason Wessel
2009-12-23 21:19 ` [PATCH 22/37] mips,kgdb: kdb low level trap catch and stack trace Jason Wessel
2009-12-23 21:19 ` [PATCH 23/37] kgdb: Add the ability to schedule a breakpoint via a tasklet Jason Wessel
2009-12-23 21:19 ` [PATCH 24/37] kgdboc,kdb: Allow kdb to work on a non open console port Jason Wessel
2009-12-23 21:19 ` [PATCH 25/37] printk,kdb: capture printk() when in kdb shell Jason Wessel
2009-12-23 21:19 ` [PATCH 26/37] keyboard, input: Add hook to input to allow low level event clear Jason Wessel
2009-12-23 21:19 ` [PATCH 27/37] debug_core,kdb: Allow the debug core to process a recursive debug entry Jason Wessel
2009-12-23 21:19 ` [PATCH 28/37] kdb,panic,debug_core: Allow the debug core to receive a panic before smp_send_stop() Jason Wessel
2009-12-23 21:19 ` [PATCH 29/37] MAINTAINERS: update kgdb, kdb, and debug_core info Jason Wessel
2009-12-23 21:19 ` [PATCH 30/37] kgdboc,debug_core: Add call backs to allow kernel mode switching Jason Wessel
2009-12-23 21:19 ` [PATCH 31/37] kgdb: add ops arg to kgdb console active & restore hooks Jason Wessel
2009-12-23 21:19 ` [PATCH 32/37] kms,kdb: Force unblank a console device Jason Wessel
2009-12-23 21:43 ` [PATCH 33/37] drm: add KGDB/KDB support Add support for KDB entry/exit Jason Wessel
2009-12-23 21:43 ` [PATCH 34/37] i915: when kgdb is active display compression should be off Jason Wessel
2009-12-23 21:43 ` [PATCH 35/37] drm_fb_helper: Preserve capability to use atomic kms Jason Wessel
2009-12-23 21:43 ` [PATCH 36/37] drm,i915 - atomic mutex hacks Jason Wessel
2009-12-23 21:43 ` [PATCH 37/37] kgdbts,sh: Add in breakpoint pc offset for superh Jason Wessel
2009-12-24 3:58 ` Paul Mundt
2010-01-04 17:23 ` [PATCH 33/37] drm: add KGDB/KDB support Add support for KDB entry/exit Jesse Barnes
2009-12-23 21:50 ` [PATCH 15/37] sparc,sunzilog: Add console polling support for sunzilog serial driver David Miller
2009-12-23 21:54 ` Jason Wessel
2009-12-23 22:00 ` David Miller
2009-12-24 6:08 ` [PATCH 14/37] sh,sh-sci: Use NO_POLL_CHAR in the SCIF polled console code Paul Mundt
2009-12-26 21:07 ` [PATCH 10/37] kgdb: Make mem access function weak in kgdb.c and kgdb.h Mike Frysinger
2009-12-26 21:12 ` [PATCH 09/37] kgdb,blackfin: Add in kgdb_arch_set_pc for blackfin Mike Frysinger
2009-12-28 9:49 ` Zhang, Sonic
2009-12-28 9:57 ` Zhang, Sonic
2009-12-28 10:17 ` Zhang, Sonic
2009-12-31 2:45 ` Sonic Zhang
2010-01-06 19:43 ` Jason Wessel [this message]
2010-01-06 20:08 ` [Kgdb-bugreport] " Mike Frysinger
2010-01-06 20:34 ` Jason Wessel
2010-01-06 20:39 ` Mike Frysinger
2010-01-06 22:40 ` Jason Wessel
2010-01-07 6:27 ` Mike Frysinger
2010-01-07 3:50 ` Zhang, Sonic
2009-12-24 6:07 ` [PATCH 08/37] kgdb,sh: update superh kgdb exception handling Paul Mundt
2009-12-23 21:48 ` [PATCH 07/37] kgdb,sparc: Add in kgdb_arch_set_pc for sparc David Miller
2009-12-23 23:04 ` Jason Wessel
2009-12-24 4:42 ` David Miller
2009-12-24 1:28 ` [PATCH 05/37] kdb: core for kgdb back end Andi Kleen
2009-12-28 22:36 ` Jason Wessel
2009-12-28 23:37 ` Andi Kleen
2009-12-24 11:01 ` Peter Zijlstra
2009-12-24 11:16 ` Peter Zijlstra
2009-12-24 15:57 ` Jason Wessel
2009-12-26 21:34 ` Mike Frysinger
2009-12-24 11:55 ` Jason Wessel
2009-12-24 12:01 ` Peter Zijlstra
2009-12-24 11:04 ` Peter Zijlstra
2009-12-28 16:33 ` Jason Wessel
2009-12-28 16:55 ` Peter Zijlstra
2009-12-28 17:15 ` Jason Wessel
2009-12-24 0:56 ` [PATCH 0/37] kgdb, kdb and atomic kernel modesetting series Greg KH
2009-12-24 3:55 ` [Kgdb-bugreport] [PATCH 0/37] kgdb,kdb " Jason Wessel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B44E7E3.10305@windriver.com \
--to=jason.wessel@windriver.com \
--cc=Sonic.Zhang@analog.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=sonic.adi@gmail.com \
--cc=vapier.adi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox