aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/amd64/vm_machdep.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>2005-01-21 05:57:45 +0000
committerPeter Wemm <peter@FreeBSD.org>2005-01-21 05:57:45 +0000
commit4fe91893a6237821cd83fa3e56d612e504ea10a5 (patch)
tree5006e894340be91f6e5add0732fbe242fe54276f /sys/amd64/amd64/vm_machdep.c
parentba2426ff447a0767bfe8454563d0984233ede0ff (diff)
downloadsrc-4fe91893a6237821cd83fa3e56d612e504ea10a5.tar.gz
src-4fe91893a6237821cd83fa3e56d612e504ea10a5.zip
MFi386: handle PSL_T properly across fork. Typo fix.
Notes
Notes: svn path=/head/; revision=140554
Diffstat (limited to 'sys/amd64/amd64/vm_machdep.c')
-rw-r--r--sys/amd64/amd64/vm_machdep.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
index d784d02f80b2..9b9981234aef 100644
--- a/sys/amd64/amd64/vm_machdep.c
+++ b/sys/amd64/amd64/vm_machdep.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
+#include <sys/pioctl.h>
#include <sys/proc.h>
#include <sys/sf_buf.h>
#include <sys/smp.h>
@@ -133,6 +134,17 @@ cpu_fork(td1, p2, td2, flags)
td2->td_frame->tf_rdx = 1;
/*
+ * If the parent process has the trap bit set (i.e. a debugger had
+ * single stepped the process to the system call), we need to clear
+ * the trap flag from the new frame unless the debugger had set PF_FORK
+ * 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;
+
+ /*
* Set registers for trampoline to user mode. Leave space for the
* return address on stack. These are the kernel mode register values.
*/
@@ -227,7 +239,7 @@ cpu_thread_setup(struct thread *td)
/*
* Initialize machine state (pcb and trap frame) for a new thread about to
- * upcall. Pu t enough state in the new thread's PCB to get it to go back
+ * 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.