aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_mmap.c
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2020-03-04 21:27:12 +0000
committerBrooks Davis <brooks@FreeBSD.org>2020-03-04 21:27:12 +0000
commitd718de812fe1f93f8134af58ee23a36601aebe5e (patch)
tree89fc07e443be266fbfdfdf682c2f502fde888434 /sys/compat/linux/linux_mmap.c
parenta2037dba7e8671c533ede60b8fdb3f09c03b565d (diff)
Introduce kern_mmap_req().
This presents an extensible interface to the generic mmap(2) implementation via a struct pointer intended to use a designated initializer or compount literal. We take advantage of the mandatory zeroing of fields not listed in the initializer. Remove kern_mmap_fpcheck() and use kern_mmap_req(). The motivation for this change is a desire to keep the core implementation from growing an ever-increasing number of arguments that must be specified in the correct order for the lowest-level implementations. In CheriBSD we have already added two more arguments. Reviewed by: kib Discussed with: kevans Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D23164
Notes
svn path=/head/; revision=358650
Diffstat (limited to 'sys/compat/linux/linux_mmap.c')
-rw-r--r--sys/compat/linux/linux_mmap.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/compat/linux/linux_mmap.c b/sys/compat/linux/linux_mmap.c
index 1949f3055c8e..941a3388487c 100644
--- a/sys/compat/linux/linux_mmap.c
+++ b/sys/compat/linux/linux_mmap.c
@@ -77,6 +77,7 @@ int
linux_mmap_common(struct thread *td, uintptr_t addr, size_t len, int prot,
int flags, int fd, off_t pos)
{
+ struct mmap_req mr, mr_fixed;
struct proc *p = td->td_proc;
struct vmspace *vms = td->td_proc->p_vmspace;
int bsd_flags, error;
@@ -201,17 +202,25 @@ linux_mmap_common(struct thread *td, uintptr_t addr, size_t len, int prot,
* address is not zero, try with MAP_FIXED and MAP_EXCL first,
* and fall back to the normal behaviour if that fails.
*/
+ mr = (struct mmap_req) {
+ .mr_hint = addr,
+ .mr_len = len,
+ .mr_prot = prot,
+ .mr_flags = bsd_flags,
+ .mr_fd = fd,
+ .mr_pos = pos,
+ .mr_check_fp_fn = linux_mmap_check_fp,
+ };
if (addr != 0 && (bsd_flags & MAP_FIXED) == 0 &&
(bsd_flags & MAP_EXCL) == 0) {
- error = kern_mmap_fpcheck(td, addr, len, prot,
- bsd_flags | MAP_FIXED | MAP_EXCL, fd, pos,
- linux_mmap_check_fp);
+ mr_fixed = mr;
+ mr_fixed.mr_flags |= MAP_FIXED | MAP_EXCL;
+ error = kern_mmap_req(td, &mr_fixed);
if (error == 0)
goto out;
}
- error = kern_mmap_fpcheck(td, addr, len, prot, bsd_flags, fd, pos,
- linux_mmap_check_fp);
+ error = kern_mmap_req(td, &mr);
out:
LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]);