Re: [PATCH 6.1.y v2 3/4] mm: refactor arch_calc_vm_flag_bits() and arm64 MTE handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Sasha,

On 19/11/24 10:06, Sasha Levin wrote:
[ Sasha's backport helper bot ]

Hi,

The upstream commit SHA1 provided is correct: 5baf8b037debf4ec60108ccfeccb8636d1dbad81


Nice bot!

Just few thoughts:

Commit in newer trees:

|-----------------|----------------------------------------------|
| 6.11.y          |  Present (different SHA1: 9f5efc1137ba)      |
| 6.6.y           |  Not found                                   |
| 6.1.y           |  Not found                                   |
|-----------------|----------------------------------------------|



Given that this patch is for 6.1.y, it(6.1.y) need not be considered as newer tree I think ?

Also the backport for 6.6.y is present on lore.stable [1], so the backport not being present in stable-6.6.y might be not very useful, as it is possible for people to send the backport to multiple trees in the same stable update cycle(before 6.6.y has the backport included) -- instead could we run this while queuing up(maybe warn if it is neither present in stable-queue-6.6 nor in stable-6.6.y ?) ?


[1] https://lore.kernel.org/all/7c0218d03fd2119025d8cbc1b814639cf09314e0.1731672733.git.lorenzo.stoakes@xxxxxxxxxx/

Thanks,
Harshit

Note: The patch differs from the upstream commit:
---
--- -	2024-11-18 17:15:02.588328592 -0500
+++ /tmp/tmp.LhvhUpwE7J	2024-11-18 17:15:02.577003940 -0500
@@ -50,29 +50,29 @@
  Cc: Will Deacon <will@xxxxxxxxxx>
  Cc: <stable@xxxxxxxxxxxxxxx>
  Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
+Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
  ---
- arch/arm64/include/asm/mman.h  | 10 +++++++---
- arch/parisc/include/asm/mman.h |  5 +++--
- include/linux/mman.h           |  7 ++++---
- mm/mmap.c                      |  2 +-
- mm/nommu.c                     |  2 +-
- mm/shmem.c                     |  3 ---
- 6 files changed, 16 insertions(+), 13 deletions(-)
+ arch/arm64/include/asm/mman.h | 10 +++++++---
+ include/linux/mman.h          |  7 ++++---
+ mm/mmap.c                     |  2 +-
+ mm/nommu.c                    |  2 +-
+ mm/shmem.c                    |  3 ---
+ 5 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/include/asm/mman.h b/arch/arm64/include/asm/mman.h
-index 9e39217b4afbb..798d965760d43 100644
+index 5966ee4a6154..ef35c52aabd6 100644
  --- a/arch/arm64/include/asm/mman.h
  +++ b/arch/arm64/include/asm/mman.h
-@@ -6,6 +6,8 @@
+@@ -3,6 +3,8 @@
+ #define __ASM_MMAN_H__
- #ifndef BUILD_VDSO
   #include <linux/compiler.h>
  +#include <linux/fs.h>
  +#include <linux/shmem_fs.h>
   #include <linux/types.h>
+ #include <uapi/asm/mman.h>
- static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
-@@ -31,19 +33,21 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
+@@ -21,19 +23,21 @@ 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)
@@ -97,37 +97,8 @@ static inline bool arch_validate_prot(unsigned long prot,
   	unsigned long addr __always_unused)
