Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

asm-generic: add generic MMU versions of mmu context functions

Many of these are no-ops on many architectures, so extend mmu_context.h
to cover MMU and NOMMU, and split the NOMMU bits out to nommu_context.h

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: linux-arch@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Nicholas Piggin and committed by
Arnd Bergmann
94f89922 3650b228

+72 -17
+6
arch/c6x/include/asm/mmu_context.h
··· 1 + #ifndef _ASM_C6X_MMU_CONTEXT_H 2 + #define _ASM_C6X_MMU_CONTEXT_H 3 + 4 + #include <asm-generic/nommu_context.h> 5 + 6 + #endif /* _ASM_C6X_MMU_CONTEXT_H */
+1 -1
arch/microblaze/include/asm/mmu_context.h
··· 2 2 #ifdef CONFIG_MMU 3 3 # include <asm/mmu_context_mm.h> 4 4 #else 5 - # include <asm-generic/mmu_context.h> 5 + # include <asm-generic/nommu_context.h> 6 6 #endif
+1 -1
arch/sh/include/asm/mmu_context.h
··· 133 133 #define set_TTB(pgd) do { } while (0) 134 134 #define get_TTB() (0) 135 135 136 - #include <asm-generic/mmu_context.h> 136 + #include <asm-generic/nommu_context.h> 137 137 138 138 #endif /* CONFIG_MMU */ 139 139
+45 -15
include/asm-generic/mmu_context.h
··· 3 3 #define __ASM_GENERIC_MMU_CONTEXT_H 4 4 5 5 /* 6 - * Generic hooks for NOMMU architectures, which do not need to do 7 - * anything special here. 6 + * Generic hooks to implement no-op functionality. 8 7 */ 9 - 10 - #include <asm-generic/mm_hooks.h> 11 8 12 9 struct task_struct; 13 10 struct mm_struct; 14 11 12 + /* 13 + * enter_lazy_tlb - Called when "tsk" is about to enter lazy TLB mode. 14 + * 15 + * @mm: the currently active mm context which is becoming lazy 16 + * @tsk: task which is entering lazy tlb 17 + * 18 + * tsk->mm will be NULL 19 + */ 20 + #ifndef enter_lazy_tlb 15 21 static inline void enter_lazy_tlb(struct mm_struct *mm, 16 22 struct task_struct *tsk) 17 23 { 18 24 } 25 + #endif 19 26 27 + /** 28 + * init_new_context - Initialize context of a new mm_struct. 29 + * @tsk: task struct for the mm 30 + * @mm: the new mm struct 31 + * @return: 0 on success, -errno on failure 32 + */ 33 + #ifndef init_new_context 20 34 static inline int init_new_context(struct task_struct *tsk, 21 35 struct mm_struct *mm) 22 36 { 23 37 return 0; 24 38 } 39 + #endif 25 40 41 + /** 42 + * destroy_context - Undo init_new_context when the mm is going away 43 + * @mm: old mm struct 44 + */ 45 + #ifndef destroy_context 26 46 static inline void destroy_context(struct mm_struct *mm) 27 47 { 28 48 } 49 + #endif 29 50 30 - static inline void deactivate_mm(struct task_struct *task, 31 - struct mm_struct *mm) 32 - { 33 - } 34 - 35 - static inline void switch_mm(struct mm_struct *prev, 36 - struct mm_struct *next, 37 - struct task_struct *tsk) 38 - { 39 - } 40 - 51 + /** 52 + * activate_mm - called after exec switches the current task to a new mm, to switch to it 53 + * @prev_mm: previous mm of this task 54 + * @next_mm: new mm 55 + */ 56 + #ifndef activate_mm 41 57 static inline void activate_mm(struct mm_struct *prev_mm, 42 58 struct mm_struct *next_mm) 43 59 { 60 + switch_mm(prev_mm, next_mm, current); 44 61 } 62 + #endif 63 + 64 + /** 65 + * dectivate_mm - called when an mm is released after exit or exec switches away from it 66 + * @tsk: the task 67 + * @mm: the old mm 68 + */ 69 + #ifndef deactivate_mm 70 + static inline void deactivate_mm(struct task_struct *tsk, 71 + struct mm_struct *mm) 72 + { 73 + } 74 + #endif 45 75 46 76 #endif /* __ASM_GENERIC_MMU_CONTEXT_H */
+19
include/asm-generic/nommu_context.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef __ASM_GENERIC_NOMMU_H 3 + #define __ASM_GENERIC_NOMMU_H 4 + 5 + /* 6 + * Generic hooks for NOMMU architectures, which do not need to do 7 + * anything special here. 8 + */ 9 + #include <asm-generic/mm_hooks.h> 10 + 11 + static inline void switch_mm(struct mm_struct *prev, 12 + struct mm_struct *next, 13 + struct task_struct *tsk) 14 + { 15 + } 16 + 17 + #include <asm-generic/mmu_context.h> 18 + 19 + #endif /* __ASM_GENERIC_NOMMU_H */