Re: [PATCH 1/3] mm: Make arch_get_unmapped_area() take vm_flags by default

2024-09-03 Thread Helge Deller

On 9/2/24 21:08, Mark Brown wrote:

When we introduced arch_get_unmapped_area_vmflags() in 961148704acd
("mm: introduce arch_get_unmapped_area_vmflags()") we did so as part of
properly supporting guard pages for shadow stacks on x86_64, which uses
a custom arch_get_unmapped_area(). Equivalent features are also present
on both arm64 and RISC-V, both of which use the generic implementation
of arch_get_unmapped_area() and will require equivalent modification
there. Rather than continue to deal with having two versions of the
functions let's bite the bullet and have all implementations of
arch_get_unmapped_area() take vm_flags as a parameter.

The new parameter is currently ignored by all implementations other than
x86. The only caller that doesn't have a vm_flags available is
mm_get_unmapped_area(), as for the x86 implementation and the wrapper used
on other architectures this is modified to supply no flags.

No functional changes.

Signed-off-by: Mark Brown 
---
  arch/alpha/kernel/osf_sys.c   |  2 +-
  arch/arc/mm/mmap.c|  3 ++-
  arch/arm/mm/mmap.c|  7 ---
  arch/csky/abiv1/mmap.c|  3 ++-
  arch/loongarch/mm/mmap.c  |  5 +++--
  arch/mips/mm/mmap.c   |  2 +-
  arch/parisc/kernel/sys_parisc.c   |  5 +++--
  arch/parisc/mm/hugetlbpage.c  |  2 +-


Acked-by: Helge Deller   # parisc

Helge

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 1/3] mm: Make arch_get_unmapped_area() take vm_flags by default

2024-09-03 Thread Liam R. Howlett
* Mark Brown  [240902 15:09]:
> When we introduced arch_get_unmapped_area_vmflags() in 961148704acd
> ("mm: introduce arch_get_unmapped_area_vmflags()") we did so as part of
> properly supporting guard pages for shadow stacks on x86_64, which uses
> a custom arch_get_unmapped_area(). Equivalent features are also present
> on both arm64 and RISC-V, both of which use the generic implementation
> of arch_get_unmapped_area() and will require equivalent modification
> there. Rather than continue to deal with having two versions of the
> functions let's bite the bullet and have all implementations of
> arch_get_unmapped_area() take vm_flags as a parameter.
> 
> The new parameter is currently ignored by all implementations other than
> x86. The only caller that doesn't have a vm_flags available is
> mm_get_unmapped_area(), as for the x86 implementation and the wrapper used
> on other architectures this is modified to supply no flags.
> 
> No functional changes.
> 
> Signed-off-by: Mark Brown 

I don't love sparc32/sparc64 requires a wide screen monitor, but it
already broke the 80 char limit.

Reviewed-by: Liam R. Howlett 

