Skip to content

Commit ad4aa06

Browse files
John David Anglinhdeller
authored andcommitted
parisc: Add nop instructions after TLB inserts
An excerpt from the PA8800 ERS states: * The PA8800 violates the seven instruction pipeline rule when performing TLB inserts or PxTLBE instructions with the PSW C bit on. The instruction will take effect by the 12th instruction after the insert or purge. I believe we have a problem with handling TLB misses. We don't fill the pipeline following TLB inserts. As a result, we likely fault again after returning from the interruption. The above statement indicates that we need at least seven instructions after the insert on pre PA8800 processors and we need 12 instructions on PA8800/PA8900 processors. Here we add macros and code to provide the required number instructions after a TLB insert. Signed-off-by: John David Anglin <dave.anglin@bell.net> Suggested-by: Helge Deller <deller@gmx.de> Cc: stable@vger.kernel.org Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 1c7431b commit ad4aa06

File tree

1 file changed

+52
-29
lines changed

1 file changed

+52
-29
lines changed

arch/parisc/kernel/entry.S

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@
3636
.level 2.0
3737
#endif
3838

39+
/*
40+
* We need seven instructions after a TLB insert for it to take effect.
41+
* The PA8800/PA8900 processors are an exception and need 12 instructions.
42+
* The RFI changes both IAOQ_Back and IAOQ_Front, so it counts as one.
43+
*/
44+
#ifdef CONFIG_64BIT
45+
#define NUM_PIPELINE_INSNS 12
46+
#else
47+
#define NUM_PIPELINE_INSNS 7
48+
#endif
49+
50+
/* Insert num nops */
51+
.macro insert_nops num
52+
.rept \num
53+
nop
54+
.endr
55+
.endm
56+
3957
/* Get aligned page_table_lock address for this mm from cr28/tr4 */
4058
.macro get_ptl reg
4159
mfctl %cr28,\reg
@@ -415,24 +433,20 @@
415433
3:
416434
.endm
417435

418-
/* Release page_table_lock without reloading lock address.
419-
We use an ordered store to ensure all prior accesses are
420-
performed prior to releasing the lock. */
421-
.macro ptl_unlock0 spc,tmp,tmp2
436+
/* Release page_table_lock if for user space. We use an ordered
437+
store to ensure all prior accesses are performed prior to
438+
releasing the lock. Note stw may not be executed, so we
439+
provide one extra nop when CONFIG_TLB_PTLOCK is defined. */
440+
.macro ptl_unlock spc,tmp,tmp2
422441
#ifdef CONFIG_TLB_PTLOCK
423-
98: ldi __ARCH_SPIN_LOCK_UNLOCKED_VAL, \tmp2
442+
98: get_ptl \tmp
443+
ldi __ARCH_SPIN_LOCK_UNLOCKED_VAL, \tmp2
424444
or,COND(=) %r0,\spc,%r0
425445
stw,ma \tmp2,0(\tmp)
426446
99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
427-
#endif
428-
.endm
429-
430-
/* Release page_table_lock. */
431-
.macro ptl_unlock1 spc,tmp,tmp2
432-
#ifdef CONFIG_TLB_PTLOCK
433-
98: get_ptl \tmp
434-
ptl_unlock0 \spc,\tmp,\tmp2
435-
99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
447+
insert_nops NUM_PIPELINE_INSNS - 4
448+
#else
449+
insert_nops NUM_PIPELINE_INSNS - 1
436450
#endif
437451
.endm
438452

@@ -1124,7 +1138,7 @@ dtlb_miss_20w:
11241138

11251139
idtlbt pte,prot
11261140

1127-
ptl_unlock1 spc,t0,t1
1141+
ptl_unlock spc,t0,t1
11281142
rfir
11291143
nop
11301144

@@ -1133,6 +1147,7 @@ dtlb_check_alias_20w:
11331147

11341148
idtlbt pte,prot
11351149

1150+
insert_nops NUM_PIPELINE_INSNS - 1
11361151
rfir
11371152
nop
11381153

@@ -1150,7 +1165,7 @@ nadtlb_miss_20w:
11501165

11511166
idtlbt pte,prot
11521167

1153-
ptl_unlock1 spc,t0,t1
1168+
ptl_unlock spc,t0,t1
11541169
rfir
11551170
nop
11561171

@@ -1159,6 +1174,7 @@ nadtlb_check_alias_20w:
11591174

11601175
idtlbt pte,prot
11611176

1177+
insert_nops NUM_PIPELINE_INSNS - 1
11621178
rfir
11631179
nop
11641180

@@ -1184,7 +1200,7 @@ dtlb_miss_11:
11841200

11851201
mtsp t1, %sr1 /* Restore sr1 */
11861202

1187-
ptl_unlock1 spc,t0,t1
1203+
ptl_unlock spc,t0,t1
11881204
rfir
11891205
nop
11901206

@@ -1194,6 +1210,7 @@ dtlb_check_alias_11:
11941210
idtlba pte,(va)
11951211
idtlbp prot,(va)
11961212

1213+
insert_nops NUM_PIPELINE_INSNS - 1
11971214
rfir
11981215
nop
11991216

