Skip to content

Commit 090b928

Browse files
mikeyozbenh
authored andcommitted
powerpc/tm: Clear MSR RI in non-recoverable TM code
When we treclaim and trecheckpoint there's an unavoidable period when r1 will not be a valid kernel stack pointer. This patch clears the MSR recoverable interrupt (RI) bit over these regions to indicate we have an invalid kernel stack pointer. For treclaim, the region over which we clear MSR RI is larger than required to avoid the need for an extra costly mtmsrd. Thanks to Paulus for suggesting this change. Signed-off-by: Michael Neuling <[email protected]> Signed-off-by: Benjamin Herrenschmidt <[email protected]>
1 parent 80aa0fb commit 090b928

File tree

1 file changed

+16
-2
lines changed
  • arch/powerpc/kernel

1 file changed

+16
-2
lines changed

arch/powerpc/kernel/tm.S

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,18 @@ _GLOBAL(tm_reclaim)
112112
std r3, STACK_PARAM(0)(r1)
113113
SAVE_NVGPRS(r1)
114114

115+
/* We need to setup MSR for VSX register save instructions. Here we
116+
* also clear the MSR RI since when we do the treclaim, we won't have a
117+
* valid kernel pointer for a while. We clear RI here as it avoids
118+
* adding another mtmsr closer to the treclaim. This makes the region
119+
* maked as non-recoverable wider than it needs to be but it saves on
120+
* inserting another mtmsrd later.
121+
*/
115122
mfmsr r14
116123
mr r15, r14
117124
ori r15, r15, MSR_FP
125+
li r16, MSR_RI
126+
andc r15, r15, r16
118127
oris r15, r15, MSR_VEC@h
119128
#ifdef CONFIG_VSX
120129
BEGIN_FTR_SECTION
@@ -349,9 +358,10 @@ restore_gprs:
349358
mtcr r5
350359
mtxer r6
351360

352-
/* MSR and flags: We don't change CRs, and we don't need to alter
353-
* MSR.
361+
/* Clear the MSR RI since we are about to change R1. EE is already off
354362
*/
363+
li r4, 0
364+
mtmsrd r4, 1
355365

356366
REST_4GPRS(0, r7) /* GPR0-3 */
357367
REST_GPR(4, r7) /* GPR4-6 */
@@ -377,6 +387,10 @@ restore_gprs:
377387
GET_PACA(r13)
378388
GET_SCRATCH0(r1)
379389

390+
/* R1 is restored, so we are recoverable again. EE is still off */
391+
li r4, MSR_RI
392+
mtmsrd r4, 1
393+
380394
REST_NVGPRS(r1)
381395

382396
addi r1, r1, TM_FRAME_SIZE

0 commit comments

Comments
 (0)