The branch main has been updated by brooks:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=7a1591c1b625ef47a9c9954f0143a6f0d78cc05c

commit 7a1591c1b625ef47a9c9954f0143a6f0d78cc05c
Author:     Brooks Davis <[email protected]>
AuthorDate: 2021-01-23 00:08:59 +0000
Commit:     Brooks Davis <[email protected]>
CommitDate: 2021-01-25 21:50:37 +0000

    Rename kern_mmap_req to kern_mmap
    
    Replace all uses of kern_mmap with kern_mmap_req move the old kern_mmap.
    Reand rename kern_mmap_req to kern_mmap                                .
    
    The helper saved some code churn initially, but having multiple
    interfaces is sub-optimal.
    
    Obtained from:  CheriBSD
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D28292
---
 sys/compat/cloudabi/cloudabi_mem.c    | 10 +++++--
 sys/compat/freebsd32/freebsd32_misc.c | 20 +++++++++++---
 sys/compat/linux/linux_mmap.c         |  4 +--
 sys/sys/syscallsubr.h                 |  4 +--
 sys/vm/vm_mmap.c                      | 49 ++++++++++++++++++-----------------
 5 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/sys/compat/cloudabi/cloudabi_mem.c 
b/sys/compat/cloudabi/cloudabi_mem.c
index a1ecf3623c02..426adb6ff43f 100644
--- a/sys/compat/cloudabi/cloudabi_mem.c
+++ b/sys/compat/cloudabi/cloudabi_mem.c
@@ -110,8 +110,14 @@ cloudabi_sys_mem_map(struct thread *td, struct 
cloudabi_sys_mem_map_args *uap)
        if (error != 0)
                return (error);
 
-       return (kern_mmap(td, (uintptr_t)uap->addr, uap->len, prot, flags,
-           uap->fd, uap->off));
+       return (kern_mmap(td, &(struct mmap_req){
+               .mr_hint = (uintptr_t)uap->addr,
+               .mr_len = uap->len,
+               .mr_prot = prot,
+               .mr_flags = flags,
+               .mr_fd = uap->fd,
+               .mr_pos = uap->off,
+           }));
 }
 
 int
diff --git a/sys/compat/freebsd32/freebsd32_misc.c 
b/sys/compat/freebsd32/freebsd32_misc.c
index b7db1c4468d7..c2caa7c10544 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -502,8 +502,14 @@ freebsd32_mmap(struct thread *td, struct 
freebsd32_mmap_args *uap)
                prot |= PROT_EXEC;
 #endif
 
-       return (kern_mmap(td, (uintptr_t)uap->addr, uap->len, prot,
-           uap->flags, uap->fd, PAIR32TO64(off_t, uap->pos)));
+       return (kern_mmap(td, &(struct mmap_req){
+               .mr_hint = (uintptr_t)uap->addr,
+               .mr_len = uap->len,
+               .mr_prot = prot,
+               .mr_flags = uap->flags,
+               .mr_fd = uap->fd,
+               .mr_pos = PAIR32TO64(off_t, uap->pos),
+           }));
 }
 
 #ifdef COMPAT_FREEBSD6
@@ -519,8 +525,14 @@ freebsd6_freebsd32_mmap(struct thread *td,
                prot |= PROT_EXEC;
 #endif
 
-       return (kern_mmap(td, (uintptr_t)uap->addr, uap->len, prot,
-           uap->flags, uap->fd, PAIR32TO64(off_t, uap->pos)));
+       return (kern_mmap(td, &(struct mmap_req){
+               .mr_hint = (uintptr_t)uap->addr,
+               .mr_len = uap->len,
+               .mr_prot = prot,
+               .mr_flags = uap->flags,
+               .mr_fd = uap->fd,
+               .mr_pos = PAIR32TO64(off_t, uap->pos),
+           }));
 }
 #endif
 
diff --git a/sys/compat/linux/linux_mmap.c b/sys/compat/linux/linux_mmap.c
index 1b4b0b78280c..d7f12b782e96 100644
--- a/sys/compat/linux/linux_mmap.c
+++ b/sys/compat/linux/linux_mmap.c
@@ -217,12 +217,12 @@ linux_mmap_common(struct thread *td, uintptr_t addr, 
size_t len, int prot,
            (bsd_flags & MAP_EXCL) == 0) {
                mr_fixed = mr;
                mr_fixed.mr_flags |= MAP_FIXED | MAP_EXCL;
-               error = kern_mmap_req(td, &mr_fixed);
+               error = kern_mmap(td, &mr_fixed);
                if (error == 0)
                        goto out;
        }
 