-diff --git a/arch/parisc/include/asm/mman.h b/arch/parisc/include/asm/mman.h
-index 89b6beeda0b86..663f587dc7896 100644
---- a/arch/parisc/include/asm/mman.h
-+++ b/arch/parisc/include/asm/mman.h
-@@ -2,6 +2,7 @@
- #ifndef __ASM_MMAN_H__
- #define __ASM_MMAN_H__
-
-+#include <linux/fs.h>
- #include <uapi/asm/mman.h>
-
- /* PARISC cannot allow mdwe as it needs writable stacks */
-@@ -11,7 +12,7 @@ static inline bool arch_memory_deny_write_exec_supported(void)
- }
- #define arch_memory_deny_write_exec_supported arch_memory_deny_write_exec_supported
-
--static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
-+static inline unsigned long arch_calc_vm_flag_bits(struct file *file, unsigned long flags)
- {
- 	/*
- 	 * The stack on parisc grows upwards, so if userspace requests memory
-@@ -23,6 +24,6 @@ static inline unsigned long arch_calc_vm_flag_bits(unsigned long flags)
-
- 	return 0;
- }
--#define arch_calc_vm_flag_bits(flags) arch_calc_vm_flag_bits(flags)
-+#define arch_calc_vm_flag_bits(file, flags) arch_calc_vm_flag_bits(file, flags)
-
- #endif /* __ASM_MMAN_H__ */
  diff --git a/include/linux/mman.h b/include/linux/mman.h
-index 8ddca62d6460b..a842783ffa62b 100644
+index 58b3abd457a3..21ea08b919d9 100644
  --- a/include/linux/mman.h
  +++ b/include/linux/mman.h
  @@ -2,6 +2,7 @@
@@ -138,7 +109,7 @@
   #include <linux/mm.h>
   #include <linux/percpu_counter.h>
-@@ -94,7 +95,7 @@ static inline void vm_unacct_memory(long pages)
+@@ -90,7 +91,7 @@ static inline void vm_unacct_memory(long pages)
   #endif
#ifndef arch_calc_vm_flag_bits
@@ -147,7 +118,7 @@
   #endif
#ifndef arch_validate_prot
-@@ -151,13 +152,13 @@ calc_vm_prot_bits(unsigned long prot, unsigned long pkey)
+@@ -147,12 +148,12 @@ calc_vm_prot_bits(unsigned long prot, unsigned long pkey)
    * Combine the mmap "flags" argument into "vm_flags" used internally.
    */
   static inline unsigned long
@@ -157,49 +128,51 @@
   	return _calc_vm_trans(flags, MAP_GROWSDOWN,  VM_GROWSDOWN ) |
   	       _calc_vm_trans(flags, MAP_LOCKED,     VM_LOCKED    ) |
   	       _calc_vm_trans(flags, MAP_SYNC,	     VM_SYNC      ) |
- 	       _calc_vm_trans(flags, MAP_STACK,	     VM_NOHUGEPAGE) |
  -	       arch_calc_vm_flag_bits(flags);
  +	       arch_calc_vm_flag_bits(file, flags);
   }
unsigned long vm_commit_limit(void);
  diff --git a/mm/mmap.c b/mm/mmap.c
-index ab71d4c3464cd..aee5fa08ae5d1 100644
+index 4bfec4df51c2..322677f61d30 100644
  --- a/mm/mmap.c
  +++ b/mm/mmap.c
-@@ -344,7 +344,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
+@@ -1316,7 +1316,7 @@ unsigned long do_mmap(struct file *file, unsigned long addr,
   	 * to. we assume access permissions have been handled by the open
   	 * of the memory object, so we don't do any here.
   	 */
--	vm_flags |= calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(flags) |
-+	vm_flags |= calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(file, flags) |
+-	vm_flags = calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(flags) |
++	vm_flags = calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(file, flags) |
   			mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
- /* Obtain the address to map to. we verify (or select) it and ensure
+ 	if (flags & MAP_LOCKED)
  diff --git a/mm/nommu.c b/mm/nommu.c
-index 635d028d647b3..e9b5f527ab5b4 100644
+index e0428fa57526..859ba6bdeb9c 100644
  --- a/mm/nommu.c
  +++ b/mm/nommu.c
-@@ -842,7 +842,7 @@ static unsigned long determine_vm_flags(struct file *file,
+@@ -903,7 +903,7 @@ static unsigned long determine_vm_flags(struct file *file,
   {
   	unsigned long vm_flags;
- vm_flags = calc_vm_prot_bits(prot, 0) | calc_vm_flag_bits(flags);
  +	vm_flags = calc_vm_prot_bits(prot, 0) | calc_vm_flag_bits(file, flags);
+ 	/* vm_flags |= mm->def_flags; */
- if (!file) {
- 		/*
+ 	if (!(capabilities & NOMMU_MAP_DIRECT)) {
  diff --git a/mm/shmem.c b/mm/shmem.c
-index 4ba1d00fabdaa..e87f5d6799a7b 100644
+index 0e1fbc53717d..d1a33f66cc7f 100644
  --- a/mm/shmem.c
  +++ b/mm/shmem.c
-@@ -2733,9 +2733,6 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
+@@ -2308,9 +2308,6 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
   	if (ret)
   		return ret;
- /* arm64 - allow memory tagging on RAM-based files */
--	vm_flags_set(vma, VM_MTE_ALLOWED);
+-	vma->vm_flags |= VM_MTE_ALLOWED;
  -
   	file_accessed(file);
- 	/* This is anonymous shared memory if it is unlinked at the time of mmap */
- 	if (inode->i_nlink)
+ 	vma->vm_ops = &shmem_vm_ops;
+ 	return 0;
+--
+2.47.0
+
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.1.y        |  Success    |  Success   |






[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux