Author: kib
Date: Fri Jul 21 18:06:57 2017
New Revision: 321343
URL: https://svnweb.freebsd.org/changeset/base/321343

Log:
  MFC r319873:
  Move struct syscall_args syscall arguments parameters container into
  struct thread.

Modified:
  stable/11/sys/amd64/amd64/trap.c
  stable/11/sys/amd64/cloudabi32/cloudabi32_sysvec.c
  stable/11/sys/amd64/cloudabi64/cloudabi64_sysvec.c
  stable/11/sys/amd64/ia32/ia32_syscall.c
  stable/11/sys/amd64/linux/linux_sysvec.c
  stable/11/sys/amd64/linux32/linux32_sysvec.c
  stable/11/sys/arm/arm/syscall.c
  stable/11/sys/arm/cloudabi32/cloudabi32_sysvec.c
  stable/11/sys/arm64/arm64/trap.c
  stable/11/sys/arm64/cloudabi64/cloudabi64_sysvec.c
  stable/11/sys/compat/ia32/ia32_util.h
  stable/11/sys/compat/linux/linux_fork.c
  stable/11/sys/i386/cloudabi32/cloudabi32_sysvec.c
  stable/11/sys/i386/i386/trap.c
  stable/11/sys/i386/linux/linux_sysvec.c
  stable/11/sys/kern/init_main.c
  stable/11/sys/kern/kern_fork.c
  stable/11/sys/kern/kern_kthread.c
  stable/11/sys/kern/kern_thr.c
  stable/11/sys/kern/subr_syscall.c
  stable/11/sys/kern/sys_process.c
  stable/11/sys/mips/mips/trap.c
  stable/11/sys/powerpc/powerpc/trap.c
  stable/11/sys/riscv/riscv/trap.c
  stable/11/sys/sparc64/sparc64/trap.c
  stable/11/sys/sys/proc.h
  stable/11/sys/sys/sysent.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/amd64/trap.c
==============================================================================
--- stable/11/sys/amd64/amd64/trap.c    Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/amd64/amd64/trap.c    Fri Jul 21 18:06:57 2017        
(r321343)
@@ -829,16 +829,18 @@ dblfault_handler(struct trapframe *frame)
 }
 
 int
-cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cpu_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        struct trapframe *frame;
        register_t *argp;
+       struct syscall_args *sa;
        caddr_t params;
        int reg, regcnt, error;
 
        p = td->td_proc;
        frame = td->td_frame;
+       sa = &td->td_sa;
        reg = 0;
        regcnt = 6;
 
