public inbox for linuxppc-dev@ozlabs.org
 help / color / mirror / Atom feed
From: Jeremy Kerr <jk@ozlabs.org>
To: <linuxppc-dev@ozlabs.org>
Subject: [PATCH 15/25] spufs: Write some SPU coredump values as ASCII
Date: Fri, 14 Sep 2007 16:32:54 +1000	[thread overview]
Message-ID: <1189751574.107417.626327179757.15.gpush@pokey> (raw)
In-Reply-To: <1189751574.98527.127994196313.1.gpush@pokey>

From: Michael Ellerman <michael@ellerman.id.au>

Unfortunately GDB expects some of the SPU coredump values to be identical
in format to what is found in spufs. This means we need to dump some of
the values as ASCII strings, not the actual values.

Because we don't know what the values will be, we always print the values
with the format "0x%.16lx", that way we know the result will be 19 bytes.

do_coredump_read() doesn't take a __user buffer, so remove the annotation,
and because we know that it's safe to just snprintf() directly to it.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>

---
 arch/powerpc/platforms/cell/spufs/coredump.c |    8 +++++---
 arch/powerpc/platforms/cell/spufs/file.c     |   14 +++++++-------
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/platforms/cell/spufs/coredump.c b/arch/powerpc/platforms/cell/spufs/coredump.c
index 21283f6..c65b717 100644
--- a/arch/powerpc/platforms/cell/spufs/coredump.c
+++ b/arch/powerpc/platforms/cell/spufs/coredump.c
@@ -31,7 +31,7 @@
 
 #include "spufs.h"
 
