linux_sysvec.c (fcdffc03f80577070fad20ff11fa3c9c5c09328e) linux_sysvec.c (4ab7403bbd76f466d482cd69035091c04e409c09)
1/*-
2 * Copyright (c) 1994-1996 Søren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 135 unchanged lines hidden (view full) ---

144 -90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
145 -100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
146 -110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
147 -116, -66, -6, -6, -6, -6, -6, -37, -38, -9,
148 -6, -6, -43, -42, -75,-125, -84, -95, -16, -74,
149 -72, -67, -71
150};
151
1/*-
2 * Copyright (c) 1994-1996 Søren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 135 unchanged lines hidden (view full) ---

144 -90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
145 -100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
146 -110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
147 -116, -66, -6, -6, -6, -6, -6, -37, -38, -9,
148 -6, -6, -43, -42, -75,-125, -84, -95, -16, -74,
149 -72, -67, -71
150};
151
152int bsd_to_linux_signal[LINUX_SIGTBLSZ] = {
153 LINUX_SIGHUP, LINUX_SIGINT, LINUX_SIGQUIT, LINUX_SIGILL,
154 LINUX_SIGTRAP, LINUX_SIGABRT, 0, LINUX_SIGFPE,
155 LINUX_SIGKILL, LINUX_SIGBUS, LINUX_SIGSEGV, LINUX_SIGSYS,
156 LINUX_SIGPIPE, LINUX_SIGALRM, LINUX_SIGTERM, LINUX_SIGURG,
157 LINUX_SIGSTOP, LINUX_SIGTSTP, LINUX_SIGCONT, LINUX_SIGCHLD,
158 LINUX_SIGTTIN, LINUX_SIGTTOU, LINUX_SIGIO, LINUX_SIGXCPU,
159 LINUX_SIGXFSZ, LINUX_SIGVTALRM, LINUX_SIGPROF, LINUX_SIGWINCH,
160 0, LINUX_SIGUSR1, LINUX_SIGUSR2
161};
162
163int linux_to_bsd_signal[LINUX_SIGTBLSZ] = {
164 SIGHUP, SIGINT, SIGQUIT, SIGILL,
165 SIGTRAP, SIGABRT, SIGBUS, SIGFPE,
166 SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2,
167 SIGPIPE, SIGALRM, SIGTERM, SIGBUS,
168 SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP,
169 SIGTTIN, SIGTTOU, SIGURG, SIGXCPU,
170 SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH,
171 SIGIO, SIGURG, SIGSYS
172};
173
174#define LINUX_T_UNKNOWN 255
175static int _bsd_to_linux_trapcode[] = {
176 LINUX_T_UNKNOWN, /* 0 */
177 6, /* 1 T_PRIVINFLT */
178 LINUX_T_UNKNOWN, /* 2 */
179 3, /* 3 T_BPTFLT */
180 LINUX_T_UNKNOWN, /* 4 */
181 LINUX_T_UNKNOWN, /* 5 */

--- 293 unchanged lines hidden (view full) ---

475 td->td_sigstk.ss_size - sizeof(struct l_rt_sigframe));
476 } else
477 fp = (struct l_rt_sigframe *)regs->tf_esp - 1;
478 mtx_unlock(&psp->ps_mtx);
479
480 /*
481 * Build the argument list for the signal handler.
482 */
152#define LINUX_T_UNKNOWN 255
153static int _bsd_to_linux_trapcode[] = {
154 LINUX_T_UNKNOWN, /* 0 */
155 6, /* 1 T_PRIVINFLT */
156 LINUX_T_UNKNOWN, /* 2 */
157 3, /* 3 T_BPTFLT */
158 LINUX_T_UNKNOWN, /* 4 */
159 LINUX_T_UNKNOWN, /* 5 */

--- 293 unchanged lines hidden (view full) ---

453 td->td_sigstk.ss_size - sizeof(struct l_rt_sigframe));
454 } else
455 fp = (struct l_rt_sigframe *)regs->tf_esp - 1;
456 mtx_unlock(&psp->ps_mtx);
457
458 /*
459 * Build the argument list for the signal handler.
460 */
483 sig = BSD_TO_LINUX_SIGNAL(sig);
461 sig = bsd_to_linux_signal(sig);
484
485 bzero(&frame, sizeof(frame));
486
487 frame.sf_handler = catcher;
488 frame.sf_sig = sig;
489 frame.sf_siginfo = &fp->sf_si;
490 frame.sf_ucontext = &fp->sf_sc;
491

--- 9 unchanged lines hidden (view full) ---

