Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/amd64/vm_machdep.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
#include <sys/bio.h> | #include <sys/bio.h> | ||||
#include <sys/buf.h> | #include <sys/buf.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/ktr.h> | #include <sys/ktr.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/pioctl.h> | |||||
#include <sys/priv.h> | #include <sys/priv.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/procctl.h> | #include <sys/procctl.h> | ||||
#include <sys/smp.h> | #include <sys/smp.h> | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/sysent.h> | #include <sys/sysent.h> | ||||
#include <sys/unistd.h> | #include <sys/unistd.h> | ||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | cpu_fork(struct thread *td1, struct proc *p2, struct thread *td2, int flags) | ||||
td2->td_frame = (struct trapframe *)td2->td_md.md_stack_base - 1; | td2->td_frame = (struct trapframe *)td2->td_md.md_stack_base - 1; | ||||
bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); | bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe)); | ||||
td2->td_frame->tf_rax = 0; /* Child returns zero */ | td2->td_frame->tf_rax = 0; /* Child returns zero */ | ||||
td2->td_frame->tf_rflags &= ~PSL_C; /* success */ | td2->td_frame->tf_rflags &= ~PSL_C; /* success */ | ||||
td2->td_frame->tf_rdx = 1; | td2->td_frame->tf_rdx = 1; | ||||
/* | /* | ||||
* If the parent process has the trap bit set (i.e. a debugger had | * If the parent process has the trap bit set (i.e. a debugger | ||||
* single stepped the process to the system call), we need to clear | * had single stepped the process to the system call), we need | ||||
* the trap flag from the new frame unless the debugger had set PF_FORK | * to clear the trap flag from the new frame. | ||||
* on the parent. Otherwise, the child will receive a (likely | |||||
* unexpected) SIGTRAP when it executes the first instruction after | |||||
* returning to userland. | |||||
*/ | */ | ||||
if ((p1->p_pfsflags & PF_FORK) == 0) | |||||
td2->td_frame->tf_rflags &= ~PSL_T; | td2->td_frame->tf_rflags &= ~PSL_T; | ||||
/* | /* | ||||
* Set registers for trampoline to user mode. Leave space for the | * Set registers for trampoline to user mode. Leave space for the | ||||
* return address on stack. These are the kernel mode register values. | * return address on stack. These are the kernel mode register values. | ||||
*/ | */ | ||||
pcb2->pcb_r12 = (register_t)fork_return; /* fork_trampoline argument */ | pcb2->pcb_r12 = (register_t)fork_return; /* fork_trampoline argument */ | ||||
pcb2->pcb_rbp = 0; | pcb2->pcb_rbp = 0; | ||||
pcb2->pcb_rsp = (register_t)td2->td_frame - sizeof(void *); | pcb2->pcb_rsp = (register_t)td2->td_frame - sizeof(void *); | ||||
▲ Show 20 Lines • Show All 448 Lines • Show Last 20 Lines |