| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * CoProcessor (SPU/AFU) mm fault handler |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Author: Arnd Bergmann <arndb@de.ibm.com> |
|---|
| 7 | 8 | * 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 | 9 | */ |
|---|
| 23 | 10 | #include <linux/sched.h> |
|---|
| 24 | 11 | #include <linux/mm.h> |
|---|
| .. | .. |
|---|
| 46 | 33 | if (mm->pgd == NULL) |
|---|
| 47 | 34 | return -EFAULT; |
|---|
| 48 | 35 | |
|---|
| 49 | | - down_read(&mm->mmap_sem); |
|---|
| 36 | + mmap_read_lock(mm); |
|---|
| 50 | 37 | ret = -EFAULT; |
|---|
| 51 | 38 | vma = find_vma(mm, ea); |
|---|
| 52 | 39 | if (!vma) |
|---|
| .. | .. |
|---|
| 77 | 64 | } |
|---|
| 78 | 65 | |
|---|
| 79 | 66 | ret = 0; |
|---|
| 80 | | - *flt = handle_mm_fault(vma, ea, is_write ? FAULT_FLAG_WRITE : 0); |
|---|
| 67 | + *flt = handle_mm_fault(vma, ea, is_write ? FAULT_FLAG_WRITE : 0, NULL); |
|---|
| 81 | 68 | if (unlikely(*flt & VM_FAULT_ERROR)) { |
|---|
| 82 | 69 | if (*flt & VM_FAULT_OOM) { |
|---|
| 83 | 70 | ret = -ENOMEM; |
|---|
| .. | .. |
|---|
| 89 | 76 | BUG(); |
|---|
| 90 | 77 | } |
|---|
| 91 | 78 | |
|---|
| 92 | | - if (*flt & VM_FAULT_MAJOR) |
|---|
| 93 | | - current->maj_flt++; |
|---|
| 94 | | - else |
|---|
| 95 | | - current->min_flt++; |
|---|
| 96 | | - |
|---|
| 97 | 79 | out_unlock: |
|---|
| 98 | | - up_read(&mm->mmap_sem); |
|---|
| 80 | + mmap_read_unlock(mm); |
|---|
| 99 | 81 | return ret; |
|---|
| 100 | 82 | } |
|---|
| 101 | 83 | EXPORT_SYMBOL_GPL(copro_handle_mm_fault); |
|---|
| .. | .. |
|---|
| 105 | 87 | u64 vsid, vsidkey; |
|---|
| 106 | 88 | int psize, ssize; |
|---|
| 107 | 89 | |
|---|
| 108 | | - switch (REGION_ID(ea)) { |
|---|
| 90 | + switch (get_region_id(ea)) { |
|---|
| 109 | 91 | case USER_REGION_ID: |
|---|
| 110 | 92 | pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea); |
|---|
| 111 | 93 | if (mm == NULL) |
|---|
| .. | .. |
|---|
| 117 | 99 | break; |
|---|
| 118 | 100 | case VMALLOC_REGION_ID: |
|---|
| 119 | 101 | pr_devel("%s: 0x%llx -- VMALLOC_REGION_ID\n", __func__, ea); |
|---|
| 120 | | - if (ea < VMALLOC_END) |
|---|
| 121 | | - psize = mmu_vmalloc_psize; |
|---|
| 122 | | - else |
|---|
| 123 | | - psize = mmu_io_psize; |
|---|
| 102 | + psize = mmu_vmalloc_psize; |
|---|
| 124 | 103 | ssize = mmu_kernel_ssize; |
|---|
| 125 | 104 | vsid = get_kernel_vsid(ea, mmu_kernel_ssize); |
|---|
| 126 | 105 | vsidkey = SLB_VSID_KERNEL; |
|---|
| 127 | 106 | break; |
|---|
| 128 | | - case KERNEL_REGION_ID: |
|---|
| 129 | | - pr_devel("%s: 0x%llx -- KERNEL_REGION_ID\n", __func__, ea); |
|---|
| 107 | + case IO_REGION_ID: |
|---|
| 108 | + pr_devel("%s: 0x%llx -- IO_REGION_ID\n", __func__, ea); |
|---|
| 109 | + psize = mmu_io_psize; |
|---|
| 110 | + ssize = mmu_kernel_ssize; |
|---|
| 111 | + vsid = get_kernel_vsid(ea, mmu_kernel_ssize); |
|---|
| 112 | + vsidkey = SLB_VSID_KERNEL; |
|---|
| 113 | + break; |
|---|
| 114 | + case LINEAR_MAP_REGION_ID: |
|---|
| 115 | + pr_devel("%s: 0x%llx -- LINEAR_MAP_REGION_ID\n", __func__, ea); |
|---|
| 130 | 116 | psize = mmu_linear_psize; |
|---|
| 131 | 117 | ssize = mmu_kernel_ssize; |
|---|
| 132 | 118 | vsid = get_kernel_vsid(ea, mmu_kernel_ssize); |
|---|