The branch main has been updated by hselasky:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=904390b4787d2e4a0d9d8ca9cb0d6da5a4fb320c

commit 904390b4787d2e4a0d9d8ca9cb0d6da5a4fb320c
Author:     Hans Petter Selasky <[email protected]>
AuthorDate: 2021-05-11 18:49:13 +0000
Commit:     Hans Petter Selasky <[email protected]>
CommitDate: 2021-05-11 19:00:14 +0000

    Implement read-only VM_SHARED flag in the LinuxKPI.
    
    For use by mmap(2) callbacks.
    
    MFC after:      1 week
    Sponsored by:   Mellanox Technologies // NVIDIA Networking
---
 sys/compat/linuxkpi/common/include/linux/mm.h |  1 +
 sys/compat/linuxkpi/common/src/linux_compat.c | 14 ++++++++------
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h 
b/sys/compat/linuxkpi/common/include/linux/mm.h
index f6f53afbc8a9..68a0f34acaf3 100644
--- a/sys/compat/linuxkpi/common/include/linux/mm.h
+++ b/sys/compat/linuxkpi/common/include/linux/mm.h
@@ -63,6 +63,7 @@ CTASSERT((VM_PROT_ALL & -(1 << 8)) == 0);
 #define        VM_DONTCOPY             (1 << 14)
 #define        VM_DONTEXPAND           (1 << 15)
 #define        VM_DONTDUMP             (1 << 16)
+#define        VM_SHARED               (1 << 17)
 
 #define        VMA_MAX_PREFAULT_RECORD 1
 
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c 
b/sys/compat/linuxkpi/common/src/linux_compat.c
index 630ee30e73e2..ee41e5e2b30d 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -1232,7 +1232,7 @@ linux_file_kqfilter(struct file *file, struct knote *kn)
 static int
 linux_file_mmap_single(struct file *fp, const struct file_operations *fop,
     vm_ooffset_t *offset, vm_size_t size, struct vm_object **object,
-    int nprot, struct thread *td)
+    int nprot, bool is_shared, struct thread *td)
 {
        struct task_struct *task;
        struct vm_area_struct *vmap;
@@ -1267,6 +1267,8 @@ linux_file_mmap_single(struct file *fp, const struct 
file_operations *fop,
        vmap->vm_pgoff = *offset / PAGE_SIZE;
        vmap->vm_pfn = 0;
        vmap->vm_flags = vmap->vm_page_prot = (nprot & VM_PROT_ALL);
+       if (is_shared)
+               vmap->vm_flags |= VM_SHARED;
        vmap->vm_ops = NULL;
        vmap->vm_file = get_file(filp);
        vmap->vm_mm = mm;
@@ -1601,21 +1603,21 @@ linux_file_ioctl(struct file *fp, u_long cmd, void 
*data, struct ucred *cred,
 
 static int
 linux_file_mmap_sub(struct thread *td, vm_size_t objsize, vm_prot_t prot,
-    vm_prot_t *maxprotp, int *flagsp, struct file *fp,
+    vm_prot_t maxprot, int flags, struct file *fp,
     vm_ooffset_t *foff, const struct file_operations *fop, vm_object_t *objp)
 {
        /*
         * Character devices do not provide private mappings
         * of any kind:
         */
-       if ((*maxprotp & VM_PROT_WRITE) == 0 &&
+       if ((maxprot & VM_PROT_WRITE) == 0 &&
            (prot & VM_PROT_WRITE) != 0)
                return (EACCES);
-       if ((*flagsp & (MAP_PRIVATE | MAP_COPY)) != 0)
+       if ((flags & (MAP_PRIVATE | MAP_COPY)) != 0)
                return (EINVAL);
 
        return (linux_file_mmap_single(fp, fop, foff, objsize, objp,
-           (int)prot, td));
+           (int)prot, (flags & MAP_SHARED) ? true : false, td));
 }
 
 static int
@@ -1673,7 +1675,7 @@ linux_file_mmap(struct file *fp, vm_map_t map, 
vm_offset_t *addr, vm_size_t size
        maxprot &= cap_maxprot;
 
        linux_get_fop(filp, &fop, &ldev);
-       error = linux_file_mmap_sub(td, size, prot, &maxprot, &flags, fp,
+       error = linux_file_mmap_sub(td, size, prot, maxprot, flags, fp,
            &foff, fop, &object);
        if (error != 0)
                goto out;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to