hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/arc/mm/tlbex.S
....@@ -1,11 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * TLB Exception Handling for ARC
34 *
45 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
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 as
8
- * published by the Free Software Foundation.
96 *
107 * Vineetg: April 2011 :
118 * -MMU v1: moved out legacy code into a seperate file
....@@ -36,9 +33,9 @@
3633 */
3734
3835 #include <linux/linkage.h>
36
+#include <linux/pgtable.h>
3937 #include <asm/entry.h>
4038 #include <asm/mmu.h>
41
-#include <asm/pgtable.h>
4239 #include <asm/arcregs.h>
4340 #include <asm/cache.h>
4441 #include <asm/processor.h>
....@@ -125,17 +122,27 @@
125122 #else /* ARCv2 */
126123
127124 .macro TLBMISS_FREEUP_REGS
125
+#ifdef CONFIG_ARC_HAS_LL64
126
+ std r0, [sp, -16]
127
+ std r2, [sp, -8]
128
+#else
128129 PUSH r0
129130 PUSH r1
130131 PUSH r2
131132 PUSH r3
133
+#endif
132134 .endm
133135
134136 .macro TLBMISS_RESTORE_REGS
137
+#ifdef CONFIG_ARC_HAS_LL64
138
+ ldd r0, [sp, -16]
139
+ ldd r2, [sp, -8]
140
+#else
135141 POP r3
136142 POP r2
137143 POP r1
138144 POP r0
145
+#endif
139146 .endm
140147
141148 #endif
....@@ -196,7 +203,7 @@
196203
197204 lr r2, [efa]
198205
199
-#ifndef CONFIG_SMP
206
+#ifdef ARC_USE_SCRATCH_REG
200207 lr r1, [ARC_REG_SCRATCH_DATA0] ; current pgd
201208 #else
202209 GET_CURR_TASK_ON_CPU r1
....@@ -274,22 +281,11 @@
274281 .macro COMMIT_ENTRY_TO_MMU
275282 #if (CONFIG_ARC_MMU_VER < 4)
276283
277
-#ifdef CONFIG_EZNPS_MTM_EXT
278
- /* verify if entry for this vaddr+ASID already exists */
279
- sr TLBProbe, [ARC_REG_TLBCOMMAND]
280
- lr r0, [ARC_REG_TLBINDEX]
281
- bbit0 r0, 31, 88f
282
-#endif
283
-
284284 /* Get free TLB slot: Set = computed from vaddr, way = random */
285285 sr TLBGetIndex, [ARC_REG_TLBCOMMAND]
286286
287287 /* Commit the Write */
288
-#if (CONFIG_ARC_MMU_VER >= 2) /* introduced in v2 */
289288 sr TLBWriteNI, [ARC_REG_TLBCOMMAND]
290
-#else
291
- sr TLBWrite, [ARC_REG_TLBCOMMAND]
292
-#endif
293289
294290 #else
295291 sr TLBInsertEntry, [ARC_REG_TLBCOMMAND]
....@@ -373,9 +369,7 @@
373369
374370 ;----------------------------------------------------------------
375371 ; UPDATE_PTE: Let Linux VM know that page was accessed/dirty
376
- lr r3, [ecr]
377372 or r0, r0, _PAGE_ACCESSED ; Accessed bit always
378
- btst_s r3, ECR_C_BIT_DTLB_ST_MISS ; See if it was a Write Access ?
379373 or.nz r0, r0, _PAGE_DIRTY ; if Write, set Dirty bit as well
380374 st_s r0, [r1] ; Write back PTE
381375
....@@ -396,6 +390,17 @@
396390 ;-------- Common routine to call Linux Page Fault Handler -----------
397391 do_slow_path_pf:
398392
393
+#ifdef CONFIG_ISA_ARCV2
394
+ ; Set Z flag if exception in U mode. Hardware micro-ops do this on any
395
+ ; taken interrupt/exception, and thus is already the case at the entry
396
+ ; above, but ensuing code would have already clobbered.
397
+ ; EXCEPTION_PROLOGUE called in slow path, relies on correct Z flag set
398
+
399
+ lr r2, [erstatus]
400
+ and r2, r2, STATUS_U_MASK
401
+ bxor.f 0, r2, STATUS_U_BIT
402
+#endif
403
+
399404 ; Restore the 4-scratch regs saved by fast path miss handler
400405 TLBMISS_RESTORE_REGS
401406