Patch "MIPS: add missing MSACSR and upper MSA initialization" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    MIPS: add missing MSACSR and upper MSA initialization

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mips-add-missing-msacsr-and-upper-msa-initialization.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 362a3da876cee4d9b8ef0206eb4412297dbee21f
Author: Huang Pei <huangpei@xxxxxxxxxxx>
Date:   Tue Sep 1 14:53:09 2020 +0800

    MIPS: add missing MSACSR and upper MSA initialization
    
    [ Upstream commit bb06748207cfb1502d11b90325eba7f8c44c9f02 ]
    
    In cc97ab235f3f ("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: cc97ab235f3f ("MIPS: Simplify FP context initialization")
    Signed-off-by: Huang Pei <huangpei@xxxxxxxxxxx>
    Signed-off-by: Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 6a25364600266..8282d0feb0b21 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -1240,6 +1240,18 @@ static int enable_restore_fp_context(int msa)
 		err = own_fpu_inatomic(1);
 		if (msa && !err) {
 			enable_msa();
+			/*
+			 * with MSA enabled, userspace can see MSACSR
+			 * and MSA regs, but the values in them are from
+			 * other task before current task, restore them
+			 * from saved fp/msa context
+			 */
+			write_msa_csr(current->thread.fpu.msacsr);
+			/*
+			 * own_fpu_inatomic(1) just restore low 64bit,
+			 * fix the high 64bit
+			 */
+			init_msa_upper();
 			set_thread_flag(TIF_USEDMSA);
 			set_thread_flag(TIF_MSA_CTX_LIVE);
 		}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux