1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 2bb1f17b0SAlexey Dobriyan #include <linux/mm_types.h> 3bb1f17b0SAlexey Dobriyan #include <linux/rbtree.h> 4bb1f17b0SAlexey Dobriyan #include <linux/rwsem.h> 5bb1f17b0SAlexey Dobriyan #include <linux/spinlock.h> 6bb1f17b0SAlexey Dobriyan #include <linux/list.h> 7bb1f17b0SAlexey Dobriyan #include <linux/cpumask.h> 8*a2ae8c05SBen Dooks (Codethink) #include <linux/mman.h> 9bb1f17b0SAlexey Dobriyan 1060063497SArun Sharma #include <linux/atomic.h> 11bfedb589SEric W. Biederman #include <linux/user_namespace.h> 12bb1f17b0SAlexey Dobriyan #include <asm/pgtable.h> 13a1b200e2SHeiko Carstens #include <asm/mmu.h> 14a1b200e2SHeiko Carstens 15a1b200e2SHeiko Carstens #ifndef INIT_MM_CONTEXT 16a1b200e2SHeiko Carstens #define INIT_MM_CONTEXT(name) 17a1b200e2SHeiko Carstens #endif 18bb1f17b0SAlexey Dobriyan 19c1a2f7f0SRik van Riel /* 20c1a2f7f0SRik van Riel * For dynamically allocated mm_structs, there is a dynamically sized cpumask 21c1a2f7f0SRik van Riel * at the end of the structure, the size of which depends on the maximum CPU 22c1a2f7f0SRik van Riel * number the system can see. That way we allocate only as much memory for 23c1a2f7f0SRik van Riel * mm_cpumask() as needed for the hundreds, or thousands of processes that 24c1a2f7f0SRik van Riel * a system typically runs. 25c1a2f7f0SRik van Riel * 26c1a2f7f0SRik van Riel * Since there is only one init_mm in the entire system, keep it simple 27c1a2f7f0SRik van Riel * and size this cpu_bitmask to NR_CPUS. 28c1a2f7f0SRik van Riel */ 29bb1f17b0SAlexey Dobriyan struct mm_struct init_mm = { 30bb1f17b0SAlexey Dobriyan .mm_rb = RB_ROOT, 31bb1f17b0SAlexey Dobriyan .pgd = swapper_pg_dir, 32bb1f17b0SAlexey Dobriyan .mm_users = ATOMIC_INIT(2), 33bb1f17b0SAlexey Dobriyan .mm_count = ATOMIC_INIT(1), 34bb1f17b0SAlexey Dobriyan .mmap_sem = __RWSEM_INITIALIZER(init_mm.mmap_sem), 35bb1f17b0SAlexey Dobriyan .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock), 3688aa7cc6SYang Shi .arg_lock = __SPIN_LOCK_UNLOCKED(init_mm.arg_lock), 37bb1f17b0SAlexey Dobriyan .mmlist = LIST_HEAD_INIT(init_mm.mmlist), 38bfedb589SEric W. Biederman .user_ns = &init_user_ns, 392286bf4eSMike Rapoport .cpu_bitmap = CPU_BITS_NONE, 40a1b200e2SHeiko Carstens INIT_MM_CONTEXT(init_mm) 41bb1f17b0SAlexey Dobriyan }; 42