-       error = kern_mmap_req(td, &mr);
+       error = kern_mmap(td, &mr);
 out:
        LINUX_CTR2(mmap2, "return: %d (%p)", error, td->td_retval[0]);
 
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
index 71e76f072693..9e889e9d5465 100644
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -201,12 +201,10 @@ int       kern_mknodat(struct thread *td, int fd, const 
char *path,
            enum uio_seg pathseg, int mode, dev_t dev);
 int    kern_mlock(struct proc *proc, struct ucred *cred, uintptr_t addr,
            size_t len);
-int    kern_mmap(struct thread *td, uintptr_t addr, size_t len, int prot,
-           int flags, int fd, off_t pos);
+int    kern_mmap(struct thread *td, const struct mmap_req *mrp);
 int    kern_mmap_racct_check(struct thread *td, struct vm_map *map,
            vm_size_t size);
 int    kern_mmap_maxprot(struct proc *p, int prot);
-int    kern_mmap_req(struct thread *td, const struct mmap_req *mrp);
 int    kern_mprotect(struct thread *td, uintptr_t addr, size_t size, int prot);
 int    kern_msgctl(struct thread *, int, int, struct msqid_ds *);
 int    kern_msgrcv(struct thread *, int, void *, size_t, long, int, long *);
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c
index 30c485010ac8..ecdcc1272db1 100644
--- a/sys/vm/vm_mmap.c
+++ b/sys/vm/vm_mmap.c
@@ -179,8 +179,14 @@ int
 sys_mmap(struct thread *td, struct mmap_args *uap)
 {
 
-       return (kern_mmap(td, (uintptr_t)uap->addr, uap->len, uap->prot,
-           uap->flags, uap->fd, uap->pos));
+       return (kern_mmap(td, &(struct mmap_req){
+               .mr_hint = (uintptr_t)uap->addr,
+               .mr_len = uap->len,
+               .mr_prot = uap->prot,
+               .mr_flags = uap->flags,
+               .mr_fd = uap->fd,
+               .mr_pos = uap->pos,
+           }));
 }
 
 int
@@ -197,23 +203,7 @@ kern_mmap_maxprot(struct proc *p, int prot)
 }
 
 int
-kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags,
-    int fd, off_t pos)
-{
-       struct mmap_req mr = {
-               .mr_hint = addr0,
-               .mr_len = len,
-               .mr_prot = prot,
-               .mr_flags = flags,
-               .mr_fd = fd,
-               .mr_pos = pos
-       };
-
-       return (kern_mmap_req(td, &mr));
-}
-
-int
-kern_mmap_req(struct thread *td, const struct mmap_req *mrp)
+kern_mmap(struct thread *td, const struct mmap_req *mrp)
 {
        struct vmspace *vms;
        struct file *fp;
@@ -442,9 +432,14 @@ done:
 int
 freebsd6_mmap(struct thread *td, struct freebsd6_mmap_args *uap)
 {
-
-       return (kern_mmap(td, (uintptr_t)uap->addr, uap->len, uap->prot,
-           uap->flags, uap->fd, uap->pos));
+       return (kern_mmap(td, &(struct mmap_req){
+               .mr_hint = (uintptr_t)uap->addr,
+               .mr_len = uap->len,
+               .mr_prot = uap->prot,
+               .mr_flags = uap->flags,
+               .mr_fd = uap->fd,
+               .mr_pos = uap->pos,
+           }));
 }
 #endif
 
@@ -496,8 +491,14 @@ ommap(struct thread *td, struct ommap_args *uap)
                flags |= MAP_PRIVATE;
        if (uap->flags & OMAP_FIXED)
                flags |= MAP_FIXED;
-       return (kern_mmap(td, (uintptr_t)uap->addr, uap->len, prot, flags,
-           uap->fd, uap->pos));
+       return (kern_mmap(td, &(struct mmap_req){
+               .mr_hint = (uintptr_t)uap->addr,
+               .mr_len = uap->len,
+               .mr_prot = prot,
+               .mr_flags = flags,
+               .mr_fd = uap->fd,
+               .mr_pos = uap->pos,
+           }));
 }
 #endif                         /* COMPAT_43 */
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main
To unsubscribe, send any mail to "[email protected]"

Reply via email to