spufs: use new vm_ops->access to allow local state access from gdb
authorBenjamin Herrenschmidt <[email protected]>
Thu, 24 Jul 2008 04:27:09 +0000 (21:27 -0700)
committerLinus Torvalds <[email protected]>
Thu, 24 Jul 2008 17:47:15 +0000 (10:47 -0700)
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.

[[email protected]: fix typo]
Signed-off-by: Benjamin Herrenschmidt <[email protected]>
Signed-off-by: Rik van Riel <[email protected]>
Cc: Dave Airlie <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/powerpc/platforms/cell/spufs/file.c

index 99c73066b82f860cefc09f496d682be15b012aa0..010a51f59796b7a9068103bb6598843f9195fff4 100644 (file)
@@ -288,9 +288,32 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
        return VM_FAULT_NOPAGE;
 }
 
+static int spufs_mem_mmap_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_mmap_access,
 };
 
 static int spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)