From: Benjamin Herrenschmidt This uses the new vm_ops->access to allow gdb to access the SPU local store. We currently prevent access to problem state registers, this can be done later if really needed but it's safer not to. Signed-off-by: Benjamin Herrenschmidt Signed-off-by: Rik van Riel Cc: Dave Airlie Cc: Hugh Dickins Cc: Paul Mackerras Cc: Arnd Bergmann On Fri, 16 May 2008 11:33:41 +0200 Arnd Bergmann wrote: > I'm also not entirely sure about the memcpy_{from,to}io, in all other > places in spufs, we just use plain pointer derefences, which I assume > is safe on local store (it does not have side-effects), and get_ls > may return either an ioremapped page or a kernel memory page, depending > on the state of ctx. Shouldn't matter either way, but the current code > triggers a sparse warning. Signed-off-by: Andrew Morton --- arch/powerpc/platforms/cell/spufs/file.c | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff -puN arch/powerpc/platforms/cell/spufs/file.c~spufs-use-the-new-vm_ops-access arch/powerpc/platforms/cell/spufs/file.c --- a/arch/powerpc/platforms/cell/spufs/file.c~spufs-use-the-new-vm_ops-access +++ a/arch/powerpc/platforms/cell/spufs/file.c @@ -288,9 +288,32 @@ spufs_mem_mmap_fault(struct vm_area_stru return VM_FAULT_NOPAGE; } +static int spufs_mem_mmep_access(struct vm_area_struct *vma, + unsigned long address, + void *buf, int len, int write) +{ + struct spu_context *ctx = vma->vm_file->private_data; + unsigned long offset = address - vma->vm_start; + char *local_store; + + if (write && !(vma->vm_flags & VM_WRITE)) + return -EACCES; + if (spu_acquire(ctx)) + return -EINTR; + if ((offset + len) > vma->vm_end) + len = vma->vm_end - offset; + local_store = ctx->ops->get_ls(ctx); + if (write) + memcpy_toio(local_store + offset, buf, len); + else + memcpy_fromio(buf, local_store + offset, len); + spu_release(ctx); + return len; +} static struct vm_operations_struct spufs_mem_mmap_vmops = { .fault = spufs_mem_mmap_fault, + .access = spufs_mem_mmep_access, }; static int spufs_mem_mmap(struct file *file, struct vm_area_struct *vma) _