Skip to content

Commit bb06748

Browse files
mips-hptsbogend
authored andcommitted
MIPS: add missing MSACSR and upper MSA initialization
In cc97ab2 ("MIPS: Simplify FP context initialization), init_fp_ctx just initialize the fp/msa context, and own_fp_inatomic just restore FCSR and 64bit FP regs from it, but miss MSACSR and upper MSA regs for MSA, so MSACSR and MSA upper regs's value from previous task on current cpu can leak into current task and cause unpredictable behavior when MSA context not initialized. Fixes: cc97ab2 ("MIPS: Simplify FP context initialization") Signed-off-by: Huang Pei <[email protected]> Signed-off-by: Thomas Bogendoerfer <[email protected]>
1 parent a231995 commit bb06748

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arch/mips/kernel/traps.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,18 @@ static int enable_restore_fp_context(int msa)
12871287
err = own_fpu_inatomic(1);
12881288
if (msa && !err) {
12891289
enable_msa();
1290+
/*
1291+
* with MSA enabled, userspace can see MSACSR
1292+
* and MSA regs, but the values in them are from
1293+
* other task before current task, restore them
1294+
* from saved fp/msa context
1295+
*/
1296+
write_msa_csr(current->thread.fpu.msacsr);
1297+
/*
1298+
* own_fpu_inatomic(1) just restore low 64bit,
1299+
* fix the high 64bit
1300+
*/
1301+
init_msa_upper();
12901302
set_thread_flag(TIF_USEDMSA);
12911303
set_thread_flag(TIF_MSA_CTX_LIVE);
12921304
}

0 commit comments

Comments
 (0)