[PATCHv3,06/11] asm-generic: mm_hooks: allow hooks to be overridden individually

Message ID 20180417183735.56985-7-mark.rutland@arm.com
State New
Headers show
Series
  • ARMv8.3 pointer authentication userspace support
Related show

Commit Message

Mark Rutland April 17, 2018, 6:37 p.m.
Currently, an architecture must either implement all of the mm hooks
itself, or use all of those provided by the asm-generic implementation.
When an architecture only needs to override a single hook, it must copy
the stub implementations from the asm-generic version.

To avoid this repetition, allow each hook to be overridden indiviually,
by placing each under an #ifndef block. As architectures providing their
own hooks can't include this file today, this shouldn't adversely affect
any existing hooks.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch@vger.kernel.org
---
 include/asm-generic/mm_hooks.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

-- 
2.11.0

Comments

Arnd Bergmann April 17, 2018, 7:56 p.m. | #1
On Tue, Apr 17, 2018 at 8:37 PM, Mark Rutland <mark.rutland@arm.com> wrote:
> Currently, an architecture must either implement all of the mm hooks

> itself, or use all of those provided by the asm-generic implementation.

> When an architecture only needs to override a single hook, it must copy

> the stub implementations from the asm-generic version.

>

> To avoid this repetition, allow each hook to be overridden indiviually,

> by placing each under an #ifndef block. As architectures providing their

> own hooks can't include this file today, this shouldn't adversely affect

> any existing hooks.

>

> Signed-off-by: Mark Rutland <mark.rutland@arm.com>

> Cc: Arnd Bergmann <arnd@arndb.de>

> Cc: linux-arch@vger.kernel.org


Acked-by: Arnd Bergmann <arnd@arndb.de>
Mark Rutland April 18, 2018, 11:38 a.m. | #2
On Tue, Apr 17, 2018 at 09:56:02PM +0200, Arnd Bergmann wrote:
> On Tue, Apr 17, 2018 at 8:37 PM, Mark Rutland <mark.rutland@arm.com> wrote:

> > Currently, an architecture must either implement all of the mm hooks

> > itself, or use all of those provided by the asm-generic implementation.

> > When an architecture only needs to override a single hook, it must copy

> > the stub implementations from the asm-generic version.

> >

> > To avoid this repetition, allow each hook to be overridden indiviually,

> > by placing each under an #ifndef block. As architectures providing their

> > own hooks can't include this file today, this shouldn't adversely affect

> > any existing hooks.

> >

> > Signed-off-by: Mark Rutland <mark.rutland@arm.com>

> > Cc: Arnd Bergmann <arnd@arndb.de>

> > Cc: linux-arch@vger.kernel.org

> 

> Acked-by: Arnd Bergmann <arnd@arndb.de>


Cheers!

Mark.

Patch

diff --git a/include/asm-generic/mm_hooks.h b/include/asm-generic/mm_hooks.h
index 8ac4e68a12f0..2b3ee15d3702 100644
--- a/include/asm-generic/mm_hooks.h
+++ b/include/asm-generic/mm_hooks.h
@@ -7,31 +7,42 @@ 
 #ifndef _ASM_GENERIC_MM_HOOKS_H
 #define _ASM_GENERIC_MM_HOOKS_H
 
+#ifndef arch_dup_mmap
 static inline int arch_dup_mmap(struct mm_struct *oldmm,
 				struct mm_struct *mm)
 {
 	return 0;
 }
+#endif
 
+#ifndef arch_exit_mmap
 static inline void arch_exit_mmap(struct mm_struct *mm)
 {
 }
+#endif
 
+#ifndef arch_unmap
 static inline void arch_unmap(struct mm_struct *mm,
 			struct vm_area_struct *vma,
 			unsigned long start, unsigned long end)
 {
 }
+#endif
 
+#ifndef arch_bprm_mm_init
 static inline void arch_bprm_mm_init(struct mm_struct *mm,
 				     struct vm_area_struct *vma)
 {
 }
+#endif
 
+#ifndef arch_vma_access_permitted
 static inline bool arch_vma_access_permitted(struct vm_area_struct *vma,
 		bool write, bool execute, bool foreign)
 {
 	/* by default, allow everything */
 	return true;
 }
+#endif
+
 #endif	/* _ASM_GENERIC_MM_HOOKS_H */