4 * (C) Copyright IBM Deutschland Entwicklung GmbH 2007
6 * Author: Arnd Bergmann <arndb@de.ibm.com>
7 * Author: Jeremy Kerr <jk@ozlabs.org>
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)
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.
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.
23 #include <linux/sched.h>
25 #include <linux/export.h>
28 #include <asm/spu_csa.h>
31 * This ought to be kept in sync with the powerpc specific do_page_fault
32 * function. Currently, there are a few corner cases that we haven't had
33 * to handle fortunately.
35 int spu_handle_mm_fault(struct mm_struct
*mm
, unsigned long ea
,
36 unsigned long dsisr
, unsigned *flt
)
38 struct vm_area_struct
*vma
;
39 unsigned long is_write
;
48 down_read(&mm
->mmap_sem
);
50 vma
= find_vma(mm
, ea
);
54 if (ea
< vma
->vm_start
) {
55 if (!(vma
->vm_flags
& VM_GROWSDOWN
))
57 if (expand_stack(vma
, ea
))
61 is_write
= dsisr
& MFC_DSISR_ACCESS_PUT
;
63 if (!(vma
->vm_flags
& VM_WRITE
))
66 if (dsisr
& MFC_DSISR_ACCESS_DENIED
)
68 if (!(vma
->vm_flags
& (VM_READ
| VM_EXEC
)))
73 *flt
= handle_mm_fault(mm
, vma
, ea
, is_write
? FAULT_FLAG_WRITE
: 0);
74 if (unlikely(*flt
& VM_FAULT_ERROR
)) {
75 if (*flt
& VM_FAULT_OOM
) {
78 } else if (*flt
& VM_FAULT_SIGBUS
) {
85 if (*flt
& VM_FAULT_MAJOR
)
91 up_read(&mm
->mmap_sem
);
94 EXPORT_SYMBOL_GPL(spu_handle_mm_fault
);