[PATCH 0/1] Create kernel thread possibly with USEDFPU flag in mips

From: wangyangbo
Date: Mon Sep 13 2021 - 01:42:51 EST


Hi,
I want to use new syscall io_uring in mips,

Problem:
Running ./liburing/examples/io_uring-cp of liburing in mips kernel,
[ 132.538431] do_cpu invoked from kernel context![#1]:
[ 132.597936] CPU: 2 PID: 4154 Comm: iou-wrk-4153 Not tainted 5.14.0-rc1+ #5
[ 132.680373] Hardware name: THTF CQTL630 Series/THTF-LS3A4000-7A1000-1W-VB1-ML4A, BIOS V2.0.3 05/08/2020
[ 133.560951] Hi : 0000000000000002
[ 133.603728] Lo : 000000000c49ba60
[ 133.646499] epc : ffffffff80217670 _save_fp+0x10/0xa0
[ 133.709104] ra : ffffffff80cb9c44 __schedule+0x574/0xad8
[ 133.775875] Status: 5400cce2 KX SX UX KERNEL EXL
[ 133.832222] Cause : 1000002c (ExcCode 0b)
[ 133.880215] PrId : 0014c004 (ICT Loongson-3)
[ 135.382659] Call Trace:
[ 135.411868] [<ffffffff80217670>] _save_fp+0x10/0xa0
[ 135.470296] [<ffffffff80cb9c44>] __schedule+0x574/0xad8
[ 135.532893] [<ffffffff80cba22c>] schedule+0x84/0x138
[ 135.592361] [<ffffffff80cbf714>] schedule_timeout+0x1bc/0x3c0
[ 135.661219] [<ffffffff80510588>] io_wqe_worker+0x110/0x350
[ 135.726947] [<ffffffff80205a6c>] ret_from_kernel_thread+0x14/0x1c
[ 135.799981]
[ 135.817718] Code: 000c6940 05a10011 00000000 <f4810a00> f4830a20 f4850a40 f4870a60 f4890a80 f48b0aa0

Reason:
io-wq, fork worker threads from original user task(commit 3bfe6106693b6b4ba175ad1f929c4660b8f59ca8).
This causes copy_thread with TIF_USEDFPU flag in mips, meaning save_fp in switch_to, triggering do_cpu trap, however cpid 1(fpu) don't allow kernel to use.

Fix:
clear FPU flag in kernel IO_WORKER thread_copy branch.

wangyangbo (1):
MIPS: Fix fpu trap invoked by io-worker

arch/mips/kernel/process.c | 3 +++
1 file changed, 3 insertions(+)

--
2.20.1