hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/hexagon/mm/vm_fault.c
....@@ -1,21 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Memory fault handling for Hexagon
34 *
45 * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 and
8
- * only version 2 as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
- * 02110-1301, USA.
196 */
207
218 /*
....@@ -24,7 +11,6 @@
2411 * execptions.
2512 */
2613
27
-#include <asm/pgtable.h>
2814 #include <asm/traps.h>
2915 #include <linux/uaccess.h>
3016 #include <linux/mm.h>
....@@ -32,6 +18,7 @@
3218 #include <linux/signal.h>
3319 #include <linux/extable.h>
3420 #include <linux/hardirq.h>
21
+#include <linux/perf_event.h>
3522
3623 /*
3724 * Decode of hardware exception sends us to one of several
....@@ -54,7 +41,7 @@
5441 int si_code = SEGV_MAPERR;
5542 vm_fault_t fault;
5643 const struct exception_table_entry *fixup;
57
- unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
44
+ unsigned int flags = FAULT_FLAG_DEFAULT;
5845
5946 /*
6047 * If we're in an interrupt or have no user context,
....@@ -67,8 +54,10 @@
6754
6855 if (user_mode(regs))
6956 flags |= FAULT_FLAG_USER;
57
+
58
+ perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
7059 retry:
71
- down_read(&mm->mmap_sem);
60
+ mmap_read_lock(mm);
7261 vma = find_vma(mm, address);
7362 if (!vma)
7463 goto bad_area;
....@@ -102,30 +91,25 @@
10291 break;
10392 }
10493
105
- fault = handle_mm_fault(vma, address, flags);
94
+ fault = handle_mm_fault(vma, address, flags, regs);
10695
107
- if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current))
96
+ if (fault_signal_pending(fault, regs))
10897 return;
10998
11099 /* The most common case -- we are done. */
111100 if (likely(!(fault & VM_FAULT_ERROR))) {
112101 if (flags & FAULT_FLAG_ALLOW_RETRY) {
113
- if (fault & VM_FAULT_MAJOR)
114
- current->maj_flt++;
115
- else
116
- current->min_flt++;
117102 if (fault & VM_FAULT_RETRY) {
118
- flags &= ~FAULT_FLAG_ALLOW_RETRY;
119103 flags |= FAULT_FLAG_TRIED;
120104 goto retry;
121105 }
122106 }
123107
124
- up_read(&mm->mmap_sem);
108
+ mmap_read_unlock(mm);
125109 return;
126110 }
127111
128
- up_read(&mm->mmap_sem);
112
+ mmap_read_unlock(mm);
129113
130114 /* Handle copyin/out exception cases */
131115 if (!user_mode(regs))
....@@ -148,14 +132,14 @@
148132 si_signo = SIGSEGV;
149133 si_code = SEGV_ACCERR;
150134 }
151
- force_sig_fault(si_signo, si_code, (void __user *)address, current);
135
+ force_sig_fault(si_signo, si_code, (void __user *)address);
152136 return;
153137
154138 bad_area:
155
- up_read(&mm->mmap_sem);
139
+ mmap_read_unlock(mm);
156140
157141 if (user_mode(regs)) {
158
- force_sig_fault(SIGSEGV, si_code, (void __user *)address, current);
142
+ force_sig_fault(SIGSEGV, si_code, (void __user *)address);
159143 return;
160144 }
161145 /* Kernel-mode fault falls through */