Skip to content

Commit 44a1280

Browse files
committed
Revert "powerpc/64: Avoid restore_math call if possible in syscall exit"
This reverts commit bc4f65e. As reported by Andreas, this commit is causing unrecoverable SLB misses in the system call exit path: Unrecoverable exception 4100 at c00000000000a1ec Oops: Unrecoverable exception, sig: 6 [#1] SMP NR_CPUS=2 PowerMac ... CPU: 0 PID: 18626 Comm: rm Not tainted 4.13.0-rc3 #1 task: c00000018335e080 task.stack: c000000139e50000 NIP: c00000000000a1ec LR: c00000000000a118 CTR: 0000000000000000 REGS: c000000139e53bb0 TRAP: 4100 Not tainted (4.13.0-rc3) MSR: 9000000000001030 <SF,HV,ME,IR,DR> CR: 24000044 XER: 20000000 SOFTE: 1 GPR00: 0000000000000000 c000000139e53e30 c000000000abb500 fffffffffffffffe GPR04: c0000001eb866298 0000000000000000 0000000000000000 c00000018335e080 GPR08: 900000000000d032 0000000000000000 0000000000000002 fffffffffffff001 GPR12: c000000139e50000 c00000000ffff000 00003fffa8c0dca0 00003fffa8c0dc88 GPR16: 0000000010000000 0000000000000001 00003fffa8c0eaa0 0000000000000000 GPR20: 00003fffa8c27528 00003fffa8c27b00 0000000000000000 0000000000000000 GPR24: 00003fffa8c0d918 00003ffff1b3efa0 00003fffa8c26d68 0000000000000000 GPR28: 00003fffa8c249e8 00003fffa8c263d0 00003fffa8c27550 00003ffff1b3ef10 NIP [c00000000000a1ec] system_call_exit+0xc0/0x21c LR [c00000000000a118] system_call+0x58/0x6c Call Trace: [c000000139e53e30] [c00000000000a118] system_call+0x58/0x6c (unreliable) Instruction dump: 64a51000 7c6300d0 f8a101a0 4bffff9c 3c000000 60000006 780007c6 64000000 60000000 7c004039 4082001c e8ed0170 <88070b78> 88c70b79 7c003214 2c200000 This is caused by us trying to load THREAD_LOAD_FP with MSR_RI=0, and taking an SLB miss on the thread struct. Reported-by: Andreas Schwab <schwab@linux-m68k.org> Diagnosed-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 3db40c3 commit 44a1280

File tree

2 files changed

+18
-46
lines changed

2 files changed

+18
-46
lines changed

arch/powerpc/kernel/entry_64.S

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,27 @@ system_call_exit:
223223
andi. r0,r9,(_TIF_SYSCALL_DOTRACE|_TIF_SINGLESTEP|_TIF_USER_WORK_MASK|_TIF_PERSYSCALL_MASK)
224224
bne- .Lsyscall_exit_work
225225

226-
/* If MSR_FP and MSR_VEC are set in user msr, then no need to restore */
227-
li r7,MSR_FP
226+
andi. r0,r8,MSR_FP
227+
beq 2f
228228
#ifdef CONFIG_ALTIVEC
229-
oris r7,r7,MSR_VEC@h
229+
andis. r0,r8,MSR_VEC@h
230+
bne 3f
230231
#endif
231-
and r0,r8,r7
232-
cmpd r0,r7
233-
bne .Lsyscall_restore_math
234-
.Lsyscall_restore_math_cont:
232+
2: addi r3,r1,STACK_FRAME_OVERHEAD
233+
#ifdef CONFIG_PPC_BOOK3S
234+
li r10,MSR_RI
235+
mtmsrd r10,1 /* Restore RI */
236+
#endif
237+
bl restore_math
238+
#ifdef CONFIG_PPC_BOOK3S
239+
li r11,0
240+
mtmsrd r11,1
241+
#endif
242+
ld r8,_MSR(r1)
243+
ld r3,RESULT(r1)
244+
li r11,-MAX_ERRNO
235245

236-
cmpld r3,r11
246+
3: cmpld r3,r11
237247
ld r5,_CCR(r1)
238248
bge- .Lsyscall_error
239249
.Lsyscall_error_cont:
@@ -267,40 +277,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
267277
std r5,_CCR(r1)
268278
b .Lsyscall_error_cont
269279

270-
.Lsyscall_restore_math:
271-
/*
272-
* Some initial tests from restore_math to avoid the heavyweight
273-
* C code entry and MSR manipulations.
274-
*/
275-
LOAD_REG_IMMEDIATE(r0, MSR_TS_MASK)
276-
and. r0,r0,r8
277-
bne 1f
278-
279-
ld r7,PACACURRENT(r13)
280-
lbz r0,THREAD+THREAD_LOAD_FP(r7)
281-
#ifdef CONFIG_ALTIVEC
282-
lbz r6,THREAD+THREAD_LOAD_VEC(r7)
283-
add r0,r0,r6
284-
#endif
285-
cmpdi r0,0
286-
beq .Lsyscall_restore_math_cont
287-
288-
1: addi r3,r1,STACK_FRAME_OVERHEAD
289-
#ifdef CONFIG_PPC_BOOK3S
290-
li r10,MSR_RI
291-
mtmsrd r10,1 /* Restore RI */
292-
#endif
293-
bl restore_math
294-
#ifdef CONFIG_PPC_BOOK3S
295-
li r11,0
296-
mtmsrd r11,1
297-
#endif
298-
/* Restore volatiles, reload MSR from updated one */
299-
ld r8,_MSR(r1)
300-
ld r3,RESULT(r1)
301-
li r11,-MAX_ERRNO
302-
b .Lsyscall_restore_math_cont
303-
304280
/* Traced system call support */
305281
.Lsyscall_dotrace:
306282
bl save_nvgprs

arch/powerpc/kernel/process.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,10 +511,6 @@ void restore_math(struct pt_regs *regs)
511511
{
512512
unsigned long msr;
513513

514-
/*
515-
* Syscall exit makes a similar initial check before branching
516-
* to restore_math. Keep them in synch.
517-
*/
518514
if (!msr_tm_active(regs->msr) &&
519515
!current->thread.load_fp && !loadvec(current->thread))
520516
return;

0 commit comments

Comments
 (0)