> ---
>  arch/alpha/kernel/osf_sys.c   |  2 +-
>  arch/arc/mm/mmap.c|  3 ++-
>  arch/arm/mm/mmap.c|  7 ---
>  arch/csky/abiv1/mmap.c|  3 ++-
>  arch/loongarch/mm/mmap.c  |  5 +++--
>  arch/mips/mm/mmap.c   |  2 +-
>  arch/parisc/kernel/sys_parisc.c   |  5 +++--
>  arch/parisc/mm/hugetlbpage.c  |  2 +-
>  arch/powerpc/mm/book3s64/slice.c  |  6 --
>  arch/s390/mm/mmap.c   |  4 ++--
>  arch/sh/mm/mmap.c |  5 +++--
>  arch/sparc/kernel/sys_sparc_32.c  |  2 +-
>  arch/sparc/kernel/sys_sparc_64.c  |  4 ++--
>  arch/x86/include/asm/pgtable_64.h |  1 -
>  arch/x86/kernel/sys_x86_64.c  | 21 +++--
>  arch/xtensa/kernel/syscall.c  |  3 ++-
>  include/linux/sched/mm.h  | 23 ---
>  mm/mmap.c | 31 +++
>  18 files changed, 49 insertions(+), 80 deletions(-)
> 
> diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
> index e5f881bc8288..8886ab539273 100644
> --- a/arch/alpha/kernel/osf_sys.c
> +++ b/arch/alpha/kernel/osf_sys.c
> @@ -1229,7 +1229,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned 
> long len,
>  unsigned long
>  arch_get_unmapped_area(struct file *filp, unsigned long addr,
>  unsigned long len, unsigned long pgoff,
> -unsigned long flags)
> +unsigned long flags, vm_flags_t vm_flags)
>  {
>   unsigned long limit;
>  
> diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c
> index 69a915297155..2185afe8d59f 100644
> --- a/arch/arc/mm/mmap.c
> +++ b/arch/arc/mm/mmap.c
> @@ -23,7 +23,8 @@
>   */
>  unsigned long
>  arch_get_unmapped_area(struct file *filp, unsigned long addr,
> - unsigned long len, unsigned long pgoff, unsigned long flags)
> + unsigned long len, unsigned long pgoff,
> + unsigned long flags, vm_flags_t vm_flags)
>  {
>   struct mm_struct *mm = current->mm;
>   struct vm_area_struct *vma;
> diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
> index d65d0e6ed10a..3dbb383c26d5 100644
> --- a/arch/arm/mm/mmap.c
> +++ b/arch/arm/mm/mmap.c
> @@ -28,7 +28,8 @@
>   */
>  unsigned long
>  arch_get_unmapped_area(struct file *filp, unsigned long addr,
> - unsigned long len, unsigned long pgoff, unsigned long flags)
> + unsigned long len, unsigned long pgoff,
> + unsigned long flags, vm_flags_t vm_flags)
>  {
>   struct mm_struct *mm = current->mm;
>   struct vm_area_struct *vma;
> @@ -78,8 +79,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long 
> addr,
>  
>  unsigned long
>  arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
> - const unsigned long len, const unsigned long pgoff,
> - const unsigned long flags)
> + const unsigned long len, const unsigned long pgoff,
> + const unsigned long flags, vm_flags_t vm_flags)
>  {
>   struct vm_area_struct *vma;
>   struct mm_struct *mm = current->mm;
> diff --git a/arch/csky/abiv1/mmap.c b/arch/csky/abiv1/mmap.c
> index 7f826331d409..1047865e82a9 100644
> --- a/arch/csky/abiv1/mmap.c
> +++ b/arch/csky/abiv1/mmap.c
> @@ -23,7 +23,8 @@
>   */
>  unsigned long
>  arch_get_unmapped_area(struct file *filp, unsigned long addr,
> - unsigned long len, unsigned long pgoff, unsigned long flags)
> + unsigned long len, unsigned long pgoff,
> + unsigned long flags, vm_flags_t vm_flags)
>  {
>   struct mm_struct *mm = current->mm;
>   struct vm_area_struct *vma;
> diff --git a/arch/loongarch/mm/mmap.c b/arch/loongarch/mm/mmap.c
> index 889030985135..914e82ff3f65 100644
> --- a/arch/loongarch/mm/mmap.c
> +++ b/arch/lo

Re: [PATCH 1/3] mm: Make arch_get_unmapped_area() take vm_flags by default

2024-09-03 Thread Lorenzo Stoakes
On Mon, Sep 02, 2024 at 08:08:13PM GMT, Mark Brown wrote:
> When we introduced arch_get_unmapped_area_vmflags() in 961148704acd
> ("mm: introduce arch_get_unmapped_area_vmflags()") we did so as part of
> properly supporting guard pages for shadow stacks on x86_64, which uses
> a custom arch_get_unmapped_area(). Equivalent features are also present
> on both arm64 and RISC-V, both of which use the generic implementation
> of arch_get_unmapped_area() and will require equivalent modification
> there. Rather than continue to deal with having two versions of the
> functions let's bite the bullet and have all implementations of
> arch_get_unmapped_area() take vm_flags as a parameter.
>
> The new parameter is currently ignored by all implementations other than
> x86. The only caller that doesn't have a vm_flags available is
> mm_get_unmapped_area(), as for the x86 implementation and the wrapper used
> on other architectures this is modified to supply no flags.
>
> No functional changes.
>
> Signed-off-by: Mark Brown 

mm/mmap.c bit looks reasonable to me! Nice cleanup! :)

Acked-by: Lorenzo Stoakes  (for mm/mmap.c part)

