Skip to content

Commit

Permalink
MIPS: Save MSA extended context around signals
Browse files Browse the repository at this point in the history
It is desirable for signal handlers to be allowed to make use of MSA,
particularly if auto vectorisation is used when compiling a program.
The MSA context must therefore be saved & restored before & after
invoking the signal handler. Make use of the extended context structs
defined in the preceding patch to save MSA context after the sigframe
when appropriate.

[ralf@linux-mips.org: Fixed conflicts.]

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Matthew Fortune <matthew.fortune@imgtec.com>
Cc: Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Cc: Richard Weinberger <richard@nod.at>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: Manuel Lauss <manuel.lauss@gmail.com>
Cc: Maciej W. Rozycki <macro@codesourcery.com>
Patchwork: https://patchwork.linux-mips.org/patch/10796/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
  • Loading branch information
Paul Burton authored and Ralf Baechle committed Sep 3, 2015
1 parent f1fe2d2 commit bf82cb3
Show file tree
Hide file tree
Showing 3 changed files with 333 additions and 15 deletions.
118 changes: 118 additions & 0 deletions arch/mips/kernel/r4k_fpu.S
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,124 @@ LEAF(\name)
op_msa_wr write_msa_wr_w, ld_w
op_msa_wr write_msa_wr_d, ld_d

#endif /* CONFIG_CPU_HAS_MSA */

#ifdef CONFIG_CPU_HAS_MSA

.macro save_msa_upper wr, off, base
.set push
.set noat
#ifdef CONFIG_64BIT
copy_u_d \wr, 1
EX sd $1, \off(\base)
#elif defined(CONFIG_CPU_LITTLE_ENDIAN)
copy_u_w \wr, 2
EX sw $1, \off(\base)
copy_u_w \wr, 3
EX sw $1, (\off+4)(\base)
#else /* CONFIG_CPU_BIG_ENDIAN */
copy_u_w \wr, 2
EX sw $1, (\off+4)(\base)
copy_u_w \wr, 3
EX sw $1, \off(\base)
#endif
.set pop
.endm

LEAF(_save_msa_all_upper)
save_msa_upper 0, 0x00, a0
save_msa_upper 1, 0x08, a0
save_msa_upper 2, 0x10, a0
save_msa_upper 3, 0x18, a0
save_msa_upper 4, 0x20, a0
save_msa_upper 5, 0x28, a0
save_msa_upper 6, 0x30, a0
save_msa_upper 7, 0x38, a0
save_msa_upper 8, 0x40, a0
save_msa_upper 9, 0x48, a0
save_msa_upper 10, 0x50, a0
save_msa_upper 11, 0x58, a0
save_msa_upper 12, 0x60, a0
save_msa_upper 13, 0x68, a0
save_msa_upper 14, 0x70, a0
save_msa_upper 15, 0x78, a0
save_msa_upper 16, 0x80, a0
save_msa_upper 17, 0x88, a0
save_msa_upper 18, 0x90, a0
save_msa_upper 19, 0x98, a0
save_msa_upper 20, 0xa0, a0
save_msa_upper 21, 0xa8, a0
save_msa_upper 22, 0xb0, a0
save_msa_upper 23, 0xb8, a0
save_msa_upper 24, 0xc0, a0
save_msa_upper 25, 0xc8, a0
save_msa_upper 26, 0xd0, a0
save_msa_upper 27, 0xd8, a0
save_msa_upper 28, 0xe0, a0
save_msa_upper 29, 0xe8, a0
save_msa_upper 30, 0xf0, a0
save_msa_upper 31, 0xf8, a0
jr ra
li v0, 0
END(_save_msa_all_upper)

.macro restore_msa_upper wr, off, base
.set push
.set noat
#ifdef CONFIG_64BIT
EX ld $1, \off(\base)
insert_d \wr, 1
#elif defined(CONFIG_CPU_LITTLE_ENDIAN)
EX lw $1, \off(\base)
insert_w \wr, 2
EX lw $1, (\off+4)(\base)
insert_w \wr, 3
#else /* CONFIG_CPU_BIG_ENDIAN */
EX lw $1, (\off+4)(\base)
insert_w \wr, 2
EX lw $1, \off(\base)
insert_w \wr, 3
#endif
.set pop
.endm

LEAF(_restore_msa_all_upper)
restore_msa_upper 0, 0x00, a0
restore_msa_upper 1, 0x08, a0
restore_msa_upper 2, 0x10, a0
restore_msa_upper 3, 0x18, a0
restore_msa_upper 4, 0x20, a0
restore_msa_upper 5, 0x28, a0
restore_msa_upper 6, 0x30, a0
restore_msa_upper 7, 0x38, a0
restore_msa_upper 8, 0x40, a0
restore_msa_upper 9, 0x48, a0
restore_msa_upper 10, 0x50, a0
restore_msa_upper 11, 0x58, a0
restore_msa_upper 12, 0x60, a0
restore_msa_upper 13, 0x68, a0
restore_msa_upper 14, 0x70, a0
restore_msa_upper 15, 0x78, a0
restore_msa_upper 16, 0x80, a0
restore_msa_upper 17, 0x88, a0
restore_msa_upper 18, 0x90, a0
restore_msa_upper 19, 0x98, a0
restore_msa_upper 20, 0xa0, a0
restore_msa_upper 21, 0xa8, a0
restore_msa_upper 22, 0xb0, a0
restore_msa_upper 23, 0xb8, a0
restore_msa_upper 24, 0xc0, a0
restore_msa_upper 25, 0xc8, a0
restore_msa_upper 26, 0xd0, a0
restore_msa_upper 27, 0xd8, a0
restore_msa_upper 28, 0xe0, a0
restore_msa_upper 29, 0xe8, a0
restore_msa_upper 30, 0xf0, a0
restore_msa_upper 31, 0xf8, a0
jr ra
li v0, 0
END(_restore_msa_all_upper)

#endif /* CONFIG_CPU_HAS_MSA */

.set reorder
Expand Down
3 changes: 3 additions & 0 deletions arch/mips/kernel/signal-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ _save_fp_context(void __user *fpregs, void __user *csr);
extern asmlinkage int
_restore_fp_context(void __user *fpregs, void __user *csr);

extern asmlinkage int _save_msa_all_upper(void __user *buf);
extern asmlinkage int _restore_msa_all_upper(void __user *buf);

#endif /* __SIGNAL_COMMON_H */
Loading

0 comments on commit bf82cb3

Please sign in to comment.