-static ssize_t do_coredump_read(int num, struct spu_context *ctx, void __user *buffer,
+static ssize_t do_coredump_read(int num, struct spu_context *ctx, void *buffer,
 				size_t size, loff_t *off)
 {
 	u64 data;
@@ -41,8 +41,10 @@ static ssize_t do_coredump_read(int num, struct spu_context *ctx, void __user *b
 		return spufs_coredump_read[num].read(ctx, buffer, size, off);
 
 	data = spufs_coredump_read[num].get(ctx);
-	ret = copy_to_user(buffer, &data, 8);
-	return ret ? -EFAULT : 8;
+	ret = snprintf(buffer, size, "0x%.16lx", data);
+	if (ret >= size)
+		return size;
+	return ++ret; /* count trailing NULL */
 }
 
 /*
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 18ddde8..85edbec 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2233,16 +2233,16 @@ struct tree_descr spufs_dir_nosched_contents[] = {
 struct spufs_coredump_reader spufs_coredump_read[] = {
 	{ "regs", __spufs_regs_read, NULL, sizeof(struct spu_reg128[128])},
 	{ "fpcr", __spufs_fpcr_read, NULL, sizeof(struct spu_reg128) },
-	{ "lslr", NULL, __spufs_lslr_get, 11 },
-	{ "decr", NULL, __spufs_decr_get, 11 },
-	{ "decr_status", NULL, __spufs_decr_status_get, 11 },
+	{ "lslr", NULL, __spufs_lslr_get, 19 },
+	{ "decr", NULL, __spufs_decr_get, 19 },
+	{ "decr_status", NULL, __spufs_decr_status_get, 19 },
 	{ "mem", __spufs_mem_read, NULL, LS_SIZE, },
 	{ "signal1", __spufs_signal1_read, NULL, sizeof(u32) },
-	{ "signal1_type", NULL, __spufs_signal1_type_get, 2 },
+	{ "signal1_type", NULL, __spufs_signal1_type_get, 19 },
 	{ "signal2", __spufs_signal2_read, NULL, sizeof(u32) },
-	{ "signal2_type", NULL, __spufs_signal2_type_get, 2 },
-	{ "event_mask", NULL, __spufs_event_mask_get, 8 },
-	{ "event_status", NULL, __spufs_event_status_get, 8 },
+	{ "signal2_type", NULL, __spufs_signal2_type_get, 19 },
+	{ "event_mask", NULL, __spufs_event_mask_get, 19 },
+	{ "event_status", NULL, __spufs_event_status_get, 19 },
 	{ "mbox_info", __spufs_mbox_info_read, NULL, sizeof(u32) },
 	{ "ibox_info", __spufs_ibox_info_read, NULL, sizeof(u32) },
 	{ "wbox_info", __spufs_wbox_info_read, NULL, 4 * sizeof(u32)},

  parent reply	other threads:[~2007-09-14  6:32 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-14  6:32 [PATCH 01/25] spufs: staticify file-internal functions & variables Jeremy Kerr
2007-09-14  6:32 ` [PATCH 16/25] spufs: Correctly calculate the size of the local-store to dump Jeremy Kerr
2007-09-14  6:32 ` [PATCH 06/25] cell: unify spufs syscall path Jeremy Kerr
2007-09-14  6:32 ` [PATCH 18/25] spufs: Get rid of spufs_coredump_num_notes, it's not needed if we NULL terminate Jeremy Kerr
2007-09-14  6:32 ` [PATCH 09/25] cell: remove DEBUG for spu callbacks Jeremy Kerr
2007-09-14  7:43   ` Christoph Hellwig
2007-09-14  6:32 ` [PATCH 08/25] Fix restore_decr_wrapped() to match CBE Handbook Jeremy Kerr
2007-09-14  6:32 ` [PATCH 24/25] spufs: Respect RLIMIT_CORE in spu coredump code Jeremy Kerr
2007-09-14  6:32 ` [PATCH 10/25] spusched: fix null pointer dereference in find_victim Jeremy Kerr
2007-09-14  7:44   ` Christoph Hellwig
2007-09-20  0:13     ` Jeremy Kerr
2007-09-14  6:32 ` [PATCH 05/25] spufs: fix race condition on gang->aff_ref_spu Jeremy Kerr
2007-09-14  6:32 ` [PATCH 14/25] spufs: Use computed sizes/#defines rather than literals in SPU coredump code Jeremy Kerr
2007-09-14  6:32 ` [PATCH 19/25] spufs: Internal __spufs_get_foo() routines should take a spu_context * Jeremy Kerr
2007-09-14  7:43   ` Christoph Hellwig
2007-09-14  6:32 ` [PATCH 03/25] spufs: remove spu_harvest Jeremy Kerr
2007-09-14  6:32 ` [PATCH 02/25] spufs: remove asmlinkage from do_spu_create Jeremy Kerr
2007-09-14  7:44   ` Christoph Hellwig
2007-09-14  6:32 ` [PATCH 07/25] spufs: remove asmlinkage from spufs_calls Jeremy Kerr
2007-09-14  6:32 ` [PATCH 22/25] spufs: Cleanup ELF coredump extra notes logic Jeremy Kerr
2007-09-14  6:32 ` [PATCH 13/25] spufs: Call spu_acquire_saved() before calculating the SPU note sizes Jeremy Kerr
2007-09-14  6:32 ` [PATCH 25/25] spufs: Add DEFINE_SPUFS_ATTRIBUTE() Jeremy Kerr
2007-09-14  6:32 ` [PATCH 04/25] spufs: make isolated loader properly aligned Jeremy Kerr
2007-09-14  6:32 ` [PATCH 20/25] spufs: Add contents of npc file to SPU coredumps Jeremy Kerr
2007-09-14  6:32 ` [PATCH 23/25] spufs: Handle errors in SPU coredump code, and support coredump to a pipe Jeremy Kerr
2007-09-14  6:32 ` Jeremy Kerr [this message]
2007-09-14  6:32 ` [PATCH 17/25] spufs: Don't return -ENOSYS as extra notes size if spufs is not loaded Jeremy Kerr
2007-09-14  6:32 ` [PATCH 11/25] spufs: Extract the file descriptor search logic in SPU coredump code Jeremy Kerr
2007-09-14  6:32 ` [PATCH 21/25] spufs: Combine spufs_coredump_calls with spufs_calls Jeremy Kerr
2007-09-14  6:32 ` [PATCH 12/25] spufs: Remove ctx_info and ctx_info_list Jeremy Kerr
2007-09-14  7:42 ` [PATCH 01/25] spufs: staticify file-internal functions & variables Christoph Hellwig

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=1189751574.107417.626327179757.15.gpush@pokey \
    --to=jk@ozlabs.org \
    --cc=linuxppc-dev@ozlabs.org \
    /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