> ---
>  arch/alpha/kernel/osf_sys.c   |  2 +-
>  arch/arc/mm/mmap.c|  3 ++-
>  arch/arm/mm/mmap.c|  7 ---
>  arch/csky/abiv1/mmap.c|  3 ++-
>  arch/loongarch/mm/mmap.c  |  5 +++--
>  arch/mips/mm/mmap.c   |  2 +-
>  arch/parisc/kernel/sys_parisc.c   |  5 +++--
>  arch/parisc/mm/hugetlbpage.c  |  2 +-
>  arch/powerpc/mm/book3s64/slice.c  |  6 --
>  arch/s390/mm/mmap.c   |  4 ++--
>  arch/sh/mm/mmap.c |  5 +++--
>  arch/sparc/kernel/sys_sparc_32.c  |  2 +-
>  arch/sparc/kernel/sys_sparc_64.c  |  4 ++--
>  arch/x86/include/asm/pgtable_64.h |  1 -
>  arch/x86/kernel/sys_x86_64.c  | 21 +++--
>  arch/xtensa/kernel/syscall.c  |  3 ++-
>  include/linux/sched/mm.h  | 23 ---
>  mm/mmap.c | 31 +++
>  18 files changed, 49 insertions(+), 80 deletions(-)
>
> diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
> index e5f881bc8288..8886ab539273 100644
> --- a/arch/alpha/kernel/osf_sys.c
> +++ b/arch/alpha/kernel/osf_sys.c
> @@ -1229,7 +1229,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned 
> long len,
>  unsigned long
>  arch_get_unmapped_area(struct file *filp, unsigned long addr,
>  unsigned long len, unsigned long pgoff,
> -unsigned long flags)
> +unsigned long flags, vm_flags_t vm_flags)
>  {
>   unsigned long limit;
>
> diff --git a/arch/arc/mm/mmap.c b/arch/arc/mm/mmap.c
> index 69a915297155..2185afe8d59f 100644
> --- a/arch/arc/mm/mmap.c
> +++ b/arch/arc/mm/mmap.c
> @@ -23,7 +23,8 @@
>   */
>  unsigned long
>  arch_get_unmapped_area(struct file *filp, unsigned long addr,
> - unsigned long len, unsigned long pgoff, unsigned long flags)
> + unsigned long len, unsigned long pgoff,
> + unsigned long flags, vm_flags_t vm_flags)
>  {
>   struct mm_struct *mm = current->mm;
>   struct vm_area_struct *vma;
> diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
> index d65d0e6ed10a..3dbb383c26d5 100644
> --- a/arch/arm/mm/mmap.c
> +++ b/arch/arm/mm/mmap.c
> @@ -28,7 +28,8 @@
>   */
>  unsigned long
>  arch_get_unmapped_area(struct file *filp, unsigned long addr,
> - unsigned long len, unsigned long pgoff, unsigned long flags)
> + unsigned long len, unsigned long pgoff,
> + unsigned long flags, vm_flags_t vm_flags)
>  {
>   struct mm_struct *mm = current->mm;
>   struct vm_area_struct *vma;
> @@ -78,8 +79,8 @@ arch_get_unmapped_area(struct file *filp, unsigned long 
> addr,
>
>  unsigned long
>  arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
> - const unsigned long len, const unsigned long pgoff,
> - const unsigned long flags)
> + const unsigned long len, const unsigned long pgoff,
> + const unsigned long flags, vm_flags_t vm_flags)
>  {
>   struct vm_area_struct *vma;
>   struct mm_struct *mm = current->mm;
> diff --git a/arch/csky/abiv1/mmap.c b/arch/csky/abiv1/mmap.c
> index 7f826331d409..1047865e82a9 100644
> --- a/arch/csky/abiv1/mmap.c
> +++ b/arch/csky/abiv1/mmap.c
> @@ -23,7 +23,8 @@
>   */
>  unsigned long
>  arch_get_unmapped_area(struct file *filp, unsigned long addr,
> - unsigned long len, unsigned long pgoff, unsigned long flags)
> + unsigned long len, unsigned long pgoff,
> + unsigned long flags, vm_flags_t vm_flags)
>  {
>   struct mm_struct *mm = current->mm;
>   struct vm_area_struct *vma;
> diff --git a/arch/loongarch/mm/mmap.c b/arch/loongarch/mm/mmap.c
> index 889030985135..914e82ff3f65 100644
> --- a/arch/loongarch/mm/mmap.c
> +++ b/arch/loongarch/