Page MenuHomeFreeBSD

D6731.id17628.diff
No OneTemporary

D6731.id17628.diff

Index: head/sys/amd64/amd64/vm_machdep.c
===================================================================
--- head/sys/amd64/amd64/vm_machdep.c
+++ head/sys/amd64/amd64/vm_machdep.c
@@ -285,10 +285,7 @@
* This is needed to make kernel threads stay in kernel mode.
*/
void
-cpu_set_fork_handler(td, func, arg)
- struct thread *td;
- void (*func)(void *);
- void *arg;
+cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
{
/*
* Note that the trap frame follows the args, so the function
@@ -421,14 +418,14 @@
}
/*
- * Initialize machine state (pcb and trap frame) for a new thread about to
- * upcall. Put enough state in the new thread's PCB to get it to go back
- * userret(), where we can intercept it again to set the return (upcall)
- * Address and stack, along with those from upcals that are from other sources
- * such as those generated in thread_userret() itself.
+ * Initialize machine state, mostly pcb and trap frame for a new
+ * thread, about to return to userspace. Put enough state in the new
+ * thread's PCB to get it to go back to the fork_return(), which
+ * finalizes the thread state and handles peculiarities of the first
+ * return to userspace for the new thread.
*/
void
-cpu_set_upcall(struct thread *td, struct thread *td0)
+cpu_copy_thread(struct thread *td, struct thread *td0)
{
struct pcb *pcb2;
@@ -484,13 +481,12 @@
}
/*
- * Set that machine state for performing an upcall that has to
- * be done in thread_userret() so that those upcalls generated
- * in thread_userret() itself can be done as well.
+ * Set that machine state for performing an upcall that starts
+ * the entry function with the given argument.
*/
void
-cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
- stack_t *stack)
+cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
+ stack_t *stack)
{
/*
@@ -505,7 +501,7 @@
#ifdef COMPAT_FREEBSD32
if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
/*
- * Set the trap frame to point at the beginning of the uts
+ * Set the trap frame to point at the beginning of the entry
* function.
*/
td->td_frame->tf_rbp = 0;
@@ -513,10 +509,7 @@
(((uintptr_t)stack->ss_sp + stack->ss_size - 4) & ~0x0f) - 4;
td->td_frame->tf_rip = (uintptr_t)entry;
- /*
- * Pass the address of the mailbox for this kse to the uts
- * function as a parameter on the stack.
- */
+ /* Pass the argument to the entry point. */
suword32((void *)(td->td_frame->tf_rsp + sizeof(int32_t)),
(uint32_t)(uintptr_t)arg);
@@ -539,10 +532,7 @@
td->td_frame->tf_gs = _ugssel;
td->td_frame->tf_flags = TF_HASSEGS;
- /*
- * Pass the address of the mailbox for this kse to the uts
- * function as a parameter on the stack.
- */
+ /* Pass the argument to the entry point. */
td->td_frame->tf_rdi = (register_t)arg;
}
Index: head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
===================================================================
--- head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
+++ head/sys/amd64/cloudabi64/cloudabi64_sysvec.c
@@ -172,7 +172,7 @@
/* Perform standard register initialization. */
stack.ss_sp = (void *)attr->stack;
stack.ss_size = tcbptr - attr->stack;
- cpu_set_upcall_kse(td, (void *)attr->entry_point, NULL, &stack);
+ cpu_set_upcall(td, (void *)attr->entry_point, NULL, &stack);
/*
* Pass in the thread ID of the new thread and the argument
Index: head/sys/arm/arm/swtch-v6.S
===================================================================
--- head/sys/arm/arm/swtch-v6.S
+++ head/sys/arm/arm/swtch-v6.S
@@ -450,8 +450,8 @@
/*
* Restore all saved registers and return. Note that some saved
- * registers can be changed when either cpu_fork(), cpu_set_upcall(),
- * cpu_set_fork_handler(), or makectx() was called.
+ * registers can be changed when either cpu_fork(), cpu_copy_thread(),
+ * cpu_fork_kthread_handler(), or makectx() was called.
*/
add r3, r7, #PCB_R4
ldmia r3, {r4-r12, sp, pc}
Index: head/sys/arm/arm/vm_machdep.c
===================================================================
--- head/sys/arm/arm/vm_machdep.c
+++ head/sys/arm/arm/vm_machdep.c
@@ -226,14 +226,14 @@
}
/*
- * Initialize machine state (pcb and trap frame) for a new thread about to
- * upcall. Put enough state in the new thread's PCB to get it to go back
- * userret(), where we can intercept it again to set the return (upcall)
- * Address and stack, along with those from upcals that are from other sources
- * such as those generated in thread_userret() itself.
+ * Initialize machine state, mostly pcb and trap frame for a new
+ * thread, about to return to userspace. Put enough state in the new
+ * thread's PCB to get it to go back to the fork_return(), which
+ * finalizes the thread state and handles peculiarities of the first
+ * return to userspace for the new thread.
*/
void
-cpu_set_upcall(struct thread *td, struct thread *td0)
+cpu_copy_thread(struct thread *td, struct thread *td0)
{
bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe));
@@ -253,12 +253,11 @@
}
/*
- * Set that machine state for performing an upcall that has to
- * be done in thread_userret() so that those upcalls generated
- * in thread_userret() itself can be done as well.
+ * Set that machine state for performing an upcall that starts
+ * the entry function with the given argument.
*/
void
-cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
+cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
stack_t *stack)
{
struct trapframe *tf = td->td_frame;
@@ -327,7 +326,7 @@
* This is needed to make kernel threads stay in kernel mode.
*/
void
-cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg)
+cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
{
td->td_pcb->pcb_regs.sf_r4 = (register_t)func; /* function */
td->td_pcb->pcb_regs.sf_r5 = (register_t)arg; /* first arg */
Index: head/sys/arm64/arm64/vm_machdep.c
===================================================================
--- head/sys/arm64/arm64/vm_machdep.c
+++ head/sys/arm64/arm64/vm_machdep.c
@@ -153,14 +153,14 @@
}
/*
- * Initialize machine state (pcb and trap frame) for a new thread about to
- * upcall. Put enough state in the new thread's PCB to get it to go back
- * userret(), where we can intercept it again to set the return (upcall)
- * Address and stack, along with those from upcals that are from other sources
- * such as those generated in thread_userret() itself.
+ * Initialize machine state, mostly pcb and trap frame for a new
+ * thread, about to return to userspace. Put enough state in the new
+ * thread's PCB to get it to go back to the fork_return(), which
+ * finalizes the thread state and handles peculiarities of the first
+ * return to userspace for the new thread.
*/
void
-cpu_set_upcall(struct thread *td, struct thread *td0)
+cpu_copy_thread(struct thread *td, struct thread *td0)
{
bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe));
bcopy(td0->td_pcb, td->td_pcb, sizeof(struct pcb));
@@ -177,12 +177,11 @@
}
/*
- * Set that machine state for performing an upcall that has to
- * be done in thread_userret() so that those upcalls generated
- * in thread_userret() itself can be done as well.
+ * Set that machine state for performing an upcall that starts
+ * the entry function with the given argument.
*/
void
-cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
+cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
stack_t *stack)
{
struct trapframe *tf = td->td_frame;
@@ -238,7 +237,7 @@
* This is needed to make kernel threads stay in kernel mode.
*/
void
-cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg)
+cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
{
td->td_pcb->pcb_x[8] = (uintptr_t)func;
Index: head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
===================================================================
--- head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
+++ head/sys/arm64/cloudabi64/cloudabi64_sysvec.c
@@ -140,7 +140,7 @@
/* Perform standard register initialization. */
stack.ss_sp = (void *)attr->stack;
stack.ss_size = attr->stack_size;
- cpu_set_upcall_kse(td, (void *)attr->entry_point, NULL, &stack);
+ cpu_set_upcall(td, (void *)attr->entry_point, NULL, &stack);
/*
* Pass in the thread ID of the new thread and the argument
Index: head/sys/compat/linux/linux_fork.c
===================================================================
--- head/sys/compat/linux/linux_fork.c
+++ head/sys/compat/linux/linux_fork.c
@@ -299,8 +299,8 @@
error = kern_thr_alloc(p, 0, &newtd);
if (error)
goto fail;
-
- cpu_set_upcall(newtd, td);
+
+ cpu_copy_thread(newtd, td);
bzero(&newtd->td_startzero,
__rangeof(struct thread, td_startzero, td_endzero));
Index: head/sys/i386/i386/vm_machdep.c
===================================================================
--- head/sys/i386/i386/vm_machdep.c
+++ head/sys/i386/i386/vm_machdep.c
@@ -324,10 +324,7 @@
* This is needed to make kernel threads stay in kernel mode.
*/
void
-cpu_set_fork_handler(td, func, arg)
- struct thread *td;
- void (*func)(void *);
- void *arg;
+cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
{
/*
* Note that the trap frame follows the args, so the function
@@ -458,14 +455,14 @@
}
/*
- * Initialize machine state (pcb and trap frame) for a new thread about to
- * upcall. Put enough state in the new thread's PCB to get it to go back
- * userret(), where we can intercept it again to set the return (upcall)
- * Address and stack, along with those from upcals that are from other sources
- * such as those generated in thread_userret() itself.
+ * Initialize machine state, mostly pcb and trap frame for a new
+ * thread, about to return to userspace. Put enough state in the new
+ * thread's PCB to get it to go back to the fork_return(), which
+ * finalizes the thread state and handles peculiarities of the first
+ * return to userspace for the new thread.
*/
void
-cpu_set_upcall(struct thread *td, struct thread *td0)
+cpu_copy_thread(struct thread *td, struct thread *td0)
{
struct pcb *pcb2;
@@ -527,13 +524,12 @@
}
/*
- * Set that machine state for performing an upcall that has to
- * be done in thread_userret() so that those upcalls generated
- * in thread_userret() itself can be done as well.
+ * Set that machine state for performing an upcall that starts
+ * the entry function with the given argument.
*/
void
-cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
- stack_t *stack)
+cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
+ stack_t *stack)
{
/*
@@ -546,7 +542,7 @@
cpu_thread_clean(td);
/*
- * Set the trap frame to point at the beginning of the uts
+ * Set the trap frame to point at the beginning of the entry
* function.
*/
td->td_frame->tf_ebp = 0;
@@ -554,10 +550,7 @@
(((int)stack->ss_sp + stack->ss_size - 4) & ~0x0f) - 4;
td->td_frame->tf_eip = (int)entry;
- /*
- * Pass the address of the mailbox for this kse to the uts
- * function as a parameter on the stack.
- */
+ /* Pass the argument to the entry point. */
suword((void *)(td->td_frame->tf_esp + sizeof(void *)),
(int)arg);
}
Index: head/sys/kern/init_main.c
===================================================================
--- head/sys/kern/init_main.c
+++ head/sys/kern/init_main.c
@@ -862,7 +862,8 @@
PROC_UNLOCK(initproc);
sx_xunlock(&proctree_lock);
crfree(oldcred);
- cpu_set_fork_handler(FIRST_THREAD_IN_PROC(initproc), start_init, NULL);
+ cpu_fork_kthread_handler(FIRST_THREAD_IN_PROC(initproc),
+ start_init, NULL);
}
SYSINIT(init, SI_SUB_CREATE_INIT, SI_ORDER_FIRST, create_init, NULL);
Index: head/sys/kern/kern_fork.c
===================================================================
--- head/sys/kern/kern_fork.c
+++ head/sys/kern/kern_fork.c
@@ -1030,7 +1030,7 @@
thread_unlock(td);
/*
- * cpu_set_fork_handler intercepts this function call to
+ * cpu_fork_kthread_handler intercepts this function call to
* have this call a non-return function to stay in kernel mode.
* initproc has its own fork handler, but it does return.
*/
Index: head/sys/kern/kern_kthread.c
===================================================================
--- head/sys/kern/kern_kthread.c
+++ head/sys/kern/kern_kthread.c
@@ -124,7 +124,7 @@
#endif
/* call the processes' main()... */
- cpu_set_fork_handler(td, func, arg);
+ cpu_fork_kthread_handler(td, func, arg);
/* Avoid inheriting affinity from a random parent. */
cpuset_setthread(td->td_tid, cpuset_root);
@@ -281,14 +281,11 @@
vsnprintf(newtd->td_name, sizeof(newtd->td_name), fmt, ap);
va_end(ap);
- newtd->td_proc = p; /* needed for cpu_set_upcall */
-
- /* XXX optimise this probably? */
- /* On x86 (and probably the others too) it is way too full of junk */
- /* Needs a better name */
- cpu_set_upcall(newtd, oldtd);
+ newtd->td_proc = p; /* needed for cpu_copy_thread */
+ /* might be further optimized for kthread */
+ cpu_copy_thread(newtd, oldtd);
/* put the designated function(arg) as the resume context */
- cpu_set_fork_handler(newtd, func, arg);
+ cpu_fork_kthread_handler(newtd, func, arg);
newtd->td_pflags |= TDP_KTHREAD;
thread_cow_get_proc(newtd, p);
Index: head/sys/kern/kern_thr.c
===================================================================
--- head/sys/kern/kern_thr.c
+++ head/sys/kern/kern_thr.c
@@ -163,7 +163,7 @@
stack.ss_sp = param->stack_base;
stack.ss_size = param->stack_size;
/* Set upcall address to user thread entry function. */
- cpu_set_upcall_kse(td, param->start_func, param->arg, &stack);
+ cpu_set_upcall(td, param->start_func, param->arg, &stack);
/* Setup user TLS address and TLS pointer register. */
return (cpu_set_user_tls(td, param->tls_base));
}
@@ -227,7 +227,7 @@
if (error)
goto fail;
- cpu_set_upcall(newtd, td);
+ cpu_copy_thread(newtd, td);
bzero(&newtd->td_startzero,
__rangeof(struct thread, td_startzero, td_endzero));
Index: head/sys/mips/mips/vm_machdep.c
===================================================================
--- head/sys/mips/mips/vm_machdep.c
+++ head/sys/mips/mips/vm_machdep.c
@@ -194,7 +194,7 @@
* This is needed to make kernel threads stay in kernel mode.
*/
void
-cpu_set_fork_handler(struct thread *td, void (*func) __P((void *)), void *arg)
+cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
{
/*
* Note that the trap frame follows the args, so the function
@@ -352,14 +352,14 @@
}
/*
- * Initialize machine state (pcb and trap frame) for a new thread about to
- * upcall. Put enough state in the new thread's PCB to get it to go back
- * userret(), where we can intercept it again to set the return (upcall)
- * Address and stack, along with those from upcalls that are from other sources
- * such as those generated in thread_userret() itself.
+ * Initialize machine state, mostly pcb and trap frame for a new
+ * thread, about to return to userspace. Put enough state in the new
+ * thread's PCB to get it to go back to the fork_return(), which
+ * finalizes the thread state and handles peculiarities of the first
+ * return to userspace for the new thread.
*/
void
-cpu_set_upcall(struct thread *td, struct thread *td0)
+cpu_copy_thread(struct thread *td, struct thread *td0)
{
struct pcb *pcb2;
@@ -415,12 +415,11 @@
}
/*
- * Set that machine state for performing an upcall that has to
- * be done in thread_userret() so that those upcalls generated
- * in thread_userret() itself can be done as well.
+ * Set that machine state for performing an upcall that starts
+ * the entry function with the given argument.
*/
void
-cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
+cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
stack_t *stack)
{
struct trapframe *tf;
Index: head/sys/powerpc/powerpc/exec_machdep.c
===================================================================
--- head/sys/powerpc/powerpc/exec_machdep.c
+++ head/sys/powerpc/powerpc/exec_machdep.c
@@ -955,7 +955,7 @@
}
void
-cpu_set_upcall(struct thread *td, struct thread *td0)
+cpu_copy_thread(struct thread *td, struct thread *td0)
{
struct pcb *pcb2;
struct trapframe *tf;
@@ -996,8 +996,8 @@
}
void
-cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
- stack_t *stack)
+cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
+ stack_t *stack)
{
struct trapframe *tf;
uintptr_t sp;
Index: head/sys/powerpc/powerpc/vm_machdep.c
===================================================================
--- head/sys/powerpc/powerpc/vm_machdep.c
+++ head/sys/powerpc/powerpc/vm_machdep.c
@@ -179,7 +179,7 @@
* This is needed to make kernel threads stay in kernel mode.
*/
void
-cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg)
+cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
{
struct callframe *cf;
Index: head/sys/riscv/riscv/vm_machdep.c
===================================================================
--- head/sys/riscv/riscv/vm_machdep.c
+++ head/sys/riscv/riscv/vm_machdep.c
@@ -146,14 +146,14 @@
}
/*
- * Initialize machine state (pcb and trap frame) for a new thread about to
- * upcall. Put enough state in the new thread's PCB to get it to go back
- * userret(), where we can intercept it again to set the return (upcall)
- * Address and stack, along with those from upcals that are from other sources
- * such as those generated in thread_userret() itself.
+ * Initialize machine state, mostly pcb and trap frame for a new
+ * thread, about to return to userspace. Put enough state in the new
+ * thread's PCB to get it to go back to the fork_return(), which
+ * finalizes the thread state and handles peculiarities of the first
+ * return to userspace for the new thread.
*/
void
-cpu_set_upcall(struct thread *td, struct thread *td0)
+cpu_copy_thread(struct thread *td, struct thread *td0)
{
bcopy(td0->td_frame, td->td_frame, sizeof(struct trapframe));
@@ -170,12 +170,11 @@
}
/*
- * Set that machine state for performing an upcall that has to
- * be done in thread_userret() so that those upcalls generated
- * in thread_userret() itself can be done as well.
+ * Set that machine state for performing an upcall that starts
+ * the entry function with the given argument.
*/
void
-cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
+cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
stack_t *stack)
{
struct trapframe *tf = td->td_frame;
@@ -231,7 +230,7 @@
* This is needed to make kernel threads stay in kernel mode.
*/
void
-cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg)
+cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
{
td->td_pcb->pcb_s[0] = (uintptr_t)func;
Index: head/sys/sparc64/sparc64/vm_machdep.c
===================================================================
--- head/sys/sparc64/sparc64/vm_machdep.c
+++ head/sys/sparc64/sparc64/vm_machdep.c
@@ -174,7 +174,7 @@
}
void
-cpu_set_upcall(struct thread *td, struct thread *td0)
+cpu_copy_thread(struct thread *td, struct thread *td0)
{
struct trapframe *tf;
struct frame *fr;
@@ -197,7 +197,7 @@
}
void
-cpu_set_upcall_kse(struct thread *td, void (*entry)(void *), void *arg,
+cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
stack_t *stack)
{
struct trapframe *tf;
@@ -360,7 +360,7 @@
* This is needed to make kernel threads stay in kernel mode.
*/
void
-cpu_set_fork_handler(struct thread *td, void (*func)(void *), void *arg)
+cpu_fork_kthread_handler(struct thread *td, void (*func)(void *), void *arg)
{
struct frame *fp;
struct pcb *pcb;
Index: head/sys/sys/proc.h
===================================================================
--- head/sys/sys/proc.h
+++ head/sys/sys/proc.h
@@ -1005,12 +1005,12 @@
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);
void cpu_fork(struct thread *, struct proc *, struct thread *, int);
-void cpu_set_fork_handler(struct thread *, void (*)(void *), void *);
+void cpu_fork_kthread_handler(struct thread *, void (*)(void *), void *);
void cpu_set_syscall_retval(struct thread *, int);
-void cpu_set_upcall(struct thread *td, struct thread *td0);
-void cpu_set_upcall_kse(struct thread *, void (*)(void *), void *,
+void cpu_set_upcall(struct thread *, void (*)(void *), void *,
stack_t *);
int cpu_set_user_tls(struct thread *, void *tls_base);
void cpu_thread_alloc(struct thread *);

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 13, 12:03 AM (12 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
23646772
Default Alt Text
D6731.id17628.diff (20 KB)

Event Timeline