1 // SPDX-License-Identifier: GPL-2.0 1 2 #include <linux/kernel.h> 3 #include <linux/types.h> 4 #include <linux/thread_info.h> 5 #include <linux/uaccess.h> 6 #include <linux/errno.h> 7 8 #include <asm/sigcontext.h> 9 #include <asm/fpumacro.h> 10 #include <asm/ptrace.h> 11 #include <asm/switch_to.h> 12 13 #include "sigutil.h" 14 15 int save_fpu_state(struct pt_regs *regs, __sig 16 { 17 unsigned long *fpregs = current_thread 18 unsigned long fprs; 19 int err = 0; 20 21 fprs = current_thread_info()->fpsaved[ 22 if (fprs & FPRS_DL) 23 err |= copy_to_user(&fpu->si_f 24 (sizeof(un 25 if (fprs & FPRS_DU) 26 err |= copy_to_user(&fpu->si_f 27 (sizeof(un 28 err |= __put_user(current_thread_info( 29 err |= __put_user(current_thread_info( 30 err |= __put_user(fprs, &fpu->si_fprs) 31 32 return err; 33 } 34 35 int restore_fpu_state(struct pt_regs *regs, __ 36 { 37 unsigned long *fpregs = current_thread 38 unsigned long fprs; 39 int err; 40 41 if (((unsigned long) fpu) & 7) 42 return -EFAULT; 43 44 err = get_user(fprs, &fpu->si_fprs); 45 fprs_write(0); 46 regs->tstate &= ~TSTATE_PEF; 47 if (fprs & FPRS_DL) 48 err |= copy_from_user(fpregs, 49 (sizeof(unsigne 50 if (fprs & FPRS_DU) 51 err |= copy_from_user(fpregs+1 52 (sizeof(unsigne 53 err |= __get_user(current_thread_info( 54 err |= __get_user(current_thread_info( 55 current_thread_info()->fpsaved[0] |= f 56 return err; 57 } 58 59 int save_rwin_state(int wsaved, __siginfo_rwin 60 { 61 int i, err = __put_user(wsaved, &rwin- 62 63 for (i = 0; i < wsaved; i++) { 64 struct reg_window *rp = &curre 65 unsigned long fp = current_thr 66 67 err |= copy_to_user(&rwin->reg 68 sizeof(str 69 err |= __put_user(fp, &rwin->r 70 } 71 return err; 72 } 73 74 int restore_rwin_state(__siginfo_rwin_t __user 75 { 76 struct thread_info *t = current_thread 77 int i, wsaved, err; 78 79 if (((unsigned long) rp) & 7) 80 return -EFAULT; 81 82 get_user(wsaved, &rp->wsaved); 83 if (wsaved > NSWINS) 84 return -EFAULT; 85 86 err = 0; 87 for (i = 0; i < wsaved; i++) { 88 err |= copy_from_user(&t->reg_ 89 &rp->reg 90 sizeof(s 91 err |= __get_user(t->rwbuf_stk 92 &rp->rwbuf_s 93 } 94 if (err) 95 return err; 96 97 set_thread_wsaved(wsaved); 98 synchronize_user_stack(); 99 if (get_thread_wsaved()) 100 return -EFAULT; 101 return 0; 102 } 103
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.