501 frame.sf_sc.uc_stack.ss_sp = td->td_sigstk.ss_sp;
502 frame.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size;
503 frame.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK)
504 ? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
505 PROC_UNLOCK(p);
506
507 bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
508
462
463 bzero(&frame, sizeof(frame));
464
465 frame.sf_handler = catcher;
466 frame.sf_sig = sig;
467 frame.sf_siginfo = &fp->sf_si;
468 frame.sf_ucontext = &fp->sf_sc;
469

--- 9 unchanged lines hidden (view full) ---

479 frame.sf_sc.uc_stack.ss_sp = td->td_sigstk.ss_sp;
480 frame.sf_sc.uc_stack.ss_size = td->td_sigstk.ss_size;
481 frame.sf_sc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK)
482 ? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
483 PROC_UNLOCK(p);
484
485 bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
486
509 frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__bits[0];
487 frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__mask;
510 frame.sf_sc.uc_mcontext.sc_gs = rgs();
511 frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs;
512 frame.sf_sc.uc_mcontext.sc_es = regs->tf_es;
513 frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds;
514 frame.sf_sc.uc_mcontext.sc_edi = regs->tf_edi;
515 frame.sf_sc.uc_mcontext.sc_esi = regs->tf_esi;
516 frame.sf_sc.uc_mcontext.sc_ebp = regs->tf_ebp;
517 frame.sf_sc.uc_mcontext.sc_ebx = regs->tf_ebx;

--- 62 unchanged lines hidden (view full) ---

