Lines Matching +full:ext +full:- +full:regs

7  * Copyright (C) 1994 - 2000  Ralf Baechle
37 #include <asm/cpu-features.h>
42 #include "signal-common.h"
72 struct mips_abi *abi = current->thread.abi; in copy_fp_to_sigcontext()
73 uint64_t __user *fpregs = sc + abi->off_sc_fpregs; in copy_fp_to_sigcontext()
74 uint32_t __user *csr = sc + abi->off_sc_fpc_csr; in copy_fp_to_sigcontext()
81 __put_user(get_fpr64(&current->thread.fpu.fpr[i], 0), in copy_fp_to_sigcontext()
84 err |= __put_user(current->thread.fpu.fcr31, csr); in copy_fp_to_sigcontext()
91 struct mips_abi *abi = current->thread.abi; in copy_fp_from_sigcontext()
92 uint64_t __user *fpregs = sc + abi->off_sc_fpregs; in copy_fp_from_sigcontext()
93 uint32_t __user *csr = sc + abi->off_sc_fpc_csr; in copy_fp_from_sigcontext()
101 set_fpr64(&current->thread.fpu.fpr[i], 0, fpr_val); in copy_fp_from_sigcontext()
103 err |= __get_user(current->thread.fpu.fcr31, csr); in copy_fp_from_sigcontext()
127 struct mips_abi *abi = current->thread.abi; in save_hw_fp_context()
128 uint64_t __user *fpregs = sc + abi->off_sc_fpregs; in save_hw_fp_context()
129 uint32_t __user *csr = sc + abi->off_sc_fpc_csr; in save_hw_fp_context()
136 struct mips_abi *abi = current->thread.abi; in restore_hw_fp_context()
137 uint64_t __user *fpregs = sc + abi->off_sc_fpregs; in restore_hw_fp_context()
138 uint32_t __user *csr = sc + abi->off_sc_fpc_csr; in restore_hw_fp_context()
157 return &uc->uc_extcontext; in sc_to_extcontext()
187 err = __put_user(read_msa_csr(), &msa->csr); in save_msa_extcontext()
188 err |= _save_msa_all_upper(&msa->wr); in save_msa_extcontext()
194 err = __put_user(current->thread.fpu.msacsr, &msa->csr); in save_msa_extcontext()
197 val = get_fpr64(&current->thread.fpu.fpr[i], 1); in save_msa_extcontext()
198 err |= __put_user(val, &msa->wr[i]); in save_msa_extcontext()
202 err |= __put_user(MSA_EXTCONTEXT_MAGIC, &msa->ext.magic); in save_msa_extcontext()
203 err |= __put_user(sizeof(*msa), &msa->ext.size); in save_msa_extcontext()
205 return err ? -EFAULT : sizeof(*msa); in save_msa_extcontext()
216 return -EINVAL; in restore_msa_extcontext()
218 err = get_user(csr, &msa->csr); in restore_msa_extcontext()
235 err |= _restore_msa_all_upper(&msa->wr); in restore_msa_extcontext()
240 current->thread.fpu.msacsr = csr; in restore_msa_extcontext()
243 err |= __get_user(val, &msa->wr[i]); in restore_msa_extcontext()
244 set_fpr64(&current->thread.fpu.fpr[i], 1, val); in restore_msa_extcontext()
280 return -EFAULT; in save_extcontext()
282 sz += sizeof(((struct extcontext *)NULL)->magic); in save_extcontext()
288 struct extcontext ext; in restore_extcontext() local
292 err = __get_user(ext.magic, (unsigned int *)buf); in restore_extcontext()
296 if (ext.magic == END_EXTCONTEXT_MAGIC) in restore_extcontext()
299 err = __get_user(ext.size, (unsigned int *)(buf in restore_extcontext()
304 switch (ext.magic) { in restore_extcontext()
306 err = restore_msa_extcontext(buf, ext.size); in restore_extcontext()
310 err = -EINVAL; in restore_extcontext()
317 buf += ext.size; in restore_extcontext()
326 struct mips_abi *abi = current->thread.abi; in protected_save_fp_context()
327 uint64_t __user *fpregs = sc + abi->off_sc_fpregs; in protected_save_fp_context()
328 uint32_t __user *csr = sc + abi->off_sc_fpc_csr; in protected_save_fp_context()
329 uint32_t __user *used_math = sc + abi->off_sc_used_math; in protected_save_fp_context()
379 struct mips_abi *abi = current->thread.abi; in protected_restore_fp_context()
380 uint64_t __user *fpregs = sc + abi->off_sc_fpregs; in protected_restore_fp_context()
381 uint32_t __user *csr = sc + abi->off_sc_fpc_csr; in protected_restore_fp_context()
382 uint32_t __user *used_math = sc + abi->off_sc_used_math; in protected_restore_fp_context()
438 int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) in setup_sigcontext() argument
443 err |= __put_user(regs->cp0_epc, &sc->sc_pc); in setup_sigcontext()
445 err |= __put_user(0, &sc->sc_regs[0]); in setup_sigcontext()
447 err |= __put_user(regs->regs[i], &sc->sc_regs[i]); in setup_sigcontext()
450 err |= __put_user(regs->acx, &sc->sc_acx); in setup_sigcontext()
452 err |= __put_user(regs->hi, &sc->sc_mdhi); in setup_sigcontext()
453 err |= __put_user(regs->lo, &sc->sc_mdlo); in setup_sigcontext()
455 err |= __put_user(mfhi1(), &sc->sc_hi1); in setup_sigcontext()
456 err |= __put_user(mflo1(), &sc->sc_lo1); in setup_sigcontext()
457 err |= __put_user(mfhi2(), &sc->sc_hi2); in setup_sigcontext()
458 err |= __put_user(mflo2(), &sc->sc_lo2); in setup_sigcontext()
459 err |= __put_user(mfhi3(), &sc->sc_hi3); in setup_sigcontext()
460 err |= __put_user(mflo3(), &sc->sc_lo3); in setup_sigcontext()
461 err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp); in setup_sigcontext()
491 sz += sizeof(((struct extcontext *)NULL)->magic); in extcontext_max_size()
515 int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) in restore_sigcontext() argument
521 /* Always make any pending restarted system calls return -EINTR */ in restore_sigcontext()
522 current->restart_block.fn = do_no_restart_syscall; in restore_sigcontext()
524 err |= __get_user(regs->cp0_epc, &sc->sc_pc); in restore_sigcontext()
527 err |= __get_user(regs->acx, &sc->sc_acx); in restore_sigcontext()
529 err |= __get_user(regs->hi, &sc->sc_mdhi); in restore_sigcontext()
530 err |= __get_user(regs->lo, &sc->sc_mdlo); in restore_sigcontext()
532 err |= __get_user(treg, &sc->sc_hi1); mthi1(treg); in restore_sigcontext()
533 err |= __get_user(treg, &sc->sc_lo1); mtlo1(treg); in restore_sigcontext()
534 err |= __get_user(treg, &sc->sc_hi2); mthi2(treg); in restore_sigcontext()
535 err |= __get_user(treg, &sc->sc_lo2); mtlo2(treg); in restore_sigcontext()
536 err |= __get_user(treg, &sc->sc_hi3); mthi3(treg); in restore_sigcontext()
537 err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg); in restore_sigcontext()
538 err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK); in restore_sigcontext()
542 err |= __get_user(regs->regs[i], &sc->sc_regs[i]); in restore_sigcontext()
548 #define SIGMASK ~(cpu_icache_line_size()-1)
553 void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs, in get_sigframe() argument
562 sp = regs->regs[29]; in get_sigframe()
566 * Return an always-bogus address instead so we will die with SIGSEGV. in get_sigframe()
568 if (on_sig_stack(sp) && !likely(on_sig_stack(sp - frame_size))) in get_sigframe()
569 return (void __user __force *)(-1UL); in get_sigframe()
573 * above the user stack, 16-bytes before the next lowest in get_sigframe()
576 sp -= 32; in get_sigframe()
580 return (void __user *)((sp - frame_size) & SIGMASK); in get_sigframe()
606 return -EFAULT; in SYSCALL_DEFINE3()
607 err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler); in SYSCALL_DEFINE3()
608 err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags); in SYSCALL_DEFINE3()
609 err |= __get_user(mask, &act->sa_mask.sig[0]); in SYSCALL_DEFINE3()
611 return -EFAULT; in SYSCALL_DEFINE3()
620 return -EFAULT; in SYSCALL_DEFINE3()
621 err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags); in SYSCALL_DEFINE3()
622 err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler); in SYSCALL_DEFINE3()
623 err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig); in SYSCALL_DEFINE3()
624 err |= __put_user(0, &oact->sa_mask.sig[1]); in SYSCALL_DEFINE3()
625 err |= __put_user(0, &oact->sa_mask.sig[2]); in SYSCALL_DEFINE3()
626 err |= __put_user(0, &oact->sa_mask.sig[3]); in SYSCALL_DEFINE3()
628 return -EFAULT; in SYSCALL_DEFINE3()
639 struct pt_regs *regs; in sys_sigreturn() local
643 regs = current_pt_regs(); in sys_sigreturn()
644 frame = (struct sigframe __user *)regs->regs[29]; in sys_sigreturn()
647 if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked))) in sys_sigreturn()
652 sig = restore_sigcontext(regs, &frame->sf_sc); in sys_sigreturn()
665 : "r" (regs)); in sys_sigreturn()
676 struct pt_regs *regs; in sys_rt_sigreturn() local
680 regs = current_pt_regs(); in sys_rt_sigreturn()
681 frame = (struct rt_sigframe __user *)regs->regs[29]; in sys_rt_sigreturn()
684 if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set))) in sys_rt_sigreturn()
689 sig = restore_sigcontext(regs, &frame->rs_uc.uc_mcontext); in sys_rt_sigreturn()
695 if (restore_altstack(&frame->rs_uc.uc_stack)) in sys_rt_sigreturn()
705 : "r" (regs)); in sys_rt_sigreturn()
714 struct pt_regs *regs, sigset_t *set) in setup_frame() argument
719 frame = get_sigframe(ksig, regs, sizeof(*frame)); in setup_frame()
721 return -EFAULT; in setup_frame()
723 err |= setup_sigcontext(regs, &frame->sf_sc); in setup_frame()
724 err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set)); in setup_frame()
726 return -EFAULT; in setup_frame()
738 regs->regs[ 4] = ksig->sig; in setup_frame()
739 regs->regs[ 5] = 0; in setup_frame()
740 regs->regs[ 6] = (unsigned long) &frame->sf_sc; in setup_frame()
741 regs->regs[29] = (unsigned long) frame; in setup_frame()
742 regs->regs[31] = (unsigned long) sig_return; in setup_frame()
743 regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler; in setup_frame()
746 current->comm, current->pid, in setup_frame()
747 frame, regs->cp0_epc, regs->regs[31]); in setup_frame()
753 struct pt_regs *regs, sigset_t *set) in setup_rt_frame() argument
757 frame = get_sigframe(ksig, regs, sizeof(*frame)); in setup_rt_frame()
759 return -EFAULT; in setup_rt_frame()
762 if (copy_siginfo_to_user(&frame->rs_info, &ksig->info)) in setup_rt_frame()
763 return -EFAULT; in setup_rt_frame()
766 if (__put_user(0, &frame->rs_uc.uc_flags)) in setup_rt_frame()
767 return -EFAULT; in setup_rt_frame()
768 if (__put_user(NULL, &frame->rs_uc.uc_link)) in setup_rt_frame()
769 return -EFAULT; in setup_rt_frame()
770 if (__save_altstack(&frame->rs_uc.uc_stack, regs->regs[29])) in setup_rt_frame()
771 return -EFAULT; in setup_rt_frame()
772 if (setup_sigcontext(regs, &frame->rs_uc.uc_mcontext)) in setup_rt_frame()
773 return -EFAULT; in setup_rt_frame()
774 if (__copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set))) in setup_rt_frame()
775 return -EFAULT; in setup_rt_frame()
787 regs->regs[ 4] = ksig->sig; in setup_rt_frame()
788 regs->regs[ 5] = (unsigned long) &frame->rs_info; in setup_rt_frame()
789 regs->regs[ 6] = (unsigned long) &frame->rs_uc; in setup_rt_frame()
790 regs->regs[29] = (unsigned long) frame; in setup_rt_frame()
791 regs->regs[31] = (unsigned long) sig_return; in setup_rt_frame()
792 regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler; in setup_rt_frame()
795 current->comm, current->pid, in setup_rt_frame()
796 frame, regs->cp0_epc, regs->regs[31]); in setup_rt_frame()
815 static void handle_signal(struct ksignal *ksig, struct pt_regs *regs) in handle_signal() argument
819 struct mips_abi *abi = current->thread.abi; in handle_signal()
820 void *vdso = current->mm->context.vdso; in handle_signal()
828 dsemul_thread_rollback(regs); in handle_signal()
830 if (regs->regs[0]) { in handle_signal()
831 switch(regs->regs[2]) { in handle_signal()
834 regs->regs[2] = EINTR; in handle_signal()
837 if (!(ksig->ka.sa.sa_flags & SA_RESTART)) { in handle_signal()
838 regs->regs[2] = EINTR; in handle_signal()
843 regs->regs[7] = regs->regs[26]; in handle_signal()
844 regs->regs[2] = regs->regs[0]; in handle_signal()
845 regs->cp0_epc -= 4; in handle_signal()
848 regs->regs[0] = 0; /* Don't deal with this again. */ in handle_signal()
851 rseq_signal_deliver(ksig, regs); in handle_signal()
853 if (sig_uses_siginfo(&ksig->ka, abi)) in handle_signal()
854 ret = abi->setup_rt_frame(vdso + abi->vdso->off_rt_sigreturn, in handle_signal()
855 ksig, regs, oldset); in handle_signal()
857 ret = abi->setup_frame(vdso + abi->vdso->off_sigreturn, in handle_signal()
858 ksig, regs, oldset); in handle_signal()
863 static void do_signal(struct pt_regs *regs) in do_signal() argument
869 handle_signal(&ksig, regs); in do_signal()
873 if (regs->regs[0]) { in do_signal()
874 switch (regs->regs[2]) { in do_signal()
878 regs->regs[2] = regs->regs[0]; in do_signal()
879 regs->regs[7] = regs->regs[26]; in do_signal()
880 regs->cp0_epc -= 4; in do_signal()
884 regs->regs[2] = current->thread.abi->restart; in do_signal()
885 regs->regs[7] = regs->regs[26]; in do_signal()
886 regs->cp0_epc -= 4; in do_signal()
889 regs->regs[0] = 0; /* Don't deal with this again. */ in do_signal()
901 * - triggered by the TIF_WORK_MASK flags
903 asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused, in do_notify_resume() argument
911 uprobe_notify_resume(regs); in do_notify_resume()
915 do_signal(regs); in do_notify_resume()
918 resume_user_mode_work(regs); in do_notify_resume()
946 BUILD_BUG_ON((offsetof(struct sigframe, sf_extcontext) - in signal_setup()
948 (offsetof(struct rt_sigframe, rs_uc.uc_extcontext) - in signal_setup()