svn commit: r313352 - in head/sys: compat/cloudabi compat/freebsd32 compat/linux vm

Mateusz Guzik mjguzik at gmail.com
Tue Feb 7 13:50:20 UTC 2017


On Mon, Feb 06, 2017 at 08:57:12PM +0000, Edward Tomasz Napierala wrote:
> Author: trasz
> Date: Mon Feb  6 20:57:12 2017
> New Revision: 313352
> URL: https://svnweb.freebsd.org/changeset/base/313352
> 
> Log:
>   Add kern_vm_mmap2(), kern_vm_mprotect(), kern_vm_msync(), kern_vm_munlock(),
>   kern_vm_munmap(), and kern_vm_madvise(), and use them in various compats
>   instead of their sys_*() counterparts.
>   
> -sys_mmap(td, uap)
> -	struct thread *td;
> -	struct mmap_args *uap;
> +sys_mmap(struct thread *td, struct mmap_args *uap)
> +{
> +
> +	return (kern_vm_mmap(td, (vm_offset_t)uap->addr, uap->len,
> +	    uap->prot, uap->flags, uap->fd, uap->pos));
> +}
> +
> +int
> +kern_vm_mmap(struct thread *td, vm_offset_t addr, vm_size_t size,
> +    vm_prot_t prot, int flags, int fd, off_t pos)
>  {

Can we start dropping the td argument? It always is curthread and
almost always has to be anyway as something down below accesses
data in a manner only safe for curthread (classic: credential checks).

With this example the function takes 7 args. So the commit added an
indirection which cannot be tail called on amd64 due to the 7th argument
passed through the stack. Removing the td argument deals with the
problem.

-- 
Mateusz Guzik <mjguzik gmail.com>


More information about the svn-src-head mailing list