Skip to content

Commit 0fa2434

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: Fix octeon FP context switch handling
Commit 1a3d595 ("MIPS: Tidy up FPU context switching") removed FP context saving from the asm-written resume function in favour of reusing existing code to perform the same task. However it only removed the FP context saving code from the r4k_switch.S implementation of resume. Octeon uses its own implementation in octeon_switch.S, so remove FP context saving there too in order to prevent attempting to save context twice. That formerly led to an exception from the second save as follows because the FPU had already been disabled by the first save: do_cpu invoked from kernel context![#1]: CPU: 0 PID: 2 Comm: kthreadd Not tainted 4.3.0-rc2-dirty #2 task: 800000041f84a008 ti: 800000041f864000 task.ti: 800000041f864000 $ 0 : 0000000000000000 0000000010008ce1 0000000000100000 ffffffffbfffffff $ 4 : 800000041f84a008 800000041f84ac08 800000041f84c000 0000000000000004 $ 8 : 0000000000000001 0000000000000000 0000000000000000 0000000000000001 $12 : 0000000010008ce3 0000000000119c60 0000000000000036 800000041f864000 $16 : 800000041f84ac08 800000000792ce80 800000041f84a008 ffffffff81758b00 $20 : 0000000000000000 ffffffff8175ae50 0000000000000000 ffffffff8176c740 $24 : 0000000000000006 ffffffff81170300 $28 : 800000041f864000 800000041f867d90 0000000000000000 ffffffff815f3fa0 Hi : 0000000000fa8257 Lo : ffffffffe15cfc00 epc : ffffffff8112821c resume+0x9c/0x200 ra : ffffffff815f3fa0 __schedule+0x3f0/0x7d8 Status: 10008ce2 KX SX UX KERNEL EXL Cause : 1080002c (ExcCode 0b) PrId : 000d0601 (Cavium Octeon+) Modules linked in: Process kthreadd (pid: 2, threadinfo=800000041f864000, task=800000041f84a008, tls=0000000000000000) Stack : ffffffff81604218 ffffffff815f7e08 800000041f84a008 ffffffff811681b0 800000041f84a008 ffffffff817e9878 0000000000000000 ffffffff81770000 ffffffff81768340 ffffffff81161398 0000000000000001 0000000000000000 0000000000000000 ffffffff815f4424 0000000000000000 ffffffff81161d68 ffffffff81161be8 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 ffffffff8111e16c 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 0000000000000000 ... Call Trace: [<ffffffff8112821c>] resume+0x9c/0x200 [<ffffffff815f3fa0>] __schedule+0x3f0/0x7d8 [<ffffffff815f4424>] schedule+0x34/0x98 [<ffffffff81161d68>] kthreadd+0x180/0x198 [<ffffffff8111e16c>] ret_from_kernel_thread+0x14/0x1c Tested using cavium_octeon_defconfig on an EdgeRouter Lite. Fixes: 1a3d595 ("MIPS: Tidy up FPU context switching") Reported-by: Aaro Koskinen <aaro.koskinen@nokia.com> Signed-off-by: Paul Burton <paul.burton@imgtec.com> Cc: linux-mips@linux-mips.org Cc: Aleksey Makarov <aleksey.makarov@auriga.com> Cc: linux-kernel@vger.kernel.org Cc: Chandrakala Chavva <cchavva@caviumnetworks.com> Cc: David Daney <david.daney@cavium.com> Cc: Leonid Rosenboim <lrosenboim@caviumnetworks.com> Patchwork: https://patchwork.linux-mips.org/patch/11166/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent 0c5d187 commit 0fa2434

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

arch/mips/kernel/octeon_switch.S

+1-25
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
.set pop
1919
/*
2020
* task_struct *resume(task_struct *prev, task_struct *next,
21-
* struct thread_info *next_ti, int usedfpu)
21+
* struct thread_info *next_ti)
2222
*/
2323
.align 7
2424
LEAF(resume)
@@ -28,30 +28,6 @@
2828
cpu_save_nonscratch a0
2929
LONG_S ra, THREAD_REG31(a0)
3030

31-
/*
32-
* check if we need to save FPU registers
33-
*/
34-
.set push
35-
.set noreorder
36-
beqz a3, 1f
37-
PTR_L t3, TASK_THREAD_INFO(a0)
38-
.set pop
39-
40-
/*
41-
* clear saved user stack CU1 bit
42-
*/
43-
LONG_L t0, ST_OFF(t3)
44-
li t1, ~ST0_CU1
45-
and t0, t0, t1
46-
LONG_S t0, ST_OFF(t3)
47-
48-
.set push
49-
.set arch=mips64r2
50-
fpu_save_double a0 t0 t1 # c0_status passed in t0
51-
# clobbers t1
52-
.set pop
53-
1:
54-
5531
#if CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0
5632
/* Check if we need to store CVMSEG state */
5733
dmfc0 t0, $11,7 /* CvmMemCtl */

0 commit comments

Comments
 (0)