@@ -1217,7 +1234,7 @@ nadtlb_miss_11:
12171234

12181235
mtsp t1, %sr1 /* Restore sr1 */
12191236

1220-
ptl_unlock1 spc,t0,t1
1237+
ptl_unlock spc,t0,t1
12211238
rfir
12221239
nop
12231240

@@ -1227,6 +1244,7 @@ nadtlb_check_alias_11:
12271244
idtlba pte,(va)
12281245
idtlbp prot,(va)
12291246

1247+
insert_nops NUM_PIPELINE_INSNS - 1
12301248
rfir
12311249
nop
12321250

@@ -1246,7 +1264,7 @@ dtlb_miss_20:
12461264

12471265
idtlbt pte,prot
12481266

1249-
ptl_unlock1 spc,t0,t1
1267+
ptl_unlock spc,t0,t1
12501268
rfir
12511269
nop
12521270

@@ -1255,6 +1273,7 @@ dtlb_check_alias_20:
12551273

12561274
idtlbt pte,prot
12571275

1276+
insert_nops NUM_PIPELINE_INSNS - 1
12581277
rfir
12591278
nop
12601279

@@ -1274,7 +1293,7 @@ nadtlb_miss_20:
12741293

12751294
idtlbt pte,prot
12761295

1277-
ptl_unlock1 spc,t0,t1
1296+
ptl_unlock spc,t0,t1
12781297
rfir
12791298
nop
12801299

@@ -1283,6 +1302,7 @@ nadtlb_check_alias_20:
12831302

12841303
idtlbt pte,prot
12851304

1305+
insert_nops NUM_PIPELINE_INSNS - 1
12861306
rfir
12871307
nop
12881308

@@ -1319,7 +1339,7 @@ itlb_miss_20w:
13191339

13201340
iitlbt pte,prot
13211341

1322-
ptl_unlock1 spc,t0,t1
1342+
ptl_unlock spc,t0,t1
13231343
rfir
13241344
nop
13251345

@@ -1343,7 +1363,7 @@ naitlb_miss_20w:
13431363

13441364
iitlbt pte,prot
13451365

1346-
ptl_unlock1 spc,t0,t1
1366+
ptl_unlock spc,t0,t1
13471367
rfir
13481368
nop
13491369

@@ -1352,6 +1372,7 @@ naitlb_check_alias_20w:
13521372

13531373
iitlbt pte,prot
13541374

1375+
insert_nops NUM_PIPELINE_INSNS - 1
13551376
rfir
13561377
nop
13571378

@@ -1377,7 +1398,7 @@ itlb_miss_11:
13771398

13781399
mtsp t1, %sr1 /* Restore sr1 */
13791400

1380-
ptl_unlock1 spc,t0,t1
1401+
ptl_unlock spc,t0,t1
13811402
rfir
13821403
nop
13831404

@@ -1401,7 +1422,7 @@ naitlb_miss_11:
14011422

14021423
mtsp t1, %sr1 /* Restore sr1 */
14031424

1404-
ptl_unlock1 spc,t0,t1
1425+
ptl_unlock spc,t0,t1
14051426
rfir
14061427
nop
14071428

@@ -1411,6 +1432,7 @@ naitlb_check_alias_11:
14111432
iitlba pte,(%sr0, va)
14121433
iitlbp prot,(%sr0, va)
14131434

1435+
insert_nops NUM_PIPELINE_INSNS - 1
14141436
rfir
14151437
nop
14161438

@@ -1431,7 +1453,7 @@ itlb_miss_20:
14311453

14321454
iitlbt pte,prot
14331455

1434-
ptl_unlock1 spc,t0,t1
1456+
ptl_unlock spc,t0,t1
14351457
rfir
14361458
nop
14371459

@@ -1451,7 +1473,7 @@ naitlb_miss_20:
14511473

14521474
iitlbt pte,prot
14531475

1454-
ptl_unlock1 spc,t0,t1
1476+
ptl_unlock spc,t0,t1
14551477
rfir
14561478
nop
14571479

@@ -1460,6 +1482,7 @@ naitlb_check_alias_20:
14601482

14611483
iitlbt pte,prot
14621484

1485+
insert_nops NUM_PIPELINE_INSNS - 1
14631486
rfir
14641487
nop
14651488

@@ -1481,7 +1504,7 @@ dbit_trap_20w:
14811504

14821505
idtlbt pte,prot
14831506

1484-
ptl_unlock0 spc,t0,t1
1507+
ptl_unlock spc,t0,t1
14851508
rfir
14861509
nop
14871510
#else
@@ -1507,7 +1530,7 @@ dbit_trap_11:
15071530

15081531
mtsp t1, %sr1 /* Restore sr1 */
15091532

1510-
ptl_unlock0 spc,t0,t1
1533+
ptl_unlock spc,t0,t1
15111534
rfir
15121535
nop
15131536

@@ -1527,7 +1550,7 @@ dbit_trap_20:
15271550

15281551
idtlbt pte,prot
15291552

1530-
ptl_unlock0 spc,t0,t1
1553+
ptl_unlock spc,t0,t1
15311554
rfir
15321555
nop
15331556
#endif

0 commit comments

Comments
 (0)