Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147454984
D31472.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D31472.id.diff
View Options
diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c
--- a/sys/amd64/amd64/elf_machdep.c
+++ b/sys/amd64/amd64/elf_machdep.c
@@ -87,6 +87,7 @@
.sv_stackgap = elf64_stackgap,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
+ .sv_set_fork_retval = x86_set_fork_retval,
};
struct sysentvec elf64_freebsd_sysvec_la57 = {
@@ -127,6 +128,7 @@
.sv_stackgap = elf64_stackgap,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
+ .sv_set_fork_retval= x86_set_fork_retval,
};
static void
diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c
--- a/sys/amd64/amd64/vm_machdep.c
+++ b/sys/amd64/amd64/vm_machdep.c
@@ -245,9 +245,8 @@
td2->td_frame = (struct trapframe *)td2->td_md.md_stack_base - 1;
bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe));
- td2->td_frame->tf_rax = 0; /* Child returns zero */
- td2->td_frame->tf_rflags &= ~PSL_C; /* success */
- td2->td_frame->tf_rdx = 1;
+ /* Set child return values. */
+ p2->p_sysent->sv_set_fork_retval(td2);
/*
* If the parent process has the trap bit set (i.e. a debugger
@@ -300,6 +299,16 @@
*/
}
+void
+x86_set_fork_retval(struct thread *td)
+{
+ struct trapframe *frame = td->td_frame;
+
+ frame->tf_rax = 0; /* Child returns zero */
+ frame->tf_rflags &= ~PSL_C; /* success */
+ frame->tf_rdx = 1; /* System V emulation */
+}
+
/*
* Intercept the return address from a freshly forked process that has NOT
* been scheduled yet.
diff --git a/sys/amd64/cloudabi32/cloudabi32_sysvec.c b/sys/amd64/cloudabi32/cloudabi32_sysvec.c
--- a/sys/amd64/cloudabi32/cloudabi32_sysvec.c
+++ b/sys/amd64/cloudabi32/cloudabi32_sysvec.c
@@ -36,6 +36,7 @@
#include <vm/pmap.h>
#include <machine/frame.h>
+#include <machine/md_var.h>
#include <machine/pcb.h>
#include <machine/vmparam.h>
@@ -225,6 +226,7 @@
.sv_fetch_syscall_args = cloudabi32_fetch_syscall_args,
.sv_syscallnames = cloudabi32_syscallnames,
.sv_schedtail = cloudabi32_schedtail,
+ .sv_set_fork_retval = x86_set_fork_retval,
};
INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec);
diff --git a/sys/amd64/cloudabi64/cloudabi64_sysvec.c b/sys/amd64/cloudabi64/cloudabi64_sysvec.c
--- a/sys/amd64/cloudabi64/cloudabi64_sysvec.c
+++ b/sys/amd64/cloudabi64/cloudabi64_sysvec.c
@@ -36,6 +36,7 @@
#include <vm/pmap.h>
#include <machine/frame.h>
+#include <machine/md_var.h>
#include <machine/pcb.h>
#include <machine/vmparam.h>
@@ -212,6 +213,7 @@
.sv_fetch_syscall_args = cloudabi64_fetch_syscall_args,
.sv_syscallnames = cloudabi64_syscallnames,
.sv_schedtail = cloudabi64_schedtail,
+ .sv_set_fork_retval = x86_set_fork_retval,
};
INIT_SYSENTVEC(elf_sysvec, &cloudabi64_elf_sysvec);
diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c
--- a/sys/amd64/linux/linux_sysvec.c
+++ b/sys/amd64/linux/linux_sysvec.c
@@ -125,6 +125,7 @@
static void linux_exec_sysvec_init(void *param);
static int linux_on_exec_vmspace(struct proc *p,
struct image_params *imgp);
+static void linux_set_fork_retval(struct thread *td);
static int linux_vsyscall(struct thread *td);
#define LINUX_T_UNKNOWN 255
@@ -269,6 +270,14 @@
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
}
+static void
+linux_set_fork_retval(struct thread *td)
+{
+ struct trapframe *frame = td->td_frame;
+
+ frame->tf_rax = 0;
+}
+
static int
linux_copyout_auxargs(struct image_params *imgp, uintptr_t base)
{
@@ -790,6 +799,7 @@
.sv_onexit = linux_on_exit,
.sv_ontdexit = linux_thread_dtor,
.sv_setid_allowed = &linux_setid_allowed_query,
+ .sv_set_fork_retval = linux_set_fork_retval,
};
static int
diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -128,6 +128,7 @@
static void linux_vdso_install(const void *param);
static void linux_vdso_deinstall(const void *param);
static void linux_vdso_reloc(char *mapping, Elf_Addr offset);
+static void linux32_set_fork_retval(struct thread *td);
static void linux32_set_syscall_retval(struct thread *td, int error);
#define LINUX_T_UNKNOWN 255
@@ -703,6 +704,14 @@
}
}
+static void
+linux32_set_fork_retval(struct thread *td)
+{
+ struct trapframe *frame = td->td_frame;
+
+ frame->tf_rax = 0;
+}
+
/*
* Clear registers on exec
* XXX copied from ia32_signal.c.
@@ -956,6 +965,7 @@
.sv_onexit = linux_on_exit,
.sv_ontdexit = linux_thread_dtor,
.sv_setid_allowed = &linux_setid_allowed_query,
+ .sv_set_fork_retval = linux32_set_fork_retval,
};
static int
diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c
--- a/sys/compat/ia32/ia32_sysvec.c
+++ b/sys/compat/ia32/ia32_sysvec.c
@@ -133,6 +133,7 @@
.sv_stackgap = elf32_stackgap,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
+ .sv_set_fork_retval = x86_set_fork_retval,
};
INIT_SYSENTVEC(elf_ia32_sysvec, &ia32_freebsd_sysvec);
diff --git a/sys/i386/cloudabi32/cloudabi32_sysvec.c b/sys/i386/cloudabi32/cloudabi32_sysvec.c
--- a/sys/i386/cloudabi32/cloudabi32_sysvec.c
+++ b/sys/i386/cloudabi32/cloudabi32_sysvec.c
@@ -36,6 +36,7 @@
#include <vm/pmap.h>
#include <machine/frame.h>
+#include <machine/md_var.h>
#include <machine/pcb.h>
#include <machine/vmparam.h>
@@ -195,6 +196,7 @@
.sv_fetch_syscall_args = cloudabi32_fetch_syscall_args,
.sv_syscallnames = cloudabi32_syscallnames,
.sv_schedtail = cloudabi32_schedtail,
+ .sv_set_fork_retval = x86_set_fork_retval,
};
INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec);
diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c
--- a/sys/i386/i386/elf_machdep.c
+++ b/sys/i386/i386/elf_machdep.c
@@ -88,6 +88,7 @@
.sv_trap = NULL,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
+ .sv_set_fork_retval = x86_set_fork_retval,
};
INIT_SYSENTVEC(elf32_sysvec, &elf32_freebsd_sysvec);
diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c
--- a/sys/i386/i386/vm_machdep.c
+++ b/sys/i386/i386/vm_machdep.c
@@ -258,9 +258,8 @@
VM86_STACK_SPACE) - 1;
bcopy(td1->td_frame, td2->td_frame, sizeof(struct trapframe));
- td2->td_frame->tf_eax = 0; /* Child returns zero */
- td2->td_frame->tf_eflags &= ~PSL_C; /* success */
- td2->td_frame->tf_edx = 1;
+ /* Set child return values. */
+ p2->p_sysent->sv_set_fork_retval(td2);
/*
* If the parent process has the trap bit set (i.e. a debugger
@@ -302,6 +301,16 @@
*/
}
+void
+x86_set_fork_retval(struct thread *td)
+{
+ struct trapframe * frame = td->td_frame;
+
+ frame->tf_eax = 0; /* Child returns zero */
+ frame->tf_eflags &= ~PSL_C; /* success */
+ frame->tf_edx = 1; /* System V emulation */
+}
+
/*
* Intercept the return address from a freshly forked process that has NOT
* been scheduled yet.
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -108,6 +108,7 @@
struct image_params *imgp);
static int linux_copyout_strings(struct image_params *imgp,
uintptr_t *stack_base);
+static void linux_set_fork_retval(struct thread *td);
static bool linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
static void linux_vdso_install(const void *param);
static void linux_vdso_deinstall(const void *param);
@@ -803,6 +804,14 @@
}
}
+static void
+linux_set_fork_retval(struct thread *td)
+{
+ struct trapframe *frame = td->td_frame;
+
+ frame->tf_eax = 0;
+}
+
/*
* exec_setregs may initialize some registers differently than Linux
* does, thus potentially confusing Linux binaries. If necessary, we
@@ -856,6 +865,7 @@
.sv_onexit = linux_on_exit,
.sv_ontdexit = linux_thread_dtor,
.sv_setid_allowed = &linux_setid_allowed_query,
+ .sv_set_fork_retval = linux_set_fork_retval,
};
INIT_SYSENTVEC(aout_sysvec, &linux_sysvec);
@@ -898,6 +908,7 @@
.sv_onexit = linux_on_exit,
.sv_ontdexit = linux_thread_dtor,
.sv_setid_allowed = &linux_setid_allowed_query,
+ .sv_set_fork_retval = linux_set_fork_retval,
};
static int
diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c
--- a/sys/kern/imgact_aout.c
+++ b/sys/kern/imgact_aout.c
@@ -103,6 +103,7 @@
.sv_trap = NULL,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
+ .sv_set_fork_retval = x86_set_fork_retval,
};
#elif defined(__amd64__)
@@ -141,6 +142,7 @@
.sv_syscallnames = freebsd32_syscallnames,
.sv_onexec_old = exec_onexec_old,
.sv_onexit = exit_onexit,
+ .sv_set_fork_retval = x86_set_fork_retval,
};
#else
#error "Port me"
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -402,6 +402,12 @@
panic("null_set_syscall_retval");
}
+static void
+null_set_fork_retval(struct thread *td __unused)
+{
+
+}
+
struct sysentvec null_sysvec = {
.sv_size = 0,
.sv_table = NULL,
@@ -430,6 +436,7 @@
.sv_schedtail = NULL,
.sv_thread_detach = NULL,
.sv_trap = NULL,
+ .sv_set_fork_retval = null_set_fork_retval,
};
/*
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -156,6 +156,8 @@
void (*sv_ontdexit)(struct thread *td);
int (*sv_setid_allowed)(struct thread *td,
struct image_params *imgp);
+ void (*sv_set_fork_retval)(struct thread *);
+ /* Only used on x86 */
};
#define SV_ILP32 0x000100 /* 32-bit executable. */
diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h
--- a/sys/x86/include/x86_var.h
+++ b/sys/x86/include/x86_var.h
@@ -153,6 +153,7 @@
int user_dbreg_trap(register_t dr6);
int minidumpsys(struct dumperinfo *);
struct pcb *get_pcb_td(struct thread *td);
+void x86_set_fork_retval(struct thread *td);
/*
* MSR ops for x86_msr_op()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 12, 4:04 AM (12 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29563742
Default Alt Text
D31472.id.diff (9 KB)
Attached To
Mode
D31472: fork: Touch the registers specific to FreeBSD under the condition.
Attached
Detach File
Event Timeline
Log In to Comment