@@ -889,7 +891,6 @@ cpu_fetch_syscall_args(struct thread *td, struct sysca
 void
 amd64_syscall(struct thread *td, int traced)
 {
-       struct syscall_args sa;
        int error;
        ksiginfo_t ksi;
 
@@ -899,7 +900,7 @@ amd64_syscall(struct thread *td, int traced)
                /* NOT REACHED */
        }
 #endif
-       error = syscallenter(td, &sa);
+       error = syscallenter(td);
 
        /*
         * Traced syscall.
@@ -915,15 +916,16 @@ amd64_syscall(struct thread *td, int traced)
 
        KASSERT(PCB_USER_FPU(td->td_pcb),
            ("System call %s returning with kernel FPU ctx leaked",
-            syscallname(td->td_proc, sa.code)));
+            syscallname(td->td_proc, td->td_sa.code)));
        KASSERT(td->td_pcb->pcb_save == get_pcb_user_save_td(td),
            ("System call %s returning with mangled pcb_save",
-            syscallname(td->td_proc, sa.code)));
+            syscallname(td->td_proc, td->td_sa.code)));
        KASSERT(td->td_md.md_invl_gen.gen == 0,
            ("System call %s returning with leaked invl_gen %lu",
-           syscallname(td->td_proc, sa.code), td->td_md.md_invl_gen.gen));
+           syscallname(td->td_proc, td->td_sa.code),
+           td->td_md.md_invl_gen.gen));
 
-       syscallret(td, error, &sa);
+       syscallret(td, error);
 
        /*
         * If the user-supplied value of %rip is not a canonical

Modified: stable/11/sys/amd64/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- stable/11/sys/amd64/cloudabi32/cloudabi32_sysvec.c  Fri Jul 21 17:59:54 
2017        (r321342)
+++ stable/11/sys/amd64/cloudabi32/cloudabi32_sysvec.c  Fri Jul 21 18:06:57 
2017        (r321343)
@@ -90,10 +90,14 @@ cloudabi32_proc_setregs(struct thread *td, struct imag
 }
 
 static int
-cloudabi32_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cloudabi32_fetch_syscall_args(struct thread *td)
 {
-       struct trapframe *frame = td->td_frame;
+       struct trapframe *frame;
+       struct syscall_args *sa;
        int error;
+
+       frame = td->td_frame;
+       sa = &td->td_sa;
 
        /* Obtain system call number. */
        sa->code = frame->tf_rax;

Modified: stable/11/sys/amd64/cloudabi64/cloudabi64_sysvec.c
==============================================================================
--- stable/11/sys/amd64/cloudabi64/cloudabi64_sysvec.c  Fri Jul 21 17:59:54 
2017        (r321342)
+++ stable/11/sys/amd64/cloudabi64/cloudabi64_sysvec.c  Fri Jul 21 18:06:57 
2017        (r321343)
@@ -87,9 +87,13 @@ cloudabi64_proc_setregs(struct thread *td, struct imag
 }
 
 static int
-cloudabi64_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cloudabi64_fetch_syscall_args(struct thread *td)
 {
-       struct trapframe *frame = td->td_frame;
+       struct trapframe *frame;
+       struct syscall_args *sa;
+
+       frame = td->td_frame;
+       sa = &td->td_sa;
 
        /* Obtain system call number. */
        sa->code = frame->tf_rax;

Modified: stable/11/sys/amd64/ia32/ia32_syscall.c
==============================================================================
--- stable/11/sys/amd64/ia32/ia32_syscall.c     Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/amd64/ia32/ia32_syscall.c     Fri Jul 21 18:06:57 2017        
(r321343)
@@ -105,16 +105,18 @@ ia32_set_syscall_retval(struct thread *td, int error)
 }
 
 int
-ia32_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+ia32_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        struct trapframe *frame;
+       struct syscall_args *sa;
        caddr_t params;
        u_int32_t args[8], tmp;
        int error, i;
 
        p = td->td_proc;
        frame = td->td_frame;
+       sa = &td->td_sa;
 
        params = (caddr_t)frame->tf_rsp + sizeof(u_int32_t);
        sa->code = frame->tf_rax;
@@ -175,7 +177,6 @@ void
 ia32_syscall(struct trapframe *frame)
 {
        struct thread *td;
-       struct syscall_args sa;
        register_t orig_tf_rflags;
        int error;
        ksiginfo_t ksi;
@@ -184,7 +185,7 @@ ia32_syscall(struct trapframe *frame)
        td = curthread;
        td->td_frame = frame;
 
-       error = syscallenter(td, &sa);
+       error = syscallenter(td);
 
        /*
         * Traced syscall.
@@ -198,7 +199,7 @@ ia32_syscall(struct trapframe *frame)
                trapsignal(td, &ksi);
        }
 
-       syscallret(td, error, &sa);
+       syscallret(td, error);
 }
 
 static void

Modified: stable/11/sys/amd64/linux/linux_sysvec.c
==============================================================================
--- stable/11/sys/amd64/linux/linux_sysvec.c    Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/amd64/linux/linux_sysvec.c    Fri Jul 21 18:06:57 2017        
(r321343)
@@ -126,7 +126,7 @@ static boolean_t linux_trans_osrel(const Elf_Note *not
 static void    linux_vdso_install(void *param);
 static void    linux_vdso_deinstall(void *param);
 static void    linux_set_syscall_retval(struct thread *td, int error);
-static int     linux_fetch_syscall_args(struct thread *td, struct syscall_args 
*sa);
+static int     linux_fetch_syscall_args(struct thread *td);
 static void    linux_exec_setregs(struct thread *td, struct image_params *imgp,
                    u_long stack);
 static int     linux_vsyscall(struct thread *td);
@@ -217,13 +217,15 @@ translate_traps(int signal, int trap_code)
 }
 
 static int
-linux_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+linux_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        struct trapframe *frame;
+       struct syscall_args *sa;
 
        p = td->td_proc;
        frame = td->td_frame;
+       sa = &td->td_sa;
 
        sa->args[0] = frame->tf_rdi;
        sa->args[1] = frame->tf_rsi;

Modified: stable/11/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- stable/11/sys/amd64/linux32/linux32_sysvec.c        Fri Jul 21 17:59:54 
2017        (r321342)
+++ stable/11/sys/amd64/linux32/linux32_sysvec.c        Fri Jul 21 18:06:57 
2017        (r321343)
@@ -725,13 +725,15 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_
 }
 
 static int
-linux32_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+linux32_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        struct trapframe *frame;
+       struct syscall_args *sa;
 
        p = td->td_proc;
        frame = td->td_frame;
+       sa = &td->td_sa;
 
        sa->args[0] = frame->tf_rbx;
        sa->args[1] = frame->tf_rcx;

Modified: stable/11/sys/arm/arm/syscall.c
==============================================================================
--- stable/11/sys/arm/arm/syscall.c     Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/arm/arm/syscall.c     Fri Jul 21 18:06:57 2017        
(r321343)
@@ -99,12 +99,14 @@ __FBSDID("$FreeBSD$");
 void swi_handler(struct trapframe *);
 
 int
-cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cpu_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        register_t *ap;
+       struct syscall_args *sa;
        int error;
 
+       sa = &td->td_sa;
        sa->code = td->td_frame->tf_r7;
        ap = &td->td_frame->tf_r0;
        if (sa->code == SYS_syscall) {
@@ -141,15 +143,14 @@ cpu_fetch_syscall_args(struct thread *td, struct sysca
 static void
 syscall(struct thread *td, struct trapframe *frame)
 {
-       struct syscall_args sa;
        int error;
 
-       sa.nap = 4;
+       td->td_sa.nap = 4;
 
-       error = syscallenter(td, &sa);
+       error = syscallenter(td);
        KASSERT(error != 0 || td->td_ar == NULL,
            ("returning from syscall with td_ar set!"));
-       syscallret(td, error, &sa);
+       syscallret(td, error);
 }
 
 void

Modified: stable/11/sys/arm/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- stable/11/sys/arm/cloudabi32/cloudabi32_sysvec.c    Fri Jul 21 17:59:54 
2017        (r321342)
+++ stable/11/sys/arm/cloudabi32/cloudabi32_sysvec.c    Fri Jul 21 18:06:57 
2017        (r321343)
@@ -67,10 +67,14 @@ cloudabi32_proc_setregs(struct thread *td, struct imag
 }
 
 static int
-cloudabi32_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cloudabi32_fetch_syscall_args(struct thread *td)
 {
-       struct trapframe *frame = td->td_frame;
+       struct trapframe *frame;
+       struct syscall_args *sa;
        int error;
+
+       frame = td->td_frame;
+       sa = &td->td_sa;
 
        /* Obtain system call number. */
        sa->code = frame->tf_r12;

Modified: stable/11/sys/arm64/arm64/trap.c
==============================================================================
--- stable/11/sys/arm64/arm64/trap.c    Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/arm64/arm64/trap.c    Fri Jul 21 18:06:57 2017        
(r321343)
@@ -92,15 +92,17 @@ call_trapsignal(struct thread *td, int sig, int code, 
 }
 
 int
-cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cpu_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        register_t *ap;
+       struct syscall_args *sa;
        int nap;
 
        nap = 8;
        p = td->td_proc;
        ap = td->td_frame->tf_x;
+       sa = &td->td_sa;
 
        sa->code = td->td_frame->tf_x[8];
 
@@ -132,12 +134,11 @@ cpu_fetch_syscall_args(struct thread *td, struct sysca
 static void
 svc_handler(struct thread *td, struct trapframe *frame)
 {
-       struct syscall_args sa;
        int error;
 
        if ((frame->tf_esr & ESR_ELx_ISS_MASK) == 0) {
-               error = syscallenter(td, &sa);
-               syscallret(td, error, &sa);
+               error = syscallenter(td);
+               syscallret(td, error);
        } else {
                call_trapsignal(td, SIGILL, ILL_ILLOPN, (void *)frame->tf_elr);
                userret(td, frame);

Modified: stable/11/sys/arm64/cloudabi64/cloudabi64_sysvec.c
==============================================================================
--- stable/11/sys/arm64/cloudabi64/cloudabi64_sysvec.c  Fri Jul 21 17:59:54 
2017        (r321342)
+++ stable/11/sys/arm64/cloudabi64/cloudabi64_sysvec.c  Fri Jul 21 18:06:57 
2017        (r321343)
@@ -67,10 +67,14 @@ cloudabi64_proc_setregs(struct thread *td, struct imag
 }
 
 static int
-cloudabi64_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cloudabi64_fetch_syscall_args(struct thread *td)
 {
-       struct trapframe *frame = td->td_frame;
+       struct trapframe *frame;
+       struct syscall_args *sa;
        int i;
+
+       frame = td->td_frame;
+       sa = &td->td_sa;
 
        /* Obtain system call number. */
        sa->code = frame->tf_x[8];

Modified: stable/11/sys/compat/ia32/ia32_util.h
==============================================================================
--- stable/11/sys/compat/ia32/ia32_util.h       Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/compat/ia32/ia32_util.h       Fri Jul 21 18:06:57 2017        
(r321343)
@@ -50,7 +50,7 @@
 #define        IA32_MAXVMEM    0                       /* Unlimited */
 
 struct syscall_args;
-int ia32_fetch_syscall_args(struct thread *td, struct syscall_args *sa);
+int ia32_fetch_syscall_args(struct thread *td);
 void ia32_set_syscall_retval(struct thread *, int);
 void ia32_fixlimit(struct rlimit *rl, int which);
 

Modified: stable/11/sys/compat/linux/linux_fork.c
==============================================================================
--- stable/11/sys/compat/linux/linux_fork.c     Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/compat/linux/linux_fork.c     Fri Jul 21 18:06:57 2017        
(r321343)
@@ -306,6 +306,7 @@ linux_clone_thread(struct thread *td, struct linux_clo
            __rangeof(struct thread, td_startzero, td_endzero));
        bcopy(&td->td_startcopy, &newtd->td_startcopy,
            __rangeof(struct thread, td_startcopy, td_endcopy));
+       newtd->td_sa = td->td_sa;
 
        newtd->td_proc = p;
        thread_cow_get(newtd, td);

Modified: stable/11/sys/i386/cloudabi32/cloudabi32_sysvec.c
==============================================================================
--- stable/11/sys/i386/cloudabi32/cloudabi32_sysvec.c   Fri Jul 21 17:59:54 
2017        (r321342)
+++ stable/11/sys/i386/cloudabi32/cloudabi32_sysvec.c   Fri Jul 21 18:06:57 
2017        (r321343)
@@ -85,10 +85,14 @@ cloudabi32_proc_setregs(struct thread *td, struct imag
 }
 
 static int
-cloudabi32_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cloudabi32_fetch_syscall_args(struct thread *td)
 {
-       struct trapframe *frame = td->td_frame;
+       struct trapframe *frame;
+       struct syscall_args *sa;
        int error;
+
+       frame = td->td_frame;
+       sa = &td->td_sa;
 
        /* Obtain system call number. */
        sa->code = frame->tf_eax;

Modified: stable/11/sys/i386/i386/trap.c
==============================================================================
--- stable/11/sys/i386/i386/trap.c      Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/i386/i386/trap.c      Fri Jul 21 18:06:57 2017        
(r321343)
@@ -1011,16 +1011,18 @@ dblfault_handler()
 }
 
 int
-cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cpu_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        struct trapframe *frame;
+       struct syscall_args *sa;
        caddr_t params;
        long tmp;
        int error;
 
        p = td->td_proc;
        frame = td->td_frame;
+       sa = &td->td_sa;
 
        params = (caddr_t)frame->tf_esp + sizeof(int);
        sa->code = frame->tf_eax;
@@ -1081,7 +1083,6 @@ void
 syscall(struct trapframe *frame)
 {
        struct thread *td;
-       struct syscall_args sa;
        register_t orig_tf_eflags;
        int error;
        ksiginfo_t ksi;
@@ -1098,7 +1099,7 @@ syscall(struct trapframe *frame)
        td = curthread;
        td->td_frame = frame;
 
-       error = syscallenter(td, &sa);
+       error = syscallenter(td);
 
        /*
         * Traced syscall.
@@ -1114,10 +1115,10 @@ syscall(struct trapframe *frame)
 
        KASSERT(PCB_USER_FPU(td->td_pcb),
            ("System call %s returning with kernel FPU ctx leaked",
-            syscallname(td->td_proc, sa.code)));
+            syscallname(td->td_proc, td->td_sa.code)));
        KASSERT(td->td_pcb->pcb_save == get_pcb_user_save_td(td),
            ("System call %s returning with mangled pcb_save",
-            syscallname(td->td_proc, sa.code)));
+            syscallname(td->td_proc, td->td_sa.code)));
 
-       syscallret(td, error, &sa);
+       syscallret(td, error);
 }

Modified: stable/11/sys/i386/linux/linux_sysvec.c
==============================================================================
--- stable/11/sys/i386/linux/linux_sysvec.c     Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/i386/linux/linux_sysvec.c     Fri Jul 21 18:06:57 2017        
(r321343)
@@ -850,13 +850,15 @@ linux_rt_sigreturn(struct thread *td, struct linux_rt_
 }
 
 static int
-linux_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+linux_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        struct trapframe *frame;
+       struct syscall_args *sa;
 
        p = td->td_proc;
        frame = td->td_frame;
+       sa = &td->td_sa;
 
        sa->code = frame->tf_eax;
        sa->args[0] = frame->tf_ebx;

Modified: stable/11/sys/kern/init_main.c
==============================================================================
--- stable/11/sys/kern/init_main.c      Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/kern/init_main.c      Fri Jul 21 18:06:57 2017        
(r321343)
@@ -369,8 +369,7 @@ SYSINIT(diagwarn2, SI_SUB_LAST, SI_ORDER_THIRD + 2,
 #endif
 
 static int
-null_fetch_syscall_args(struct thread *td __unused,
-    struct syscall_args *sa __unused)
+null_fetch_syscall_args(struct thread *td __unused)
 {
 
        panic("null_fetch_syscall_args");

Modified: stable/11/sys/kern/kern_fork.c
==============================================================================
--- stable/11/sys/kern/kern_fork.c      Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/kern/kern_fork.c      Fri Jul 21 18:06:57 2017        
(r321343)
@@ -478,6 +478,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct
 
        bcopy(&td->td_startcopy, &td2->td_startcopy,
            __rangeof(struct thread, td_startcopy, td_endcopy));
+       td2->td_sa = td->td_sa;
 
        bcopy(&p2->p_comm, &td2->td_name, sizeof(td2->td_name));
        td2->td_sigstk = td->td_sigstk;
@@ -1103,7 +1104,7 @@ fork_return(struct thread *td, struct trapframe *frame
                 */
                PROC_LOCK(p);
                td->td_dbgflags |= TDB_SCX;
-               _STOPEVENT(p, S_SCX, td->td_dbg_sc_code);
+               _STOPEVENT(p, S_SCX, td->td_sa.code);
                if ((p->p_ptevents & PTRACE_SCX) != 0 ||
                    (td->td_dbgflags & TDB_BORN) != 0)
                        ptracestop(td, SIGTRAP, NULL);

Modified: stable/11/sys/kern/kern_kthread.c
==============================================================================
--- stable/11/sys/kern/kern_kthread.c   Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/kern/kern_kthread.c   Fri Jul 21 18:06:57 2017        
(r321343)
@@ -276,6 +276,7 @@ kthread_add(void (*func)(void *), void *arg, struct pr
        newtd->td_sleeptimo = 0;
        bcopy(&oldtd->td_startcopy, &newtd->td_startcopy,
            __rangeof(struct thread, td_startcopy, td_endcopy));
+       newtd->td_sa = oldtd->td_sa;
 
        /* set up arg0 for 'ps', et al */
        va_start(ap, fmt);

Modified: stable/11/sys/kern/kern_thr.c
==============================================================================
--- stable/11/sys/kern/kern_thr.c       Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/kern/kern_thr.c       Fri Jul 21 18:06:57 2017        
(r321343)
@@ -235,6 +235,7 @@ thread_create(struct thread *td, struct rtprio *rtp,
        newtd->td_sleeptimo = 0;
        bcopy(&td->td_startcopy, &newtd->td_startcopy,
            __rangeof(struct thread, td_startcopy, td_endcopy));
+       newtd->td_sa = td->td_sa;
        newtd->td_proc = td->td_proc;
        newtd->td_rb_list = newtd->td_rbp_list = newtd->td_rb_inact = 0;
        thread_cow_get(newtd, td);

Modified: stable/11/sys/kern/subr_syscall.c
==============================================================================
--- stable/11/sys/kern/subr_syscall.c   Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/kern/subr_syscall.c   Fri Jul 21 18:06:57 2017        
(r321343)
@@ -52,13 +52,15 @@ __FBSDID("$FreeBSD$");
 #include <security/audit/audit.h>
 
 static inline int
-syscallenter(struct thread *td, struct syscall_args *sa)
+syscallenter(struct thread *td)
 {
        struct proc *p;
+       struct syscall_args *sa;
        int error, traced;
 
        PCPU_INC(cnt.v_syscall);
        p = td->td_proc;
+       sa = &td->td_sa;
 
        td->td_pticks = 0;
        if (td->td_cowgen != p->p_cowgen)
@@ -71,7 +73,7 @@ syscallenter(struct thread *td, struct syscall_args *s
                        td->td_dbgflags |= TDB_SCE;
                PROC_UNLOCK(p);
        }
-       error = (p->p_sysent->sv_fetch_syscall_args)(td, sa);
+       error = (p->p_sysent->sv_fetch_syscall_args)(td);
 #ifdef KTRACE
        if (KTRPOINT(td, KTR_SYSCALL))
                ktrsyscall(sa->code, sa->narg, sa->args);
@@ -85,8 +87,6 @@ syscallenter(struct thread *td, struct syscall_args *s
                STOPEVENT(p, S_SCE, sa->narg);
                if (p->p_flag & P_TRACED) {
                        PROC_LOCK(p);
-                       td->td_dbg_sc_code = sa->code;
-                       td->td_dbg_sc_narg = sa->narg;
                        if (p->p_ptevents & PTRACE_SCE)
                                ptracestop((td), SIGTRAP, NULL);
                        PROC_UNLOCK(p);
@@ -96,11 +96,7 @@ syscallenter(struct thread *td, struct syscall_args *s
                         * Reread syscall number and arguments if
                         * debugger modified registers or memory.
                         */
-                       error = (p->p_sysent->sv_fetch_syscall_args)(td, sa);
-                       PROC_LOCK(p);
-                       td->td_dbg_sc_code = sa->code;
-                       td->td_dbg_sc_narg = sa->narg;
-                       PROC_UNLOCK(p);
+                       error = (p->p_sysent->sv_fetch_syscall_args)(td);
 #ifdef KTRACE
                        if (KTRPOINT(td, KTR_SYSCALL))
                                ktrsyscall(sa->code, sa->narg, sa->args);
@@ -162,9 +158,10 @@ syscallenter(struct thread *td, struct syscall_args *s
 }
 
 static inline void
-syscallret(struct thread *td, int error, struct syscall_args *sa)
+syscallret(struct thread *td, int error)
 {
        struct proc *p, *p2;
+       struct syscall_args *sa;
        ksiginfo_t ksi;
        int traced, error1;
 
@@ -172,6 +169,7 @@ syscallret(struct thread *td, int error, struct syscal
            ("fork() did not clear TDP_FORKING upon completion"));
 
        p = td->td_proc;
+       sa = &td->td_sa;
        if ((trap_enotcap || (p->p_flag2 & P2_TRAPCAP) != 0) &&
            IN_CAPABILITY_MODE(td)) {
                error1 = (td->td_pflags & TDP_NERRNO) == 0 ? error :

Modified: stable/11/sys/kern/sys_process.c
==============================================================================
--- stable/11/sys/kern/sys_process.c    Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/kern/sys_process.c    Fri Jul 21 18:06:57 2017        
(r321343)
@@ -1347,8 +1347,8 @@ kern_ptrace(struct thread *td, int req, pid_t pid, voi
                pl->pl_siglist = td2->td_siglist;
                strcpy(pl->pl_tdname, td2->td_name);
                if ((td2->td_dbgflags & (TDB_SCE | TDB_SCX)) != 0) {
-                       pl->pl_syscall_code = td2->td_dbg_sc_code;
-                       pl->pl_syscall_narg = td2->td_dbg_sc_narg;
+                       pl->pl_syscall_code = td2->td_sa.code;
+                       pl->pl_syscall_narg = td2->td_sa.narg;
                } else {
                        pl->pl_syscall_code = 0;
                        pl->pl_syscall_narg = 0;

Modified: stable/11/sys/mips/mips/trap.c
==============================================================================
--- stable/11/sys/mips/mips/trap.c      Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/mips/mips/trap.c      Fri Jul 21 18:06:57 2017        
(r321343)
@@ -339,12 +339,16 @@ static int emulate_unaligned_access(struct trapframe *
 extern void fswintrberr(void); /* XXX */
 
 int
-cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cpu_fetch_syscall_args(struct thread *td)
 {
-       struct trapframe *locr0 = td->td_frame;
+       struct trapframe *locr0;
        struct sysentvec *se;
+       struct syscall_args *sa;
        int error, nsaved;
 
+       locr0 = td->td_frame;
+       sa = &td->td_sa;
+       
        bzero(sa->args, sizeof(sa->args));
 
        /* compute next PC after syscall instruction */
@@ -786,19 +790,18 @@ dofault:
 
        case T_SYSCALL + T_USER:
                {
-                       struct syscall_args sa;
                        int error;
 
-                       sa.trapframe = trapframe;
-                       error = syscallenter(td, &sa);
+                       td->td_sa.trapframe = trapframe;
+                       error = syscallenter(td);
 
 #if !defined(SMP) && (defined(DDB) || defined(DEBUG))
                        if (trp == trapdebug)
-                               trapdebug[TRAPSIZE - 1].code = sa.code;
+                               trapdebug[TRAPSIZE - 1].code = td->td_sa.code;
                        else
-                               trp[-1].code = sa.code;
+                               trp[-1].code = td->td_sa.code;
 #endif
-                       trapdebug_enter(td->td_frame, -sa.code);
+                       trapdebug_enter(td->td_frame, -td->td_sa.code);
 
                        /*
                         * The sync'ing of I & D caches for SYS_ptrace() is
@@ -806,7 +809,7 @@ dofault:
                         * instead of being done here under a special check
                         * for SYS_ptrace().
                         */
-                       syscallret(td, error, &sa);
+                       syscallret(td, error);
                        return (trapframe->pc);
                }
 

Modified: stable/11/sys/powerpc/powerpc/trap.c
==============================================================================
--- stable/11/sys/powerpc/powerpc/trap.c        Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/powerpc/powerpc/trap.c        Fri Jul 21 18:06:57 2017        
(r321343)
@@ -484,16 +484,18 @@ handle_onfault(struct trapframe *frame)
 }
 
 int
-cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cpu_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        struct trapframe *frame;
+       struct syscall_args *sa;
        caddr_t params;
        size_t argsz;
        int error, n, i;
 
        p = td->td_proc;
        frame = td->td_frame;
+       sa = &td->td_sa;
 
        sa->code = frame->fixreg[0];
        params = (caddr_t)(frame->fixreg + FIRSTARG);
@@ -575,7 +577,6 @@ void
 syscall(struct trapframe *frame)
 {
        struct thread *td;
-       struct syscall_args sa;
        int error;
 
        td = curthread;
@@ -590,8 +591,8 @@ syscall(struct trapframe *frame)
             "r"(td->td_pcb->pcb_cpu.aim.usr_vsid), "r"(USER_SLB_SLBE));
 #endif
 
-       error = syscallenter(td, &sa);
-       syscallret(td, error, &sa);
+       error = syscallenter(td);
+       syscallret(td, error);
 }
 
 #ifdef __powerpc64__

Modified: stable/11/sys/riscv/riscv/trap.c
==============================================================================
--- stable/11/sys/riscv/riscv/trap.c    Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/riscv/riscv/trap.c    Fri Jul 21 18:06:57 2017        
(r321343)
@@ -89,14 +89,16 @@ call_trapsignal(struct thread *td, int sig, int code, 
 }
 
 int
-cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cpu_fetch_syscall_args(struct thread *td)
 {
        struct proc *p;
        register_t *ap;
+       struct syscall_args *sa;
        int nap;
 
        nap = 8;
        p = td->td_proc;
+       sa = &td->td_sa;
        ap = &td->td_frame->tf_a[0];
 
        sa->code = td->td_frame->tf_t[0];
@@ -151,15 +153,14 @@ dump_regs(struct trapframe *frame)
 static void
 svc_handler(struct trapframe *frame)
 {
-       struct syscall_args sa;
        struct thread *td;
        int error;
 
        td = curthread;
        td->td_frame = frame;
 
-       error = syscallenter(td, &sa);
-       syscallret(td, error, &sa);
+       error = syscallenter(td);
+       syscallret(td, error);
 }
 
 static void

Modified: stable/11/sys/sparc64/sparc64/trap.c
==============================================================================
--- stable/11/sys/sparc64/sparc64/trap.c        Fri Jul 21 17:59:54 2017        
(r321342)
+++ stable/11/sys/sparc64/sparc64/trap.c        Fri Jul 21 18:06:57 2017        
(r321343)
@@ -538,17 +538,19 @@ trap_pfault(struct thread *td, struct trapframe *tf)
 #define        REG_MAXARGS     6
 
 int
-cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
+cpu_fetch_syscall_args(struct thread *td)
 {
        struct trapframe *tf;
        struct proc *p;
        register_t *argp;
+       struct syscall_args *sa;
        int reg;
        int regcnt;
        int error;
 
        p = td->td_proc;
        tf = td->td_frame;
+       sa = &td->td_sa;
        reg = 0;
        regcnt = REG_MAXARGS;
 
@@ -596,7 +598,6 @@ void
 syscall(struct trapframe *tf)
 {
        struct thread *td;
-       struct syscall_args sa;
        int error;
 
        td = curthread;
@@ -612,6 +613,6 @@ syscall(struct trapframe *tf)
        td->td_pcb->pcb_tpc = tf->tf_tpc;
        TF_DONE(tf);
 
-       error = syscallenter(td, &sa);
-       syscallret(td, error, &sa);
+       error = syscallenter(td);
+       syscallret(td, error);
 }

Modified: stable/11/sys/sys/proc.h
==============================================================================
--- stable/11/sys/sys/proc.h    Fri Jul 21 17:59:54 2017        (r321342)
+++ stable/11/sys/sys/proc.h    Fri Jul 21 18:06:57 2017        (r321343)
@@ -142,6 +142,7 @@ struct pargs {
  *      j - locked by proc slock
  *      k - only accessed by curthread
  *     k*- only accessed by curthread and from an interrupt
+ *     kx- only accessed by curthread and by debugger
  *      l - the attaching proc or attaching proc parent
  *      m - Giant
  *      n - not locked, lazy
@@ -295,8 +296,8 @@ struct thread {
        u_char          td_pri_class;   /* (t) Scheduling class. */
        u_char          td_user_pri;    /* (t) User pri from estcpu and nice. */
        u_char          td_base_user_pri; /* (t) Base user pri */
-       u_int           td_dbg_sc_code; /* (c) Syscall code to debugger. */
-       u_int           td_dbg_sc_narg; /* (c) Syscall arg count to debugger.*/
+       u_int           td_padding3;
+       u_int           td_padding4;
        uintptr_t       td_rb_list;     /* (k) Robust list head. */
        uintptr_t       td_rbp_list;    /* (k) Robust priv list head. */
        uintptr_t       td_rb_inact;    /* (k) Current in-action mutex loc. */
@@ -343,6 +344,8 @@ struct thread {
        sbintime_t      td_sleeptimo;   /* (t) Sleep timeout. */
        sigqueue_t      td_sigqueue;    /* (c) Sigs arrived, not delivered. */
 #define        td_siglist      td_sigqueue.sq_signals
+       struct syscall_args td_sa;      /* (kx) Syscall parameters. Copied on
+                                          fork for child tracing. */
 };
 
 struct thread0_storage {
@@ -1051,7 +1054,7 @@ void      userret(struct thread *, struct trapframe *);
 void   cpu_exit(struct thread *);
 void   exit1(struct thread *, int, int) __dead2;
 void   cpu_copy_thread(struct thread *td, struct thread *td0);
-int    cpu_fetch_syscall_args(struct thread *td, struct syscall_args *sa);
+int    cpu_fetch_syscall_args(struct thread *td);
 void   cpu_fork(struct thread *, struct proc *, struct thread *, int);
 void   cpu_fork_kthread_handler(struct thread *, void (*)(void *), void *);
 void   cpu_set_syscall_retval(struct thread *, int);

Modified: stable/11/sys/sys/sysent.h
==============================================================================
--- stable/11/sys/sys/sysent.h  Fri Jul 21 17:59:54 2017        (r321342)
+++ stable/11/sys/sys/sysent.h  Fri Jul 21 18:06:57 2017        (r321343)
@@ -119,8 +119,7 @@ struct sysentvec {
        u_long          *sv_maxssiz;
        u_int           sv_flags;
        void            (*sv_set_syscall_retval)(struct thread *, int);
-       int             (*sv_fetch_syscall_args)(struct thread *, struct
-                           syscall_args *);
+       int             (*sv_fetch_syscall_args)(struct thread *);
        const char      **sv_syscallnames;
        vm_offset_t     sv_timekeep_base;
        vm_offset_t     sv_shared_page_base;
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to