]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm: update architecture and driver code to use vm_flags_t
authorLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Wed, 18 Jun 2025 19:42:54 +0000 (20:42 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 10 Jul 2025 05:42:14 +0000 (22:42 -0700)
In future we intend to change the vm_flags_t type, so it isn't correct for
architecture and driver code to assume it is unsigned long.  Correct this
assumption across the board.

Overall, this patch does not introduce any functional change.

Link: https://lkml.kernel.org/r/b6eb1894abc5555ece80bb08af5c022ef780c8bc.1750274467.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Acked-by: Christian Brauner <brauner@kernel.org>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Acked-by: Catalin Marinas <catalin.marinas@arm.com> [arm64]
Acked-by: Zi Yan <ziy@nvidia.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>
Cc: Jann Horn <jannh@google.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Liam R. Howlett <Liam.Howlett@oracle.com>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/arm/mm/fault.c
arch/arm64/include/asm/mman.h
arch/arm64/mm/fault.c
arch/arm64/mm/mmu.c
arch/powerpc/include/asm/mman.h
arch/powerpc/include/asm/pkeys.h
arch/powerpc/kvm/book3s_hv_uvmem.c
arch/sparc/include/asm/mman.h
arch/x86/kernel/cpu/sgx/encl.c
arch/x86/kernel/cpu/sgx/encl.h
tools/testing/vma/vma_internal.h

index ab01b51de5590bff6c2acaf446d01c589a5f7987..46169fe42c612152b38c029cd8b945fc113ff3e2 100644 (file)
@@ -268,7 +268,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
        int sig, code;
        vm_fault_t fault;
        unsigned int flags = FAULT_FLAG_DEFAULT;
-       unsigned long vm_flags = VM_ACCESS_FLAGS;
+       vm_flags_t vm_flags = VM_ACCESS_FLAGS;
 
        if (kprobe_page_fault(regs, fsr))
                return 0;
index 21df8bbd2668a2febd7abc6a7f98f2c5bbe1ebde..8770c7ee759f372400a1a617bb7b39c428bc3364 100644 (file)
 #include <linux/shmem_fs.h>
 #include <linux/types.h>
 
-static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
+static inline vm_flags_t arch_calc_vm_prot_bits(unsigned long prot,
        unsigned long pkey)
 {
-       unsigned long ret = 0;
+       vm_flags_t ret = 0;
 
        if (system_supports_bti() && (prot & PROT_BTI))
                ret |= VM_ARM64_BTI;
@@ -34,8 +34,8 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
 }
 #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
 
-static inline unsigned long arch_calc_vm_flag_bits(struct file *file,
-                                                  unsigned long flags)
+static inline vm_flags_t arch_calc_vm_flag_bits(struct file *file,
+                                               unsigned long flags)
 {
        /*
         * Only allow MTE on anonymous mappings as these are guaranteed to be
@@ -68,7 +68,7 @@ static inline bool arch_validate_prot(unsigned long prot,
 }
 #define arch_validate_prot(prot, addr) arch_validate_prot(prot, addr)
 
-static inline bool arch_validate_flags(unsigned long vm_flags)
+static inline bool arch_validate_flags(vm_flags_t vm_flags)
 {
        if (system_supports_mte()) {
                /*
index ec0a337891ddfc705238fe07444c085f0d48aa5c..24be3e632f797eb82a1bd4705a007e47fc2c9ad5 100644 (file)
@@ -549,7 +549,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
        const struct fault_info *inf;
        struct mm_struct *mm = current->mm;
        vm_fault_t fault;
-       unsigned long vm_flags;
+       vm_flags_t vm_flags;
        unsigned int mm_flags = FAULT_FLAG_DEFAULT;
        unsigned long addr = untagged_addr(far);
        struct vm_area_struct *vma;
index 00ab1d648db62b4523584fdda11a3e82a8eac634..3d5fb37424ab062426323ddc8e503728b499b074 100644 (file)
@@ -720,7 +720,7 @@ void mark_rodata_ro(void)
 
 static void __init declare_vma(struct vm_struct *vma,
                               void *va_start, void *va_end,
-                              unsigned long vm_flags)
+                              vm_flags_t vm_flags)
 {
        phys_addr_t pa_start = __pa_symbol(va_start);
        unsigned long size = va_end - va_start;
index 42a51a993d942dc2e279c35fa49207a3e57937f1..912f78a956a187a0686e7ac935e11a602ca64f6b 100644 (file)
@@ -14,7 +14,7 @@
 #include <asm/cpu_has_feature.h>
 #include <asm/firmware.h>
 
-static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
+static inline vm_flags_t arch_calc_vm_prot_bits(unsigned long prot,
                unsigned long pkey)
 {
 #ifdef CONFIG_PPC_MEM_KEYS
index 59a2c7dbc78fbf3ebf58f79507fb7710a2337b2e..28e752138996e06b52257e70bc86d0648d473d42 100644 (file)
@@ -30,9 +30,9 @@ extern u32 reserved_allocation_mask; /* bits set for reserved keys */
 #endif
 
 
-static inline u64 pkey_to_vmflag_bits(u16 pkey)
+static inline vm_flags_t pkey_to_vmflag_bits(u16 pkey)
 {
-       return (((u64)pkey << VM_PKEY_SHIFT) & ARCH_VM_PKEY_FLAGS);
+       return (((vm_flags_t)pkey << VM_PKEY_SHIFT) & ARCH_VM_PKEY_FLAGS);
 }
 
 static inline int vma_pkey(struct vm_area_struct *vma)
index 3a6592a31a10a4bc7a61ab3e93aec2dcb64bdbbe..03f8c34fa0a2066918ec5b332a075c8ffd8a56f7 100644 (file)
@@ -393,7 +393,7 @@ static int kvmppc_memslot_page_merge(struct kvm *kvm,
 {
        unsigned long gfn = memslot->base_gfn;
        unsigned long end, start = gfn_to_hva(kvm, gfn);
-       unsigned long vm_flags;
+       vm_flags_t vm_flags;
        int ret = 0;
        struct vm_area_struct *vma;
        int merge_flag = (merge) ? MADV_MERGEABLE : MADV_UNMERGEABLE;
index af9c10c83dc58b654a00e2c98ad716ba89e261e6..3e4bac33be81183d0880dd5f30a17ee1475eb152 100644 (file)
@@ -28,7 +28,7 @@ static inline void ipi_set_tstate_mcde(void *arg)
 }
 
 #define arch_calc_vm_prot_bits(prot, pkey) sparc_calc_vm_prot_bits(prot)
-static inline unsigned long sparc_calc_vm_prot_bits(unsigned long prot)
+static inline vm_flags_t sparc_calc_vm_prot_bits(unsigned long prot)
 {
        if (adi_capable() && (prot & PROT_ADI)) {
                struct pt_regs *regs;
@@ -58,7 +58,7 @@ static inline int sparc_validate_prot(unsigned long prot, unsigned long addr)
 /* arch_validate_flags() - Ensure combination of flags is valid for a
  *     VMA.
  */
-static inline bool arch_validate_flags(unsigned long vm_flags)
+static inline bool arch_validate_flags(vm_flags_t vm_flags)
 {
        /* If ADI is being enabled on this VMA, check for ADI
         * capability on the platform and ensure VMA is suitable
index 279148e7245965dc59198fa3c2705b26aff23f92..308dbbae6c6e52014ba7c3290203d9cd7fe82aa7 100644 (file)
@@ -279,7 +279,7 @@ static struct sgx_encl_page *__sgx_encl_load_page(struct sgx_encl *encl,
 
 static struct sgx_encl_page *sgx_encl_load_page_in_vma(struct sgx_encl *encl,
                                                       unsigned long addr,
-                                                      unsigned long vm_flags)
+                                                      vm_flags_t vm_flags)
 {
        unsigned long vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
        struct sgx_encl_page *entry;
@@ -520,9 +520,9 @@ static void sgx_vma_open(struct vm_area_struct *vma)
  * Return: 0 on success, -EACCES otherwise
  */
 int sgx_encl_may_map(struct sgx_encl *encl, unsigned long start,
-                    unsigned long end, unsigned long vm_flags)
+                    unsigned long end, vm_flags_t vm_flags)
 {
-       unsigned long vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
+       vm_flags_t vm_prot_bits = vm_flags & VM_ACCESS_FLAGS;
        struct sgx_encl_page *page;
        unsigned long count = 0;
        int ret = 0;
@@ -605,7 +605,7 @@ static int sgx_encl_debug_write(struct sgx_encl *encl, struct sgx_encl_page *pag
  */
 static struct sgx_encl_page *sgx_encl_reserve_page(struct sgx_encl *encl,
                                                   unsigned long addr,
-                                                  unsigned long vm_flags)
+                                                  vm_flags_t vm_flags)
 {
        struct sgx_encl_page *entry;
 
index f94ff14c948698140a1fa84e5efd0d2905ac7951..8ff47f6652b9b84dcfb3bed96b7d320585b26551 100644 (file)
@@ -101,7 +101,7 @@ static inline int sgx_encl_find(struct mm_struct *mm, unsigned long addr,
 }
 
 int sgx_encl_may_map(struct sgx_encl *encl, unsigned long start,
-                    unsigned long end, unsigned long vm_flags);
+                    unsigned long end, vm_flags_t vm_flags);
 
 bool current_is_ksgxd(void);
 void sgx_encl_release(struct kref *ref);
index f684649b1008479b125cad996b81fe68bb3bb6db..991022e9e0d3bd32adcd8cc1bf937f560a288068 100644 (file)
@@ -1215,7 +1215,7 @@ static inline void vma_set_page_prot(struct vm_area_struct *vma)
        WRITE_ONCE(vma->vm_page_prot, vm_page_prot);
 }
 
-static inline bool arch_validate_flags(unsigned long)
+static inline bool arch_validate_flags(vm_flags_t)
 {
        return true;
 }