Subject: Fix spu core dump contents From: Ulrich Weigand Signed-off-by: Arnd Bergmann Index: linux-2.6/arch/powerpc/platforms/cell/spu_coredump.c =================================================================== --- linux-2.6.orig/arch/powerpc/platforms/cell/spu_coredump.c +++ linux-2.6/arch/powerpc/platforms/cell/spu_coredump.c @@ -41,7 +41,7 @@ struct spu_file { }; static struct spu_file spu_files[NUM_SPU_NOTES] = { { "regs", 2048, }, /* binary: 128-bit * 128 */ - { "fpcr", 11, }, /* binary: 128-bit */ + { "fpcr", 16, }, /* binary: 128-bit */ { "lslr", 11, }, /* ascii: 0x + 8 bytes + nl */ { "decr", 11, }, /* ascii: 0x + 8 bytes + nl */ { "decr_status", 11, }, /* ascii: 0x + 8 bytes + nl */ @@ -57,7 +57,7 @@ static struct spu_file spu_files[NUM_SPU { "wbox_info", 16, }, /* binary: 32-bit * 4 (max) */ { "dma_info", 552, }, /* binary: 64-bit * 69 */ { "proxydma_info", 280, }, /* binary: 64-bit * 35 */ - { "object-id", 11, }, /* ascii: 0x + 8 bytes + nl */ + { "object-id", 19, }, /* ascii: 0x + 16 bytes + nl */ }; /* @@ -159,7 +159,7 @@ int spu_notes_size(void) INIT_LIST_HEAD(&tmp->list); tmp->dfd = i; tmp->memsize = spu_get_memsize(i); - sz = spu_ctx_note_size(tmp); + sz += spu_ctx_note_size(tmp); list_add(&tmp->list, &spu_ctx_list); } } @@ -179,53 +179,42 @@ cleanup: static void spu_write_note(struct spu_ctx_list *ctx, int i, struct file *file) { - int sz, dfd, fd, mem, rc, first = 1, last = 0, total = 0; + int sz, dfd, fd, rc, total = 0; char *name; char fullname[80], buf[4096]; struct elf_note en; dfd = ctx->dfd; name = spu_files[i].name; - sz = spu_files[i].size; if (!strcmp(name, "mem")) - mem = 1; + sz = ctx->memsize; else - mem = 0; + sz = spu_files[i].size; fd = sys_openat(dfd, name, O_RDONLY, 0400); if (fd < 0) - goto out; + return; + sprintf(fullname, "SPU/%d/%s", dfd, name); + en.n_namesz = strlen(fullname) + 1; + en.n_descsz = sz; + en.n_type = NT_SPU; + + DUMP_WRITE_RET(&en, sizeof(en)); + DUMP_WRITE_RET(fullname, en.n_namesz); + DUMP_SEEK_RET(roundup((unsigned long)file->f_pos, 4)); + do { rc = sys_read(fd, buf, sizeof buf); - total += rc; - if (rc < 0) - goto out; - if (rc < sizeof buf) - last = 1; - if (!rc) - continue; - if (first) { - en.n_namesz = strlen(fullname) + 1; - en.n_descsz = mem ? ctx->memsize : sz; - en.n_type = NT_SPU; - - DUMP_WRITE_RET(&en, sizeof(en)); - DUMP_WRITE_RET(fullname, en.n_namesz); - - DUMP_SEEK_RET(roundup((unsigned long)file->f_pos, 4)); - } - DUMP_WRITE_RET(buf, rc); - if (first || last) { - DUMP_SEEK_RET(roundup((unsigned long)file->f_pos, 4)); - first = 0; + if (rc > 0) { + DUMP_WRITE_RET(buf, rc); + total += rc; } - } while (rc > 0 && total < sizeof buf); + } while (rc == sizeof buf && total < sz); -out: - if (fd >= 0) - rc = sys_close(fd); + DUMP_SEEK_RET(roundup((unsigned long)file->f_pos - total + sz, 4)); + sys_close(fd); } void spu_write_notes(struct file *file)