Release 4.14 arch/powerpc/platforms/cell/spufs/coredump.c
/*
* SPU core dump code
*
* (C) Copyright 2006 IBM Corp.
*
* Author: Dwayne Grant McConnell <decimal@us.ibm.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <linux/elf.h>
#include <linux/file.h>
#include <linux/fdtable.h>
#include <linux/fs.h>
#include <linux/gfp.h>
#include <linux/list.h>
#include <linux/syscalls.h>
#include <linux/coredump.h>
#include <linux/binfmts.h>
#include <linux/uaccess.h>
#include "spufs.h"
static ssize_t do_coredump_read(int num, struct spu_context *ctx, void *buffer,
size_t size, loff_t *off)
{
u64 data;
int ret;
if (spufs_coredump_read[num].read)
return spufs_coredump_read[num].read(ctx, buffer, size, off);
data = spufs_coredump_read[num].get(ctx);
ret = snprintf(buffer, size, "0x%.16llx", data);
if (ret >= size)
return size;
return ++ret; /* count trailing NULL */
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dwayne Grant Mcconnell | 80 | 83.33% | 1 | 33.33% |
Michael Ellerman | 15 | 15.62% | 1 | 33.33% |
Stephen Rothwell | 1 | 1.04% | 1 | 33.33% |
Total | 96 | 100.00% | 3 | 100.00% |
static int spufs_ctx_note_size(struct spu_context *ctx, int dfd)
{
int i, sz, total = 0;
char *name;
char fullname[80];
for (i = 0; spufs_coredump_read[i].name != NULL; i++) {
name = spufs_coredump_read[i].name;
sz = spufs_coredump_read[i].size;
sprintf(fullname, "SPU/%d/%s", dfd, name);
total += sizeof(struct elf_note);
total += roundup(strlen(fullname) + 1, 4);
total += roundup(sz, 4);
}
return total;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dwayne Grant Mcconnell | 109 | 93.97% | 1 | 33.33% |
Michael Ellerman | 7 | 6.03% | 2 | 66.67% |
Total | 116 | 100.00% | 3 | 100.00% |
static int match_context(const void *v, struct file *file, unsigned fd)
{
struct spu_context *ctx;
if (file->f_op != &spufs_context_fops)
return 0;
ctx = SPUFS_I(file_inode(file))->i_ctx;
if (ctx->flags & SPU_CREATE_NOSCHED)
return 0;
return fd + 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Al Viro | 64 | 100.00% | 2 | 100.00% |
Total | 64 | 100.00% | 2 | 100.00% |
/*
* The additional architecture-specific notes for Cell are various
* context files in the spu context.
*
* This function iterates over all open file descriptors and sees
* if they are a directory in spufs. In that case we use spufs
* internal functionality to dump them without needing to actually
* open the files.
*/
/*
* descriptor table is not shared, so files can't change or go away.
*/
static struct spu_context *coredump_next_context(int *fd)
{
struct file *file;
int n = iterate_fd(current->files, *fd, match_context, NULL);
if (!n)
return NULL;
*fd = n - 1;
file = fcheck(*fd);
return SPUFS_I(file_inode(file))->i_ctx;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Al Viro | 27 | 39.71% | 2 | 50.00% |
Michael Ellerman | 25 | 36.76% | 1 | 25.00% |
Dwayne Grant Mcconnell | 16 | 23.53% | 1 | 25.00% |
Total | 68 | 100.00% | 4 | 100.00% |
int spufs_coredump_extra_notes_size(void)
{
struct spu_context *ctx;
int size = 0, rc, fd;
fd = 0;
while ((ctx = coredump_next_context(&fd)) != NULL) {
rc = spu_acquire_saved(ctx);
if (rc)
break;
rc = spufs_ctx_note_size(ctx, fd);
spu_release_saved(ctx);
if (rc < 0)
break;
size += rc;
/* start searching the next fd next time */
fd++;
}
return size;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Ellerman | 53 | 62.35% | 4 | 57.14% |
Dwayne Grant Mcconnell | 21 | 24.71% | 1 | 14.29% |
Christoph Hellwig | 7 | 8.24% | 1 | 14.29% |
Gerhard Stenzel | 4 | 4.71% | 1 | 14.29% |
Total | 85 | 100.00% | 7 | 100.00% |
static int spufs_arch_write_note(struct spu_context *ctx, int i,
struct coredump_params *cprm, int dfd)
{
loff_t pos = 0;
int sz, rc, total = 0;
const int bufsz = PAGE_SIZE;
char *name;
char fullname[80], *buf;
struct elf_note en;
size_t skip;
buf = (void *)get_zeroed_page(GFP_KERNEL);
if (!buf)
return -ENOMEM;
name = spufs_coredump_read[i].name;
sz = spufs_coredump_read[i].size;
sprintf(fullname, "SPU/%d/%s", dfd, name);
en.n_namesz = strlen(fullname) + 1;
en.n_descsz = sz;
en.n_type = NT_SPU;
if (!dump_emit(cprm, &en, sizeof(en)))
goto Eio;
if (!dump_emit(cprm, fullname, en.n_namesz))
goto Eio;
if (!dump_align(cprm, 4))
goto Eio;
do {
rc = do_coredump_read(i, ctx, buf, bufsz, &pos);
if (rc > 0) {
if (!dump_emit(cprm, buf, rc))
goto Eio;
total += rc;
}
} while (rc == bufsz && total < sz);
if (rc < 0)
goto out;
skip = roundup(cprm->pos - total + sz, 4) - cprm->pos;
if (!dump_skip(cprm, skip))
goto Eio;
rc = 0;
out:
free_page((unsigned long)buf);
return rc;
Eio:
free_page((unsigned long)buf);
return -EIO;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dwayne Grant Mcconnell | 191 | 60.83% | 1 | 10.00% |
Al Viro | 56 | 17.83% | 3 | 30.00% |
Michael Ellerman | 26 | 8.28% | 3 | 30.00% |
Arnd Bergmann | 25 | 7.96% | 1 | 10.00% |
Omar Sandoval | 14 | 4.46% | 1 | 10.00% |
Mateusz Guzik | 2 | 0.64% | 1 | 10.00% |
Total | 314 | 100.00% | 10 | 100.00% |
int spufs_coredump_extra_notes_write(struct coredump_params *cprm)
{
struct spu_context *ctx;
int fd, j, rc;
fd = 0;
while ((ctx = coredump_next_context(&fd)) != NULL) {
rc = spu_acquire_saved(ctx);
if (rc)
return rc;
for (j = 0; spufs_coredump_read[j].name != NULL; j++) {
rc = spufs_arch_write_note(ctx, j, cprm, fd);
if (rc) {
spu_release_saved(ctx);
return rc;
}
}
spu_release_saved(ctx);
/* start searching the next fd next time */
fd++;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Michael Ellerman | 57 | 49.57% | 4 | 44.44% |
Dwayne Grant Mcconnell | 41 | 35.65% | 1 | 11.11% |
Christoph Hellwig | 10 | 8.70% | 2 | 22.22% |
Gerhard Stenzel | 4 | 3.48% | 1 | 11.11% |
Al Viro | 3 | 2.61% | 1 | 11.11% |
Total | 115 | 100.00% | 9 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Dwayne Grant Mcconnell | 480 | 53.69% | 1 | 4.17% |
Michael Ellerman | 183 | 20.47% | 8 | 33.33% |
Al Viro | 160 | 17.90% | 6 | 25.00% |
Arnd Bergmann | 25 | 2.80% | 1 | 4.17% |
Christoph Hellwig | 17 | 1.90% | 2 | 8.33% |
Omar Sandoval | 14 | 1.57% | 1 | 4.17% |
Gerhard Stenzel | 8 | 0.89% | 1 | 4.17% |
Tejun Heo | 3 | 0.34% | 1 | 4.17% |
Mateusz Guzik | 2 | 0.22% | 1 | 4.17% |
Stephen Rothwell | 1 | 0.11% | 1 | 4.17% |
Linus Torvalds | 1 | 0.11% | 1 | 4.17% |
Total | 894 | 100.00% | 24 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.