[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20080429113504.0b916341@cuia.boston.redhat.com>
Date: Tue, 29 Apr 2008 11:35:04 -0400
From: Rik van Riel <riel@...hat.com>
To: linux-kernel@...r.kernel.org, benh@...nel.crashing.org,
ajackson@...hat.com, airlied@...hat.com, akpm@...ux-foundation.org
Subject: [PATCH 3/3] spufs use the new vm_ops->access
spufs: use new vm_ops->access to allow local state access from gdb
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: Rik van Riel <riel@...hat.com>
Signed-off-by: Benjamin Herrenschmidt <benh@...nel.crashing.org>
---
Index: linux-work/arch/powerpc/platforms/cell/spufs/file.c
===================================================================
--- linux-work.orig/arch/powerpc/platforms/cell/spufs/file.c 2008-04-29 13:20:47.000000000 +1000
+++ linux-work/arch/powerpc/platforms/cell/spufs/file.c 2008-04-29 15:15:14.000000000 +1000
@@ -285,9 +285,32 @@ static unsigned long spufs_mem_mmap_nopf
return NOPFN_REFAULT;
}
+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 = {
.nopfn = spufs_mem_mmap_nopfn,
+ .access = spufs_mem_mmep_access,
};
static int spufs_mem_mmap(struct file *file, struct vm_area_struct *vma)
@@ -403,6 +426,13 @@ refault:
return NOPFN_REFAULT;
}
+static int spufs_no_access(struct vm_area_struct *vma,
+ unsigned long addr,
+ void *buf, int len, int write)
+{
+ return -EINVAL;
+}
+
#if SPUFS_MMAP_4K
static unsigned long spufs_cntl_mmap_nopfn(struct vm_area_struct *vma,
unsigned long address)
@@ -412,6 +442,7 @@ static unsigned long spufs_cntl_mmap_nop
static struct vm_operations_struct spufs_cntl_mmap_vmops = {
.nopfn = spufs_cntl_mmap_nopfn,
+ .access = spufs_no_access,
};
/*
@@ -1113,6 +1144,7 @@ static unsigned long spufs_signal1_mmap_
static struct vm_operations_struct spufs_signal1_mmap_vmops = {
.nopfn = spufs_signal1_mmap_nopfn,
+ .access = spufs_no_access,
};
static int spufs_signal1_mmap(struct file *file, struct vm_area_struct *vma)
@@ -1250,6 +1282,7 @@ static unsigned long spufs_signal2_mmap_
static struct vm_operations_struct spufs_signal2_mmap_vmops = {
.nopfn = spufs_signal2_mmap_nopfn,
+ .access = spufs_no_access,
};
static int spufs_signal2_mmap(struct file *file, struct vm_area_struct *vma)
@@ -1369,6 +1402,7 @@ static unsigned long spufs_mss_mmap_nopf
static struct vm_operations_struct spufs_mss_mmap_vmops = {
.nopfn = spufs_mss_mmap_nopfn,
+ .access = spufs_no_access,
};
/*
@@ -1431,6 +1465,7 @@ static unsigned long spufs_psmap_mmap_no
static struct vm_operations_struct spufs_psmap_mmap_vmops = {
.nopfn = spufs_psmap_mmap_nopfn,
+ .access = spufs_no_access,
};
/*
@@ -1491,6 +1526,7 @@ static unsigned long spufs_mfc_mmap_nopf
static struct vm_operations_struct spufs_mfc_mmap_vmops = {
.nopfn = spufs_mfc_mmap_nopfn,
+ .access = spufs_no_access,
};
/*
--
All Rights Reversed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists