Skip to content

Commit 7a894c8

Browse files
committed
parisc: Fix CONFIG_TLB_PTLOCK to work with lightweight spinlock checks
For the TLB_PTLOCK checks we used an optimization to store the spc register into the spinlock to unlock it. This optimization works as long as the lightweight spinlock checks (CONFIG_LIGHTWEIGHT_SPINLOCK_CHECK) aren't enabled, because they really check if the lock word is zero or __ARCH_SPIN_LOCK_UNLOCKED_VAL and abort with a kernel crash ("Spinlock was trashed") otherwise. Drop that optimization to make it possible to activate both checks at the same time. Noticed-by: Sam James <sam@gentoo.org> Signed-off-by: Helge Deller <deller@gmx.de> Tested-by: Sam James <sam@gentoo.org> Cc: stable@vger.kernel.org # v6.4+ Fixes: 15e64ef ("parisc: Add lightweight spinlock checks")
1 parent 2ccdd1b commit 7a894c8

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

arch/parisc/kernel/entry.S

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <asm/traps.h>
2626
#include <asm/thread_info.h>
2727
#include <asm/alternative.h>
28+
#include <asm/spinlock_types.h>
2829

2930
#include <linux/linkage.h>
3031
#include <linux/pgtable.h>
@@ -406,7 +407,7 @@
406407
LDREG 0(\ptp),\pte
407408
bb,<,n \pte,_PAGE_PRESENT_BIT,3f
408409
b \fault
409-
stw \spc,0(\tmp)
410+
stw \tmp1,0(\tmp)
410411
99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
411412
#endif
412413
2: LDREG 0(\ptp),\pte
@@ -415,24 +416,22 @@
415416
.endm
416417

417418
/* Release page_table_lock without reloading lock address.
418-
Note that the values in the register spc are limited to
419-
NR_SPACE_IDS (262144). Thus, the stw instruction always
420-
stores a nonzero value even when register spc is 64 bits.
421419
We use an ordered store to ensure all prior accesses are
422420
performed prior to releasing the lock. */
423-
.macro ptl_unlock0 spc,tmp
421+
.macro ptl_unlock0 spc,tmp,tmp2
424422
#ifdef CONFIG_TLB_PTLOCK
425-
98: or,COND(=) %r0,\spc,%r0
426-
stw,ma \spc,0(\tmp)
423+
98: ldi __ARCH_SPIN_LOCK_UNLOCKED_VAL, \tmp2
424+
or,COND(=) %r0,\spc,%r0
425+
stw,ma \tmp2,0(\tmp)
427426
99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
428427
#endif
429428
.endm
430429

431430
/* Release page_table_lock. */
432-
.macro ptl_unlock1 spc,tmp
431+
.macro ptl_unlock1 spc,tmp,tmp2
433432
#ifdef CONFIG_TLB_PTLOCK
434433
98: get_ptl \tmp
435-
ptl_unlock0 \spc,\tmp
434+
ptl_unlock0 \spc,\tmp,\tmp2
436435
99: ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
437436
#endif
438437
.endm
@@ -1125,7 +1124,7 @@ dtlb_miss_20w:
11251124

11261125
idtlbt pte,prot
11271126

1128-
ptl_unlock1 spc,t0
1127+
ptl_unlock1 spc,t0,t1
11291128
rfir
11301129
nop
11311130

@@ -1151,7 +1150,7 @@ nadtlb_miss_20w:
11511150

11521151
idtlbt pte,prot
11531152

1154-
ptl_unlock1 spc,t0
1153+
ptl_unlock1 spc,t0,t1
11551154
rfir
11561155
nop
11571156

@@ -1185,7 +1184,7 @@ dtlb_miss_11:
11851184

11861185
mtsp t1, %sr1 /* Restore sr1 */
11871186

1188-
ptl_unlock1 spc,t0
1187+
ptl_unlock1 spc,t0,t1
11891188
rfir
11901189
nop
11911190

@@ -1218,7 +1217,7 @@ nadtlb_miss_11:
12181217

12191218
mtsp t1, %sr1 /* Restore sr1 */
12201219

1221-
ptl_unlock1 spc,t0
1220+
ptl_unlock1 spc,t0,t1
12221221
rfir
12231222
nop
12241223

@@ -1247,7 +1246,7 @@ dtlb_miss_20:
12471246

12481247
idtlbt pte,prot
12491248

1250-
ptl_unlock1 spc,t0
1249+
ptl_unlock1 spc,t0,t1
12511250
rfir
12521251
nop
12531252

@@ -1275,7 +1274,7 @@ nadtlb_miss_20:
12751274

12761275
idtlbt pte,prot
12771276

1278-
ptl_unlock1 spc,t0
1277+
ptl_unlock1 spc,t0,t1
12791278
rfir
12801279
nop
12811280

@@ -1320,7 +1319,7 @@ itlb_miss_20w:
13201319

13211320
iitlbt pte,prot
13221321

1323-
ptl_unlock1 spc,t0
1322+
ptl_unlock1 spc,t0,t1
13241323
rfir
13251324
nop
13261325

@@ -1344,7 +1343,7 @@ naitlb_miss_20w:
13441343

13451344
iitlbt pte,prot
13461345

1347-
ptl_unlock1 spc,t0
1346+
ptl_unlock1 spc,t0,t1
13481347
rfir
13491348
nop
13501349

@@ -1378,7 +1377,7 @@ itlb_miss_11:
13781377

13791378
mtsp t1, %sr1 /* Restore sr1 */
13801379

1381-
ptl_unlock1 spc,t0
1380+
ptl_unlock1 spc,t0,t1
13821381
rfir
13831382
nop
13841383

@@ -1402,7 +1401,7 @@ naitlb_miss_11:
14021401

14031402
mtsp t1, %sr1 /* Restore sr1 */
14041403

1405-
ptl_unlock1 spc,t0
1404+
ptl_unlock1 spc,t0,t1
14061405
rfir
14071406
nop
14081407

@@ -1432,7 +1431,7 @@ itlb_miss_20:
14321431

14331432
iitlbt pte,prot
14341433

1435-
ptl_unlock1 spc,t0
1434+
ptl_unlock1 spc,t0,t1
14361435
rfir
14371436
nop
14381437

@@ -1452,7 +1451,7 @@ naitlb_miss_20:
14521451

14531452
iitlbt pte,prot
14541453

1455-
ptl_unlock1 spc,t0
1454+
ptl_unlock1 spc,t0,t1
14561455
rfir
14571456
nop
14581457

@@ -1482,7 +1481,7 @@ dbit_trap_20w:
14821481

14831482
idtlbt pte,prot
14841483

1485-
ptl_unlock0 spc,t0
1484+
ptl_unlock0 spc,t0,t1
14861485
rfir
14871486
nop
14881487
#else
@@ -1508,7 +1507,7 @@ dbit_trap_11:
15081507

15091508
mtsp t1, %sr1 /* Restore sr1 */
15101509

1511-
ptl_unlock0 spc,t0
1510+
ptl_unlock0 spc,t0,t1
15121511
rfir
15131512
nop
15141513

@@ -1528,7 +1527,7 @@ dbit_trap_20:
15281527

15291528
idtlbt pte,prot
15301529

1531-
ptl_unlock0 spc,t0
1530+
ptl_unlock0 spc,t0,t1
15321531
rfir
15331532
nop
15341533
#endif

0 commit comments

Comments
 (0)