freebsd-skq/sys/i386
Ed Schouten 814629dd64 Don't let cpu_set_syscall_retval() clobber exec_setregs().
Upon successful completion, the execve() system call invokes
exec_setregs() to initialize the registers of the initial thread of the
newly executed process. What is weird is that when execve() returns, it
still goes through the normal system call return path, clobbering the
registers with the system call's return value (td->td_retval).

Though this doesn't seem to be problematic for x86 most of the times (as
the value of eax/rax doesn't matter upon startup), this can be pretty
frustrating for architectures where function argument and return
registers overlap (e.g., ARM). On these systems, exec_setregs() also
needs to initialize td_retval.

Even worse are architectures where cpu_set_syscall_retval() sets
registers to values not derived from td_retval. On these architectures,
there is no way cpu_set_syscall_retval() can set registers to the way it
wants them to be upon the start of execution.

To get rid of this madness, let sys_execve() return EJUSTRETURN. This
will cause cpu_set_syscall_retval() to leave registers intact. This
makes process execution easier to understand. It also eliminates the
difference between execution of the initial process and successive ones.
The initial call to sys_execve() is not performed through a system call
context.

Reviewed by:	kib, jhibbits
Differential Revision:	https://reviews.freebsd.org/D13180
2017-11-24 07:35:08 +00:00
..
acpica If x86 CPU implementation of the MWAIT instruction reasonably 2015-05-09 12:28:48 +00:00
bios Remove Micro Channel Architecture support. Of the commonly available 2017-02-15 23:04:25 +00:00
cloudabi32 Move struct syscall_args syscall arguments parameters container into 2017-06-12 21:03:23 +00:00
conf Remove i386 XBOX support. 2017-11-16 14:27:02 +00:00
i386 Don't let cpu_set_syscall_retval() clobber exec_setregs(). 2017-11-24 07:35:08 +00:00
ibcs2 spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
include Remove lint support from system headers and MD x86 headers. 2017-11-23 11:40:16 +00:00
isa Consistently ensure that we do not load MXCSR with reserved bits set. 2017-11-01 10:32:44 +00:00
linux Avoid using [LINUX_]SHAREDPAGE constant directly in the vdso code. 2017-07-30 21:24:20 +00:00
pci Remove i386 XBOX support. 2017-11-16 14:27:02 +00:00
Makefile