aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/mm
diff options
context:
space:
mode:
authorIan Munsie <imunsie@au1.ibm.com>2014-10-08 04:54:50 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2014-10-08 05:14:54 -0400
commite83d01697583d8610d1d62279758c2a881e3396f (patch)
tree167a30304a5b48debcb66955efdf5f68808c1998 /arch/powerpc/mm
parent60666de2dac99777631d0df64257d7fd6a5118fe (diff)
powerpc/cell: Move spu_handle_mm_fault() out of cell platform
Currently spu_handle_mm_fault() is in the cell platform. This code is generically useful for other non-cell co-processors on powerpc. This patch moves this function out of the cell platform into arch/powerpc/mm so that others may use it. Signed-off-by: Ian Munsie <imunsie@au1.ibm.com> Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r--arch/powerpc/mm/Makefile1
-rw-r--r--arch/powerpc/mm/copro_fault.c92
2 files changed, 93 insertions, 0 deletions
diff --git a/arch/powerpc/mm/Makefile b/arch/powerpc/mm/Makefile
index d0130fff20e5..325e861616a1 100644
--- a/arch/powerpc/mm/Makefile
+++ b/arch/powerpc/mm/Makefile
@@ -34,3 +34,4 @@ obj-$(CONFIG_TRANSPARENT_HUGEPAGE) += hugepage-hash64.o
34obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage-prot.o 34obj-$(CONFIG_PPC_SUBPAGE_PROT) += subpage-prot.o
35obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o 35obj-$(CONFIG_NOT_COHERENT_CACHE) += dma-noncoherent.o
36obj-$(CONFIG_HIGHMEM) += highmem.o 36obj-$(CONFIG_HIGHMEM) += highmem.o
37obj-$(CONFIG_PPC_COPRO_BASE) += copro_fault.o
diff --git a/arch/powerpc/mm/copro_fault.c b/arch/powerpc/mm/copro_fault.c
new file mode 100644
index 000000000000..ba7df14c6b82
--- /dev/null
+++ b/arch/powerpc/mm/copro_fault.c
@@ -0,0 +1,92 @@
1/*
2 * CoProcessor (SPU/AFU) mm fault handler
3 *
4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2007
5 *
6 * Author: Arnd Bergmann <arndb@de.ibm.com>
7 * Author: Jeremy Kerr <jk@ozlabs.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23#include <linux/sched.h>
24#include <linux/mm.h>
25#include <linux/export.h>
26#include <asm/reg.h>
27
28/*
29 * This ought to be kept in sync with the powerpc specific do_page_fault
30 * function. Currently, there are a few corner cases that we haven't had
31 * to handle fortunately.
32 */
33int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,
34 unsigned long dsisr, unsigned *flt)
35{
36 struct vm_area_struct *vma;
37 unsigned long is_write;
38 int ret;
39
40 if (mm == NULL)
41 return -EFAULT;
42
43 if (mm->pgd == NULL)
44 return -EFAULT;
45
46 down_read(&mm->mmap_sem);
47 ret = -EFAULT;
48 vma = find_vma(mm, ea);
49 if (!vma)
50 goto out_unlock;
51
52 if (ea < vma->vm_start) {
53 if (!(vma->vm_flags & VM_GROWSDOWN))
54 goto out_unlock;
55 if (expand_stack(vma, ea))
56 goto out_unlock;
57 }
58
59 is_write = dsisr & DSISR_ISSTORE;
60 if (is_write) {
61 if (!(vma->vm_flags & VM_WRITE))
62 goto out_unlock;
63 } else {
64 if (dsisr & DSISR_PROTFAULT)
65 goto out_unlock;
66 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
67 goto out_unlock;
68 }
69
70 ret = 0;
71 *flt = handle_mm_fault(mm, vma, ea, is_write ? FAULT_FLAG_WRITE : 0);
72 if (unlikely(*flt & VM_FAULT_ERROR)) {
73 if (*flt & VM_FAULT_OOM) {
74 ret = -ENOMEM;
75 goto out_unlock;
76 } else if (*flt & VM_FAULT_SIGBUS) {
77 ret = -EFAULT;
78 goto out_unlock;
79 }
80 BUG();
81 }
82
83 if (*flt & VM_FAULT_MAJOR)
84 current->maj_flt++;
85 else
86 current->min_flt++;
87
88out_unlock:
89 up_read(&mm->mmap_sem);
90 return ret;
91}
92EXPORT_SYMBOL_GPL(copro_handle_mm_fault);