10 #include <linux/sched.h>
11 #include <linux/kernel.h>
12 #include <linux/signal.h>
13 #include <linux/errno.h>
14 #include <linux/wait.h>
15 #include <linux/ptrace.h>
18 #include <linux/tty.h>
19 #include <linux/binfmts.h>
21 #include <linux/bitops.h>
24 #include <asm/uaccess.h>
25 #include <asm/ptrace.h>
26 #include <asm/pgtable.h>
31 #include <asm/switch_to.h>
38 #define SIGINFO_EXTRA_V8PLUS_MAGIC 0x130e269
40 unsigned int g_upper[8];
41 unsigned int o_upper[8];
46 struct sparc_stackf32
ss;
58 struct sparc_stackf32
ss;
94 err |=
__put_user(from->si_overrun, &to->si_overrun);
98 err |=
__put_user(from->si_utime, &to->si_utime);
99 err |=
__put_user(from->si_stime, &to->si_stime);
100 err |=
__put_user(from->si_status, &to->si_status);
106 err |=
__put_user(from->si_trapno, &to->si_trapno);
107 err |=
__put_user((
unsigned long)from->si_addr, &to->si_addr);
110 err |=
__put_user(from->si_band, &to->si_band);
148 unsigned seta[_COMPAT_NSIG_WORDS];
161 (((
unsigned long) sf) & 3))
164 if (
get_user(pc, &sf->info.si_regs.pc) ||
171 if (test_thread_flag(TIF_32BIT)) {
180 err |=
__get_user(psr, &sf->info.si_regs.psr);
193 regs->tstate |= ((asi & 0xff
UL) << 24
UL);
199 regs->tstate |= psr_to_tstate_icc(psr);
202 pt_regs_clear_syscall(regs);
205 if (!err && fpu_save)
208 if (!err && rwin_save) {
212 err |=
__get_user(seta[0], &sf->info.si_mask);
214 (_COMPAT_NSIG_WORDS - 1) *
sizeof(
unsigned int));
218 case 4:
set.sig[3] = seta[6] + (((
long)seta[7]) << 32);
219 case 3:
set.sig[2] = seta[4] + (((
long)seta[5]) << 32);
220 case 2:
set.sig[1] = seta[2] + (((
long)seta[3]) << 32);
221 case 1:
set.sig[0] = seta[0] + (((
long)seta[1]) << 32);
233 unsigned int psr,
pc, npc, u_ss_sp;
238 compat_sigset_t seta;
251 (((
unsigned long) sf) & 3))
261 if (test_thread_flag(TIF_32BIT)) {
283 regs->tstate |= ((asi & 0xff
UL) << 24
UL);
289 regs->tstate |= psr_to_tstate_icc(psr);
292 pt_regs_clear_syscall(regs);
295 if (!err && fpu_save)
299 st.
ss_sp = compat_ptr(u_ss_sp);
313 if (!err && rwin_save) {
319 case 4:
set.sig[3] = seta.sig[6] + (((
long)seta.sig[7]) << 32);
320 case 3:
set.sig[2] = seta.sig[4] + (((
long)seta.sig[5]) << 32);
321 case 2:
set.sig[1] = seta.sig[2] + (((
long)seta.sig[3]) << 32);
322 case 1:
set.sig[0] = seta.sig[0] + (((
long)seta.sig[1]) << 32);
331 static int invalid_frame_pointer(
void __user *
fp,
int fplen)
333 if ((((
unsigned long) fp) & 7) || ((
unsigned long)fp) > 0x100000000ULL - fplen)
349 if (on_sig_stack(sp) && !
likely(on_sig_stack(sp - framesize)))
350 return (
void __user *) -1
L;
354 if (sas_ss_flags(sp) == 0)
368 return (
void __user *)
sp;
378 static void flush_signal_insns(
unsigned long address)
395 __asm__ __volatile__(
"rdpr %%pstate, %0" :
"=r" (pstate));
396 __asm__ __volatile__(
"wrpr %0, %1, %%pstate"
416 __asm__ __volatile__(
"flush %0 + %1"
425 __asm__ __volatile__(
"wrpr %0, 0x0, %%pstate" : :
"r" (pstate));
437 unsigned int seta[_COMPAT_NSIG_WORDS];
441 save_and_clear_fpu();
443 wsaved = get_thread_wsaved();
445 sigframe_size =
sizeof(*sf);
454 if (invalid_frame_pointer(sf, sigframe_size))
460 if (test_thread_flag(TIF_32BIT)) {
461 regs->tpc &= 0xffffffff;
462 regs->tnpc &= 0xffffffff;
467 psr = tstate_to_psr(regs->tstate);
471 for (i = 0; i < 16; i++)
475 for (i = 1; i < 16; i++)
491 tail +=
sizeof(*rwp);
494 set_thread_wsaved(0);
500 case 4: seta[7] = (oldset->
sig[3] >> 32);
501 seta[6] = oldset->
sig[3];
502 case 3: seta[5] = (oldset->
sig[2] >> 32);
503 seta[4] = oldset->
sig[2];
504 case 2: seta[3] = (oldset->
sig[1] >> 32);
505 seta[2] = oldset->
sig[1];
506 case 1: seta[1] = (oldset->
sig[0] >> 32);
507 seta[0] = oldset->
sig[0];
511 (_COMPAT_NSIG_WORDS - 1) *
sizeof(
unsigned int));
518 struct reg_window *
rp;
521 for (i = 0; i < 8; i++)
523 for (i = 0; i < 6; i++)
538 regs->tpc = (
unsigned long) ka->
sa.sa_handler;
539 regs->tnpc = (regs->tpc + 4);
540 if (test_thread_flag(TIF_32BIT)) {
541 regs->tpc &= 0xffffffff;
542 regs->tnpc &= 0xffffffff;
549 unsigned long address = ((
unsigned long)&(sf->
insns[0]));
557 flush_signal_insns(address);
571 unsigned long signr,
sigset_t *oldset,
579 compat_sigset_t seta;
583 save_and_clear_fpu();
585 wsaved = get_thread_wsaved();
587 sigframe_size =
sizeof(*sf);
596 if (invalid_frame_pointer(sf, sigframe_size))
602 if (test_thread_flag(TIF_32BIT)) {
603 regs->tpc &= 0xffffffff;
604 regs->tnpc &= 0xffffffff;
609 psr = tstate_to_psr(regs->tstate);
613 for (i = 0; i < 16; i++)
617 for (i = 1; i < 16; i++)
633 tail +=
sizeof(*rwp);
636 set_thread_wsaved(0);
650 case 4: seta.sig[7] = (oldset->
sig[3] >> 32);
651 seta.sig[6] = oldset->
sig[3];
652 case 3: seta.sig[5] = (oldset->
sig[2] >> 32);
653 seta.sig[4] = oldset->
sig[2];
654 case 2: seta.sig[3] = (oldset->
sig[1] >> 32);
655 seta.sig[2] = oldset->
sig[1];
656 case 1: seta.sig[1] = (oldset->
sig[0] >> 32);
657 seta.sig[0] = oldset->
sig[0];
666 struct reg_window *
rp;
669 for (i = 0; i < 8; i++)
671 for (i = 0; i < 6; i++)
686 regs->tpc = (
unsigned long) ka->
sa.sa_handler;
687 regs->tnpc = (regs->tpc + 4);
688 if (test_thread_flag(TIF_32BIT)) {
689 regs->tpc &= 0xffffffff;
690 regs->tnpc &= 0xffffffff;
697 unsigned long address = ((
unsigned long)&(sf->
insns[0]));
709 flush_signal_insns(address);
729 err = setup_rt_frame32(ka, regs, signr, oldset, info);
731 err = setup_frame32(ka, regs, signr, oldset);
739 static inline void syscall_restart32(
unsigned long orig_i0,
struct pt_regs *regs,
745 no_system_call_restart:
751 goto no_system_call_restart;
767 unsigned long orig_i0;
776 if (pt_regs_is_syscall(regs) &&
784 syscall_restart32(orig_i0, regs, &ka.
sa);
788 if (restart_syscall &&
796 pt_regs_clear_syscall(regs);
798 if (restart_syscall &&
803 pt_regs_clear_syscall(regs);
809 restore_saved_sigmask();
820 (
struct sigstack32 __user *)((
unsigned long)(u_ssptr));
822 (
struct sigstack32 __user *)((
unsigned long)(u_ossptr));
844 if (
current->sas_ss_sp && on_sig_stack(sp))
869 if (ussa && (
get_user(u_ss_sp, &uss32->ss_sp) ||
873 uss.
ss_sp = compat_ptr(u_ss_sp);
879 if (!ret && uossa && (
put_user(ptr_to_compat(uoss.
ss_sp), &uoss32->ss_sp) ||