Skip to content

Commit 112ca94

Browse files
committed
LoongArch: Save LBT before FPU in setup_sigcontext()
Now if preemption happens between protected_save_fpu_context() and protected_save_lbt_context(), FTOP context is lost. Because FTOP is saved by protected_save_lbt_context() but protected_save_fpu_context() disables TM before that. So save LBT before FPU in setup_sigcontext() to avoid this potential risk. Signed-off-by: Hanlu Li <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 63dbd8f commit 112ca94

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arch/loongarch/kernel/signal.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -677,18 +677,18 @@ static int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc,
677677
for (i = 1; i < 32; i++)
678678
err |= __put_user(regs->regs[i], &sc->sc_regs[i]);
679679

680+
#ifdef CONFIG_CPU_HAS_LBT
681+
if (extctx->lbt.addr)
682+
err |= protected_save_lbt_context(extctx);
683+
#endif
684+
680685
if (extctx->lasx.addr)
681686
err |= protected_save_lasx_context(extctx);
682687
else if (extctx->lsx.addr)
683688
err |= protected_save_lsx_context(extctx);
684689
else if (extctx->fpu.addr)
685690
err |= protected_save_fpu_context(extctx);
686691

687-
#ifdef CONFIG_CPU_HAS_LBT
688-
if (extctx->lbt.addr)
689-
err |= protected_save_lbt_context(extctx);
690-
#endif
691-
692692
/* Set the "end" magic */
693693
info = (struct sctx_info *)extctx->end.addr;
694694
err |= __put_user(0, &info->magic);

0 commit comments

Comments
 (0)