18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include <linux/mm_types.h> 38c2ecf20Sopenharmony_ci#include <linux/rbtree.h> 48c2ecf20Sopenharmony_ci#include <linux/rwsem.h> 58c2ecf20Sopenharmony_ci#include <linux/spinlock.h> 68c2ecf20Sopenharmony_ci#include <linux/list.h> 78c2ecf20Sopenharmony_ci#include <linux/cpumask.h> 88c2ecf20Sopenharmony_ci#include <linux/mman.h> 98c2ecf20Sopenharmony_ci#include <linux/pgtable.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/atomic.h> 128c2ecf20Sopenharmony_ci#include <linux/user_namespace.h> 138c2ecf20Sopenharmony_ci#include <asm/mmu.h> 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci#ifndef INIT_MM_CONTEXT 168c2ecf20Sopenharmony_ci#define INIT_MM_CONTEXT(name) 178c2ecf20Sopenharmony_ci#endif 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* 208c2ecf20Sopenharmony_ci * For dynamically allocated mm_structs, there is a dynamically sized cpumask 218c2ecf20Sopenharmony_ci * at the end of the structure, the size of which depends on the maximum CPU 228c2ecf20Sopenharmony_ci * number the system can see. That way we allocate only as much memory for 238c2ecf20Sopenharmony_ci * mm_cpumask() as needed for the hundreds, or thousands of processes that 248c2ecf20Sopenharmony_ci * a system typically runs. 258c2ecf20Sopenharmony_ci * 268c2ecf20Sopenharmony_ci * Since there is only one init_mm in the entire system, keep it simple 278c2ecf20Sopenharmony_ci * and size this cpu_bitmask to NR_CPUS. 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_cistruct mm_struct init_mm = { 308c2ecf20Sopenharmony_ci .mm_rb = RB_ROOT, 318c2ecf20Sopenharmony_ci .pgd = swapper_pg_dir, 328c2ecf20Sopenharmony_ci .mm_users = ATOMIC_INIT(2), 338c2ecf20Sopenharmony_ci .mm_count = ATOMIC_INIT(1), 348c2ecf20Sopenharmony_ci .write_protect_seq = SEQCNT_ZERO(init_mm.write_protect_seq), 358c2ecf20Sopenharmony_ci MMAP_LOCK_INITIALIZER(init_mm) 368c2ecf20Sopenharmony_ci .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock), 378c2ecf20Sopenharmony_ci .arg_lock = __SPIN_LOCK_UNLOCKED(init_mm.arg_lock), 388c2ecf20Sopenharmony_ci .mmlist = LIST_HEAD_INIT(init_mm.mmlist), 398c2ecf20Sopenharmony_ci .user_ns = &init_user_ns, 408c2ecf20Sopenharmony_ci .cpu_bitmap = CPU_BITS_NONE, 418c2ecf20Sopenharmony_ci INIT_MM_CONTEXT(init_mm) 428c2ecf20Sopenharmony_ci}; 43