mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
mm: update core kernel code to use vm_flags_t consistently
The core kernel code is currently very inconsistent in its use of vm_flags_t vs. unsigned long. This prevents us from changing the type of vm_flags_t in the future and is simply not correct, so correct this. While this results in rather a lot of churn, it is a critical pre-requisite for a future planned change to VMA flag type. Additionally, update VMA userland tests to account for the changes. To make review easier and to break things into smaller parts, driver and architecture-specific changes is left for a subsequent commit. The code has been adjusted to cascade the changes across all calling code as far as is needed. We will adjust architecture-specific and driver code in a subsequent patch. Overall, this patch does not introduce any functional change. Link: https://lkml.kernel.org/r/d1588e7bb96d1ea3fe7b9df2c699d5b4592d901d.1750274467.git.lorenzo.stoakes@oracle.com Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Acked-by: Kees Cook <kees@kernel.org> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Jan Kara <jack@suse.cz> Acked-by: Christian Brauner <brauner@kernel.org> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Oscar Salvador <osalvador@suse.de> Reviewed-by: Pedro Falcato <pfalcato@suse.de> Acked-by: Zi Yan <ziy@nvidia.com> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Jann Horn <jannh@google.com> Cc: Liam R. Howlett <Liam.Howlett@oracle.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
78ddaa358e
commit
bfbe71109f
@@ -604,7 +604,7 @@ int setup_arg_pages(struct linux_binprm *bprm,
|
||||
struct mm_struct *mm = current->mm;
|
||||
struct vm_area_struct *vma = bprm->vma;
|
||||
struct vm_area_struct *prev = NULL;
|
||||
unsigned long vm_flags;
|
||||
vm_flags_t vm_flags;
|
||||
unsigned long stack_base;
|
||||
unsigned long stack_size;
|
||||
unsigned long stack_expand;
|
||||
|
||||
+1
-1
@@ -1242,7 +1242,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx,
|
||||
int ret;
|
||||
struct uffdio_register uffdio_register;
|
||||
struct uffdio_register __user *user_uffdio_register;
|
||||
unsigned long vm_flags;
|
||||
vm_flags_t vm_flags;
|
||||
bool found;
|
||||
bool basic_ioctls;
|
||||
unsigned long start, end;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#ifdef CONFIG_COREDUMP
|
||||
struct core_vma_metadata {
|
||||
unsigned long start, end;
|
||||
unsigned long flags;
|
||||
vm_flags_t flags;
|
||||
unsigned long dump_size;
|
||||
unsigned long pgoff;
|
||||
struct file *file;
|
||||
|
||||
@@ -261,7 +261,7 @@ static inline unsigned long thp_vma_suitable_orders(struct vm_area_struct *vma,
|
||||
}
|
||||
|
||||
unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma,
|
||||
unsigned long vm_flags,
|
||||
vm_flags_t vm_flags,
|
||||
unsigned long tva_flags,
|
||||
unsigned long orders);
|
||||
|
||||
@@ -282,7 +282,7 @@ unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma,
|
||||
*/
|
||||
static inline
|
||||
unsigned long thp_vma_allowable_orders(struct vm_area_struct *vma,
|
||||
unsigned long vm_flags,
|
||||
vm_flags_t vm_flags,
|
||||
unsigned long tva_flags,
|
||||
unsigned long orders)
|
||||
{
|
||||
@@ -317,7 +317,7 @@ struct thpsize {
|
||||
(1<<TRANSPARENT_HUGEPAGE_USE_ZERO_PAGE_FLAG))
|
||||
|
||||
static inline bool vma_thp_disabled(struct vm_area_struct *vma,
|
||||
unsigned long vm_flags)
|
||||
vm_flags_t vm_flags)
|
||||
{
|
||||
/*
|
||||
* Explicitly disabled through madvise or prctl, or some
|
||||
@@ -431,7 +431,7 @@ change_huge_pud(struct mmu_gather *tlb, struct vm_area_struct *vma,
|
||||
__split_huge_pud(__vma, __pud, __address); \
|
||||
} while (0)
|
||||
|
||||
int hugepage_madvise(struct vm_area_struct *vma, unsigned long *vm_flags,
|
||||
int hugepage_madvise(struct vm_area_struct *vma, vm_flags_t *vm_flags,
|
||||
int advice);
|
||||
int madvise_collapse(struct vm_area_struct *vma,
|
||||
struct vm_area_struct **prev,
|
||||
@@ -524,7 +524,7 @@ static inline unsigned long thp_vma_suitable_orders(struct vm_area_struct *vma,
|
||||
}
|
||||
|
||||
static inline unsigned long thp_vma_allowable_orders(struct vm_area_struct *vma,
|
||||
unsigned long vm_flags,
|
||||
vm_flags_t vm_flags,
|
||||
unsigned long tva_flags,
|
||||
unsigned long orders)
|
||||
{
|
||||
@@ -593,7 +593,7 @@ static inline bool unmap_huge_pmd_locked(struct vm_area_struct *vma,
|
||||
do { } while (0)
|
||||
|
||||
static inline int hugepage_madvise(struct vm_area_struct *vma,
|
||||
unsigned long *vm_flags, int advice)
|
||||
vm_flags_t *vm_flags, int advice)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ extern int start_stop_khugepaged(void);
|
||||
extern void __khugepaged_enter(struct mm_struct *mm);
|
||||
extern void __khugepaged_exit(struct mm_struct *mm);
|
||||
extern void khugepaged_enter_vma(struct vm_area_struct *vma,
|
||||
unsigned long vm_flags);
|
||||
vm_flags_t vm_flags);
|
||||
extern void khugepaged_min_free_kbytes_update(void);
|
||||
extern bool current_is_khugepaged(void);
|
||||
extern int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr,
|
||||
@@ -37,7 +37,7 @@ static inline void khugepaged_exit(struct mm_struct *mm)
|
||||
{
|
||||
}
|
||||
static inline void khugepaged_enter_vma(struct vm_area_struct *vma,
|
||||
unsigned long vm_flags)
|
||||
vm_flags_t vm_flags)
|
||||
{
|
||||
}
|
||||
static inline int collapse_pte_mapped_thp(struct mm_struct *mm,
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
#ifdef CONFIG_KSM
|
||||
int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
|
||||
unsigned long end, int advice, unsigned long *vm_flags);
|
||||
unsigned long end, int advice, vm_flags_t *vm_flags);
|
||||
vm_flags_t ksm_vma_flags(const struct mm_struct *mm, const struct file *file,
|
||||
vm_flags_t vm_flags);
|
||||
int ksm_enable_merge_any(struct mm_struct *mm);
|
||||
@@ -133,7 +133,7 @@ static inline void collect_procs_ksm(const struct folio *folio,
|
||||
|
||||
#ifdef CONFIG_MMU
|
||||
static inline int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
|
||||
unsigned long end, int advice, unsigned long *vm_flags)
|
||||
unsigned long end, int advice, vm_flags_t *vm_flags)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx);
|
||||
* We also update VMA flags if appropriate by manipulating the VMA flags pointed
|
||||
* to by vm_flags_ptr.
|
||||
*/
|
||||
int memfd_check_seals_mmap(struct file *file, unsigned long *vm_flags_ptr);
|
||||
int memfd_check_seals_mmap(struct file *file, vm_flags_t *vm_flags_ptr);
|
||||
#else
|
||||
static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a)
|
||||
{
|
||||
@@ -25,7 +25,7 @@ static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
static inline int memfd_check_seals_mmap(struct file *file,
|
||||
unsigned long *vm_flags_ptr)
|
||||
vm_flags_t *vm_flags_ptr)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
+3
-3
@@ -2564,7 +2564,7 @@ extern long change_protection(struct mmu_gather *tlb,
|
||||
unsigned long end, unsigned long cp_flags);
|
||||
extern int mprotect_fixup(struct vma_iterator *vmi, struct mmu_gather *tlb,
|
||||
struct vm_area_struct *vma, struct vm_area_struct **pprev,
|
||||
unsigned long start, unsigned long end, unsigned long newflags);
|
||||
unsigned long start, unsigned long end, vm_flags_t newflags);
|
||||
|
||||
/*
|
||||
* doesn't attempt to fault and will return short.
|
||||
@@ -3323,9 +3323,9 @@ extern void vm_stat_account(struct mm_struct *, vm_flags_t, long npages);
|
||||
|
||||
extern bool vma_is_special_mapping(const struct vm_area_struct *vma,
|
||||
const struct vm_special_mapping *sm);
|
||||
extern struct vm_area_struct *_install_special_mapping(struct mm_struct *mm,
|
||||
struct vm_area_struct *_install_special_mapping(struct mm_struct *mm,
|
||||
unsigned long addr, unsigned long len,
|
||||
unsigned long flags,
|
||||
vm_flags_t vm_flags,
|
||||
const struct vm_special_mapping *spec);
|
||||
|
||||
unsigned long randomize_stack_top(unsigned long stack_top);
|
||||
|
||||
@@ -1081,7 +1081,7 @@ struct mm_struct {
|
||||
unsigned long data_vm; /* VM_WRITE & ~VM_SHARED & ~VM_STACK */
|
||||
unsigned long exec_vm; /* VM_EXEC & ~VM_WRITE & ~VM_STACK */
|
||||
unsigned long stack_vm; /* VM_STACK */
|
||||
unsigned long def_flags;
|
||||
vm_flags_t def_flags;
|
||||
|
||||
/**
|
||||
* @write_protect_seq: Locked when any thread is write
|
||||
|
||||
@@ -137,7 +137,7 @@ static inline bool arch_validate_flags(unsigned long flags)
|
||||
/*
|
||||
* Combine the mmap "prot" argument into "vm_flags" used internally.
|
||||
*/
|
||||
static inline unsigned long
|
||||
static inline vm_flags_t
|
||||
calc_vm_prot_bits(unsigned long prot, unsigned long pkey)
|
||||
{
|
||||
return _calc_vm_trans(prot, PROT_READ, VM_READ ) |
|
||||
@@ -149,7 +149,7 @@ calc_vm_prot_bits(unsigned long prot, unsigned long pkey)
|
||||
/*
|
||||
* Combine the mmap "flags" argument into "vm_flags" used internally.
|
||||
*/
|
||||
static inline unsigned long
|
||||
static inline vm_flags_t
|
||||
calc_vm_flag_bits(struct file *file, unsigned long flags)
|
||||
{
|
||||
return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) |
|
||||
|
||||
@@ -893,7 +893,7 @@ static inline int folio_try_share_anon_rmap_pmd(struct folio *folio,
|
||||
* Called from mm/vmscan.c to handle paging out
|
||||
*/
|
||||
int folio_referenced(struct folio *, int is_locked,
|
||||
struct mem_cgroup *memcg, unsigned long *vm_flags);
|
||||
struct mem_cgroup *memcg, vm_flags_t *vm_flags);
|
||||
|
||||
void try_to_migrate(struct folio *folio, enum ttu_flags flags);
|
||||
void try_to_unmap(struct folio *, enum ttu_flags flags);
|
||||
@@ -1025,7 +1025,7 @@ struct anon_vma *folio_lock_anon_vma_read(const struct folio *folio,
|
||||
|
||||
static inline int folio_referenced(struct folio *folio, int is_locked,
|
||||
struct mem_cgroup *memcg,
|
||||
unsigned long *vm_flags)
|
||||
vm_flags_t *vm_flags)
|
||||
{
|
||||
*vm_flags = 0;
|
||||
return 0;
|
||||
|
||||
@@ -209,7 +209,7 @@ static inline bool userfaultfd_armed(struct vm_area_struct *vma)
|
||||
}
|
||||
|
||||
static inline bool vma_can_userfault(struct vm_area_struct *vma,
|
||||
unsigned long vm_flags,
|
||||
vm_flags_t vm_flags,
|
||||
bool wp_async)
|
||||
{
|
||||
vm_flags &= __VM_UFFD_FLAGS;
|
||||
@@ -281,7 +281,7 @@ struct vm_area_struct *userfaultfd_clear_vma(struct vma_iterator *vmi,
|
||||
|
||||
int userfaultfd_register_range(struct userfaultfd_ctx *ctx,
|
||||
struct vm_area_struct *vma,
|
||||
unsigned long vm_flags,
|
||||
vm_flags_t vm_flags,
|
||||
unsigned long start, unsigned long end,
|
||||
bool wp_async);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ DECLARE_EVENT_CLASS(dax_pmd_fault_class,
|
||||
__field(unsigned long, ino)
|
||||
__field(unsigned long, vm_start)
|
||||
__field(unsigned long, vm_end)
|
||||
__field(unsigned long, vm_flags)
|
||||
__field(vm_flags_t, vm_flags)
|
||||
__field(unsigned long, address)
|
||||
__field(pgoff_t, pgoff)
|
||||
__field(pgoff_t, max_pgoff)
|
||||
@@ -67,7 +67,7 @@ DECLARE_EVENT_CLASS(dax_pmd_load_hole_class,
|
||||
TP_ARGS(inode, vmf, zero_folio, radix_entry),
|
||||
TP_STRUCT__entry(
|
||||
__field(unsigned long, ino)
|
||||
__field(unsigned long, vm_flags)
|
||||
__field(vm_flags_t, vm_flags)
|
||||
__field(unsigned long, address)
|
||||
__field(struct folio *, zero_folio)
|
||||
__field(void *, radix_entry)
|
||||
@@ -107,7 +107,7 @@ DECLARE_EVENT_CLASS(dax_pte_fault_class,
|
||||
TP_ARGS(inode, vmf, result),
|
||||
TP_STRUCT__entry(
|
||||
__field(unsigned long, ino)
|
||||
__field(unsigned long, vm_flags)
|
||||
__field(vm_flags_t, vm_flags)
|
||||
__field(unsigned long, address)
|
||||
__field(pgoff_t, pgoff)
|
||||
__field(dev_t, dev)
|
||||
|
||||
+1
-1
@@ -290,7 +290,7 @@ void dump_vmg(const struct vma_merge_struct *vmg, const char *reason)
|
||||
vmg->vmi, vmg->vmi ? vma_iter_addr(vmg->vmi) : 0,
|
||||
vmg->vmi ? vma_iter_end(vmg->vmi) : 0,
|
||||
vmg->prev, vmg->middle, vmg->next, vmg->target,
|
||||
vmg->start, vmg->end, vmg->flags,
|
||||
vmg->start, vmg->end, vmg->vm_flags,
|
||||
vmg->file, vmg->anon_vma, vmg->policy,
|
||||
#ifdef CONFIG_USERFAULTFD
|
||||
vmg->uffd_ctx.ctx,
|
||||
|
||||
+4
-4
@@ -26,7 +26,7 @@ static struct execmem_info default_execmem_info __ro_after_init;
|
||||
|
||||
#ifdef CONFIG_MMU
|
||||
static void *execmem_vmalloc(struct execmem_range *range, size_t size,
|
||||
pgprot_t pgprot, unsigned long vm_flags)
|
||||
pgprot_t pgprot, vm_flags_t vm_flags)
|
||||
{
|
||||
bool kasan = range->flags & EXECMEM_KASAN_SHADOW;
|
||||
gfp_t gfp_flags = GFP_KERNEL | __GFP_NOWARN;
|
||||
@@ -82,7 +82,7 @@ struct vm_struct *execmem_vmap(size_t size)
|
||||
}
|
||||
#else
|
||||
static void *execmem_vmalloc(struct execmem_range *range, size_t size,
|
||||
pgprot_t pgprot, unsigned long vm_flags)
|
||||
pgprot_t pgprot, vm_flags_t vm_flags)
|
||||
{
|
||||
return vmalloc(size);
|
||||
}
|
||||
@@ -256,7 +256,7 @@ out_unlock:
|
||||
|
||||
static int execmem_cache_populate(struct execmem_range *range, size_t size)
|
||||
{
|
||||
unsigned long vm_flags = VM_ALLOW_HUGE_VMAP;
|
||||
vm_flags_t vm_flags = VM_ALLOW_HUGE_VMAP;
|
||||
struct vm_struct *vm;
|
||||
size_t alloc_size;
|
||||
int err = -ENOMEM;
|
||||
@@ -373,7 +373,7 @@ void *execmem_alloc(enum execmem_type type, size_t size)
|
||||
{
|
||||
struct execmem_range *range = &execmem_info->ranges[type];
|
||||
bool use_cache = range->flags & EXECMEM_ROX_CACHE;
|
||||
unsigned long vm_flags = VM_FLUSH_RESET_PERMS;
|
||||
vm_flags_t vm_flags = VM_FLUSH_RESET_PERMS;
|
||||
pgprot_t pgprot = range->pgprot;
|
||||
void *p;
|
||||
|
||||
|
||||
+1
-1
@@ -3216,7 +3216,7 @@ static struct file *do_sync_mmap_readahead(struct vm_fault *vmf)
|
||||
struct address_space *mapping = file->f_mapping;
|
||||
DEFINE_READAHEAD(ractl, file, ra, mapping, vmf->pgoff);
|
||||
struct file *fpin = NULL;
|
||||
unsigned long vm_flags = vmf->vma->vm_flags;
|
||||
vm_flags_t vm_flags = vmf->vma->vm_flags;
|
||||
unsigned short mmap_miss;
|
||||
|
||||
#ifdef CONFIG_TRANSPARENT_HUGEPAGE
|
||||
|
||||
@@ -2044,7 +2044,7 @@ static long __get_user_pages_locked(struct mm_struct *mm, unsigned long start,
|
||||
{
|
||||
struct vm_area_struct *vma;
|
||||
bool must_unlock = false;
|
||||
unsigned long vm_flags;
|
||||
vm_flags_t vm_flags;
|
||||
long i;
|
||||
|
||||
if (!nr_pages)
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ static inline bool file_thp_enabled(struct vm_area_struct *vma)
|
||||
}
|
||||
|
||||
unsigned long __thp_vma_allowable_orders(struct vm_area_struct *vma,
|
||||
unsigned long vm_flags,
|
||||
vm_flags_t vm_flags,
|
||||
unsigned long tva_flags,
|
||||
unsigned long orders)
|
||||
{
|
||||
|
||||
+2
-2
@@ -7465,8 +7465,8 @@ static unsigned long page_table_shareable(struct vm_area_struct *svma,
|
||||
unsigned long s_end = sbase + PUD_SIZE;
|
||||
|
||||
/* Allow segments to share if only one is marked locked */
|
||||
unsigned long vm_flags = vma->vm_flags & ~VM_LOCKED_MASK;
|
||||
unsigned long svm_flags = svma->vm_flags & ~VM_LOCKED_MASK;
|
||||
vm_flags_t vm_flags = vma->vm_flags & ~VM_LOCKED_MASK;
|
||||
vm_flags_t svm_flags = svma->vm_flags & ~VM_LOCKED_MASK;
|
||||
|
||||
/*
|
||||
* match the virtual addresses, permission and the alignment of the
|
||||
|
||||
+2
-2
@@ -928,7 +928,7 @@ 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, unsigned long flags,
|
||||
extern bool mlock_future_ok(struct mm_struct *mm, vm_flags_t vm_flags,
|
||||
unsigned long bytes);
|
||||
|
||||
/*
|
||||
@@ -1358,7 +1358,7 @@ int migrate_device_coherent_folio(struct folio *folio);
|
||||
|
||||
struct vm_struct *__get_vm_area_node(unsigned long size,
|
||||
unsigned long align, unsigned long shift,
|
||||
unsigned long flags, unsigned long start,
|
||||
vm_flags_t vm_flags, unsigned long start,
|
||||
unsigned long end, int node, gfp_t gfp_mask,
|
||||
const void *caller);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user