summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/linux/mm_types.h5
-rw-r--r--mm/internal.h4
-rw-r--r--mm/mmap.c2
-rw-r--r--mm/util.c14
-rw-r--r--mm/vma.c5
-rw-r--r--mm/vma.h28
-rw-r--r--tools/testing/vma/vma_internal.h28
7 files changed, 43 insertions, 43 deletions
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 6920c816f6c6..965dedb3ccfa 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -777,13 +777,14 @@ struct pfnmap_track_ctx {
*/
struct vm_area_desc {
/* Immutable state. */
- struct mm_struct *mm;
+ const struct mm_struct *const mm;
+ struct file *const file; /* May vary from vm_file in stacked callers. */
unsigned long start;
unsigned long end;
/* Mutable fields. Populated with initial state. */
pgoff_t pgoff;
- struct file *file;
+ struct file *vm_file;
vm_flags_t vm_flags;
pgprot_t page_prot;
diff --git a/mm/internal.h b/mm/internal.h
index c4657ffd342e..63e3ec8d63be 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -962,8 +962,8 @@ extern long populate_vma_page_range(struct vm_area_struct *vma,
unsigned long start, unsigned long end, int *locked);
extern long faultin_page_range(struct mm_struct *mm, unsigned long start,
unsigned long end, bool write, int *locked);
-extern bool mlock_future_ok(struct mm_struct *mm, vm_flags_t vm_flags,
- unsigned long bytes);
+bool mlock_future_ok(const struct mm_struct *mm, vm_flags_t vm_flags,
+ unsigned long bytes);
/*
* NOTE: This function can't tell whether the folio is "fully mapped" in the
diff --git a/mm/mmap.c b/mm/mmap.c
index 7a057e0e8da9..5fd3b80fda1d 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -225,7 +225,7 @@ static inline unsigned long round_hint_to_min(unsigned long hint)
return hint;
}
-bool mlock_future_ok(struct mm_struct *mm, vm_flags_t vm_flags,
+bool mlock_future_ok(const struct mm_struct *mm, vm_flags_t vm_flags,
unsigned long bytes)
{
unsigned long locked_pages, limit_pages;
diff --git a/mm/util.c b/mm/util.c
index 732a2dfcaec7..215ecd0214b7 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -1161,10 +1161,20 @@ EXPORT_SYMBOL(flush_dcache_folio);
*/
int compat_vma_mmap_prepare(struct file *file, struct vm_area_struct *vma)
{
- struct vm_area_desc desc;
+ struct vm_area_desc desc = {
+ .mm = vma->vm_mm,
+ .file = vma->vm_file,
+ .start = vma->vm_start,
+ .end = vma->vm_end,
+
+ .pgoff = vma->vm_pgoff,
+ .vm_file = vma->vm_file,
+ .vm_flags = vma->vm_flags,
+ .page_prot = vma->vm_page_prot,
+ };
int err;
- err = file->f_op->mmap_prepare(vma_to_desc(vma, &desc));
+ err = file->f_op->mmap_prepare(&desc);
if (err)
return err;
set_vma_from_desc(vma, &desc);
diff --git a/mm/vma.c b/mm/vma.c
index 3b12c7579831..abe0da33c844 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -2572,11 +2572,12 @@ static int call_mmap_prepare(struct mmap_state *map)
int err;
struct vm_area_desc desc = {
.mm = map->mm,
+ .file = map->file,
.start = map->addr,
.end = map->end,
.pgoff = map->pgoff,
- .file = map->file,
+ .vm_file = map->file,
.vm_flags = map->vm_flags,
.page_prot = map->page_prot,
};
@@ -2588,7 +2589,7 @@ static int call_mmap_prepare(struct mmap_state *map)
/* Update fields permitted to be changed. */
map->pgoff = desc.pgoff;
- map->file = desc.file;
+ map->file = desc.vm_file;
map->vm_flags = desc.vm_flags;
map->page_prot = desc.page_prot;
/* User-defined fields. */
diff --git a/mm/vma.h b/mm/vma.h
index bcdc261c5b15..9183fe549009 100644
--- a/mm/vma.h
+++ b/mm/vma.h
@@ -222,31 +222,11 @@ static inline int vma_iter_store_gfp(struct vma_iterator *vmi,
return 0;
}
-
/*
- * Temporary helper functions for file systems which wrap an invocation of
+ * Temporary helper function for stacked mmap handlers which specify
* f_op->mmap() but which might have an underlying file system which implements
* f_op->mmap_prepare().
*/
-
-static inline struct vm_area_desc *vma_to_desc(struct vm_area_struct *vma,
- struct vm_area_desc *desc)
-{
- desc->mm = vma->vm_mm;
- desc->start = vma->vm_start;
- desc->end = vma->vm_end;
-
- desc->pgoff = vma->vm_pgoff;
- desc->file = vma->vm_file;
- desc->vm_flags = vma->vm_flags;
- desc->page_prot = vma->vm_page_prot;
-
- desc->vm_ops = NULL;
- desc->private_data = NULL;
-
- return desc;
-}
-
static inline void set_vma_from_desc(struct vm_area_struct *vma,
struct vm_area_desc *desc)
{
@@ -258,9 +238,9 @@ static inline void set_vma_from_desc(struct vm_area_struct *vma,
/* Mutable fields. Populated with initial state. */
vma->vm_pgoff = desc->pgoff;
- if (vma->vm_file != desc->file)
- vma_set_file(vma, desc->file);
- if (vma->vm_flags != desc->vm_flags)
+ if (desc->vm_file != vma->vm_file)
+ vma_set_file(vma, desc->vm_file);
+ if (desc->vm_flags != vma->vm_flags)
vm_flags_set(vma, desc->vm_flags);
vma->vm_page_prot = desc->page_prot;
diff --git a/tools/testing/vma/vma_internal.h b/tools/testing/vma/vma_internal.h
index 437d2a1013be..6dcbeaa9f9a0 100644
--- a/tools/testing/vma/vma_internal.h
+++ b/tools/testing/vma/vma_internal.h
@@ -283,13 +283,14 @@ struct vm_area_struct;
*/
struct vm_area_desc {
/* Immutable state. */
- struct mm_struct *mm;
+ const struct mm_struct *const mm;
+ struct file *const file; /* May vary from vm_file in stacked callers. */
unsigned long start;
unsigned long end;
/* Mutable fields. Populated with initial state. */
pgoff_t pgoff;
- struct file *file;
+ struct file *vm_file;
vm_flags_t vm_flags;
pgprot_t page_prot;
@@ -1299,8 +1300,8 @@ static inline bool capable(int cap)
return true;
}
-static inline bool mlock_future_ok(struct mm_struct *mm, vm_flags_t vm_flags,
- unsigned long bytes)
+static inline bool mlock_future_ok(const struct mm_struct *mm,
+ vm_flags_t vm_flags, unsigned long bytes)
{
unsigned long locked_pages, limit_pages;
@@ -1465,16 +1466,23 @@ static inline void free_anon_vma_name(struct vm_area_struct *vma)
static inline void set_vma_from_desc(struct vm_area_struct *vma,
struct vm_area_desc *desc);
-static inline struct vm_area_desc *vma_to_desc(struct vm_area_struct *vma,
- struct vm_area_desc *desc);
-
-static int compat_vma_mmap_prepare(struct file *file,
+static inline int compat_vma_mmap_prepare(struct file *file,
struct vm_area_struct *vma)
{
- struct vm_area_desc desc;
+ struct vm_area_desc desc = {
+ .mm = vma->vm_mm,
+ .file = vma->vm_file,
+ .start = vma->vm_start,
+ .end = vma->vm_end,
+
+ .pgoff = vma->vm_pgoff,
+ .vm_file = vma->vm_file,
+ .vm_flags = vma->vm_flags,
+ .page_prot = vma->vm_page_prot,
+ };
int err;
- err = file->f_op->mmap_prepare(vma_to_desc(vma, &desc));
+ err = file->f_op->mmap_prepare(&desc);
if (err)
return err;
set_vma_from_desc(vma, &desc);