580{
581 struct thread *td = curthread;
582 struct proc *p = td->td_proc;
583 struct sigacts *psp;
584 struct trapframe *regs;
585 struct l_sigframe *fp, frame;
586 l_sigset_t lmask;
587 int sig, code;
488 frame.sf_sc.uc_mcontext.sc_gs = rgs();
489 frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs;
490 frame.sf_sc.uc_mcontext.sc_es = regs->tf_es;
491 frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds;
492 frame.sf_sc.uc_mcontext.sc_edi = regs->tf_edi;
493 frame.sf_sc.uc_mcontext.sc_esi = regs->tf_esi;
494 frame.sf_sc.uc_mcontext.sc_ebp = regs->tf_ebp;
495 frame.sf_sc.uc_mcontext.sc_ebx = regs->tf_ebx;

--- 62 unchanged lines hidden (view full) ---

558{
559 struct thread *td = curthread;
560 struct proc *p = td->td_proc;
561 struct sigacts *psp;
562 struct trapframe *regs;
563 struct l_sigframe *fp, frame;
564 l_sigset_t lmask;
565 int sig, code;
588 int oonstack, i;
566 int oonstack;
589
590 PROC_LOCK_ASSERT(p, MA_OWNED);
591 psp = p->p_sigacts;
592 sig = ksi->ksi_signo;
593 code = ksi->ksi_code;
594 mtx_assert(&psp->ps_mtx, MA_OWNED);
595 if (SIGISMEMBER(psp->ps_siginfo, sig)) {
596 /* Signal handler installed with SA_SIGINFO. */

--- 19 unchanged lines hidden (view full) ---

616 } else
617 fp = (struct l_sigframe *)regs->tf_esp - 1;
618 mtx_unlock(&psp->ps_mtx);
619 PROC_UNLOCK(p);
620
621 /*
622 * Build the argument list for the signal handler.
623 */
567
568 PROC_LOCK_ASSERT(p, MA_OWNED);
569 psp = p->p_sigacts;
570 sig = ksi->ksi_signo;
571 code = ksi->ksi_code;
572 mtx_assert(&psp->ps_mtx, MA_OWNED);
573 if (SIGISMEMBER(psp->ps_siginfo, sig)) {
574 /* Signal handler installed with SA_SIGINFO. */

--- 19 unchanged lines hidden (view full) ---

594 } else
595 fp = (struct l_sigframe *)regs->tf_esp - 1;
596 mtx_unlock(&psp->ps_mtx);
597 PROC_UNLOCK(p);
598
599 /*
600 * Build the argument list for the signal handler.
601 */
624 sig = BSD_TO_LINUX_SIGNAL(sig);
602 sig = bsd_to_linux_signal(sig);
625
626 bzero(&frame, sizeof(frame));
627
628 frame.sf_handler = catcher;
629 frame.sf_sig = sig;
630
631 bsd_to_linux_sigset(mask, &lmask);
632
633 /*
634 * Build the signal context to be used by sigreturn.
635 */
603
604 bzero(&frame, sizeof(frame));
605
606 frame.sf_handler = catcher;
607 frame.sf_sig = sig;
608
609 bsd_to_linux_sigset(mask, &lmask);
610
611 /*
612 * Build the signal context to be used by sigreturn.
613 */
636 frame.sf_sc.sc_mask = lmask.__bits[0];
614 frame.sf_sc.sc_mask = lmask.__mask;
637 frame.sf_sc.sc_gs = rgs();
638 frame.sf_sc.sc_fs = regs->tf_fs;
639 frame.sf_sc.sc_es = regs->tf_es;
640 frame.sf_sc.sc_ds = regs->tf_ds;
641 frame.sf_sc.sc_edi = regs->tf_edi;
642 frame.sf_sc.sc_esi = regs->tf_esi;
643 frame.sf_sc.sc_ebp = regs->tf_ebp;
644 frame.sf_sc.sc_ebx = regs->tf_ebx;

--- 5 unchanged lines hidden (view full) ---

650 frame.sf_sc.sc_cs = regs->tf_cs;
651 frame.sf_sc.sc_eflags = regs->tf_eflags;
652 frame.sf_sc.sc_esp_at_signal = regs->tf_esp;
653 frame.sf_sc.sc_ss = regs->tf_ss;
654 frame.sf_sc.sc_err = regs->tf_err;
655 frame.sf_sc.sc_cr2 = (register_t)ksi->ksi_addr;
656 frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(ksi->ksi_trapno);
657
615 frame.sf_sc.sc_gs = rgs();
616 frame.sf_sc.sc_fs = regs->tf_fs;
617 frame.sf_sc.sc_es = regs->tf_es;
618 frame.sf_sc.sc_ds = regs->tf_ds;
619 frame.sf_sc.sc_edi = regs->tf_edi;
620 frame.sf_sc.sc_esi = regs->tf_esi;
621 frame.sf_sc.sc_ebp = regs->tf_ebp;
622 frame.sf_sc.sc_ebx = regs->tf_ebx;

--- 5 unchanged lines hidden (view full) ---

628 frame.sf_sc.sc_cs = regs->tf_cs;
629 frame.sf_sc.sc_eflags = regs->tf_eflags;
630 frame.sf_sc.sc_esp_at_signal = regs->tf_esp;
631 frame.sf_sc.sc_ss = regs->tf_ss;
632 frame.sf_sc.sc_err = regs->tf_err;
633 frame.sf_sc.sc_cr2 = (register_t)ksi->ksi_addr;
634 frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(ksi->ksi_trapno);
635
658 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
659 frame.sf_extramask[i] = lmask.__bits[i+1];
636 frame.sf_extramask[0] = lmask.__mask;
660
661 if (copyout(&frame, fp, sizeof(frame)) != 0) {
662 /*
663 * Process has trashed its stack; give it an illegal
664 * instruction to halt it in its tracks.
665 */
666 PROC_LOCK(p);
667 sigexit(td, SIGILL);

--- 26 unchanged lines hidden (view full) ---

694 */
695int
696linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
697{
698 struct l_sigframe frame;
699 struct trapframe *regs;
700 l_sigset_t lmask;
701 sigset_t bmask;
637
638 if (copyout(&frame, fp, sizeof(frame)) != 0) {
639 /*
640 * Process has trashed its stack; give it an illegal
641 * instruction to halt it in its tracks.
642 */
643 PROC_LOCK(p);
644 sigexit(td, SIGILL);

--- 26 unchanged lines hidden (view full) ---

671 */
672int
673linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
674{
675 struct l_sigframe frame;
676 struct trapframe *regs;
677 l_sigset_t lmask;
678 sigset_t bmask;
702 int eflags, i;
679 int eflags;
703 ksiginfo_t ksi;
704
705 regs = td->td_frame;
706
707#ifdef DEBUG
708 if (ldebug(sigreturn))
709 printf(ARGS(sigreturn, "%p"), (void *)args->sfp);
710#endif

--- 24 unchanged lines hidden (view full) ---

735 ksi.ksi_signo = SIGBUS;
736 ksi.ksi_code = BUS_OBJERR;
737 ksi.ksi_trapno = T_PROTFLT;
738 ksi.ksi_addr = (void *)regs->tf_eip;
739 trapsignal(td, &ksi);
740 return (EINVAL);
741 }
742
680 ksiginfo_t ksi;
681
682 regs = td->td_frame;
683
684#ifdef DEBUG
685 if (ldebug(sigreturn))
686 printf(ARGS(sigreturn, "%p"), (void *)args->sfp);
687#endif

--- 24 unchanged lines hidden (view full) ---

712 ksi.ksi_signo = SIGBUS;
713 ksi.ksi_code = BUS_OBJERR;
714 ksi.ksi_trapno = T_PROTFLT;
715 ksi.ksi_addr = (void *)regs->tf_eip;
716 trapsignal(td, &ksi);
717 return (EINVAL);
718 }
719
743 lmask.__bits[0] = frame.sf_sc.sc_mask;
744 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
745 lmask.__bits[i+1] = frame.sf_extramask[i];
720 lmask.__mask = frame.sf_sc.sc_mask;
746 linux_to_bsd_sigset(&lmask, &bmask);
747 kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0);
748
749 /*
750 * Restore signal context.
751 */
752 /* %gs was restored by the trampoline. */
753 regs->tf_fs = frame.sf_sc.sc_fs;

--- 222 unchanged lines hidden (view full) ---

976 *dst = "i386";
977 }
978}
979
980struct sysentvec linux_sysvec = {
981 .sv_size = LINUX_SYS_MAXSYSCALL,
982 .sv_table = linux_sysent,
983 .sv_mask = 0,
721 linux_to_bsd_sigset(&lmask, &bmask);
722 kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0);
723
724 /*
725 * Restore signal context.
726 */
727 /* %gs was restored by the trampoline. */
728 regs->tf_fs = frame.sf_sc.sc_fs;

--- 222 unchanged lines hidden (view full) ---

951 *dst = "i386";
952 }
953}
954
955struct sysentvec linux_sysvec = {
956 .sv_size = LINUX_SYS_MAXSYSCALL,
957 .sv_table = linux_sysent,
958 .sv_mask = 0,
984 .sv_sigsize = LINUX_SIGTBLSZ,
985 .sv_sigtbl = bsd_to_linux_signal,
959 .sv_sigsize = 0,
960 .sv_sigtbl = NULL,
986 .sv_errsize = ELAST + 1,
987 .sv_errtbl = bsd_to_linux_errno,
988 .sv_transtrap = translate_traps,
989 .sv_fixup = linux_fixup,
990 .sv_sendsig = linux_sendsig,
991 .sv_sigcode = &_binary_linux_locore_o_start,
992 .sv_szsigcode = &linux_szsigcode,
993 .sv_prepsyscall = NULL,

--- 21 unchanged lines hidden (view full) ---

1015 .sv_thread_detach = linux_thread_detach,
1016};
1017INIT_SYSENTVEC(aout_sysvec, &linux_sysvec);
1018
1019struct sysentvec elf_linux_sysvec = {
1020 .sv_size = LINUX_SYS_MAXSYSCALL,
1021 .sv_table = linux_sysent,
1022 .sv_mask = 0,
961 .sv_errsize = ELAST + 1,
962 .sv_errtbl = bsd_to_linux_errno,
963 .sv_transtrap = translate_traps,
964 .sv_fixup = linux_fixup,
965 .sv_sendsig = linux_sendsig,
966 .sv_sigcode = &_binary_linux_locore_o_start,
967 .sv_szsigcode = &linux_szsigcode,
968 .sv_prepsyscall = NULL,

--- 21 unchanged lines hidden (view full) ---

990 .sv_thread_detach = linux_thread_detach,
991};
992INIT_SYSENTVEC(aout_sysvec, &linux_sysvec);
993
994struct sysentvec elf_linux_sysvec = {
995 .sv_size = LINUX_SYS_MAXSYSCALL,
996 .sv_table = linux_sysent,
997 .sv_mask = 0,
1023 .sv_sigsize = LINUX_SIGTBLSZ,
1024 .sv_sigtbl = bsd_to_linux_signal,
998 .sv_sigsize = 0,
999 .sv_sigtbl = NULL,
1025 .sv_errsize = ELAST + 1,
1026 .sv_errtbl = bsd_to_linux_errno,
1027 .sv_transtrap = translate_traps,
1028 .sv_fixup = elf_linux_fixup,
1029 .sv_sendsig = linux_sendsig,
1030 .sv_sigcode = &_binary_linux_locore_o_start,
1031 .sv_szsigcode = &linux_szsigcode,
1032 .sv_prepsyscall = NULL,

--- 194 unchanged lines hidden ---
1000 .sv_errsize = ELAST + 1,
1001 .sv_errtbl = bsd_to_linux_errno,
1002 .sv_transtrap = translate_traps,
1003 .sv_fixup = elf_linux_fixup,
1004 .sv_sendsig = linux_sendsig,
1005 .sv_sigcode = &_binary_linux_locore_o_start,
1006 .sv_szsigcode = &linux_szsigcode,
1007 .sv_prepsyscall = NULL,

--- 194 unchanged lines hidden ---