linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Huacai Chen <chenhc@lemote.com>
To: Huang Pei <huangpei@loongson.cn>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	Paul Ambrose <ambrosehua@gmail.com>,
	Li Xuefeng <lixuefeng@loongson.cn>,
	Yang Tiezhu <yangtiezhu@loongson.cn>,
	Gao Juxin <gaojuxin@loongson.cn>,
	Fuxin Zhang <zhangfx@lemote.com>,
	"open list:MIPS" <linux-mips@vger.kernel.org>
Subject: Re: [PATCH 1/3] MIPS: add missing MSACSR and upper MSA initialization
Date: Mon, 24 Aug 2020 15:19:36 +0800	[thread overview]
Message-ID: <CAAhV-H5Yu5V=NHosssCjT6B3a0+TdQNCJZ_1dxruNDwAftrsyA@mail.gmail.com> (raw)
In-Reply-To: <20200821072329.18006-1-huangpei@loongson.cn>

Hi, Pei,

On Fri, Aug 21, 2020 at 3:26 PM Huang Pei <huangpei@loongson.cn> wrote:
>
> own_fp_inatomic() does not restore/initialize MSACSR and upper MSA regs, 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.
>
> Signed-off-by: Huang Pei <huangpei@loongson.cn>
> ---
>  arch/mips/kernel/traps.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
> index 38aa07ccdbcc..99a8f1b7b522 100644
> --- a/arch/mips/kernel/traps.c
> +++ b/arch/mips/kernel/traps.c
> @@ -1287,6 +1287,8 @@ static int enable_restore_fp_context(int msa)
>                 err = own_fpu_inatomic(1);
>                 if (msa && !err) {
>                         enable_msa();
> +                       write_msa_csr(current->thread.fpu.msacsr);
> +                       init_msa_upper();
I think write_msa_csr(current->thread.fpu.msacsr) is needed here, but
I don't know whether init_msa_upper() is also needed. Maybe you should
investegate cc97ab235f3fe32401ca198cebe6f42642e9 ("MIPS: Simplify FP
context initialization") which removes init_msa_upper().

Huacai
>                         set_thread_flag(TIF_USEDMSA);
>                         set_thread_flag(TIF_MSA_CTX_LIVE);
>                 }
> --
> 2.17.1
>

  parent reply	other threads:[~2020-08-24  7:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21  7:23 [PATCH 1/3] MIPS: add missing MSACSR and upper MSA initialization Huang Pei
2020-08-21  7:23 ` [PATCH 2/3] MIPS: make userspace mapping young by default Huang Pei
2020-08-21  7:23 ` [PATCH 3/3] Revert "MIPS: Flush wrong invalid FTLB entry for huge page" Huang Pei
2020-08-21  9:26   ` Huacai Chen
2020-08-22  4:27     ` 答复: " 黄沛
2020-08-24  7:13       ` Huacai Chen
2020-08-24 10:19         ` Huang Pei
2020-08-24  7:19 ` Huacai Chen [this message]
2020-08-25  7:40   ` [PATCH 1/3] MIPS: add missing MSACSR and upper MSA initialization Huacai Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAhV-H5Yu5V=NHosssCjT6B3a0+TdQNCJZ_1dxruNDwAftrsyA@mail.gmail.com' \
    --to=chenhc@lemote.com \
    --cc=ambrosehua@gmail.com \
    --cc=gaojuxin@loongson.cn \
    --cc=huangpei@loongson.cn \
    --cc=linux-mips@vger.kernel.org \
    --cc=lixuefeng@loongson.cn \
    --cc=tsbogend@alpha.franken.de \
    --cc=yangtiezhu@loongson.cn \
    --cc=zhangfx@lemote.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).