Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/mm_types.h>
0003 #include <linux/rbtree.h>
0004 #include <linux/rwsem.h>
0005 #include <linux/spinlock.h>
0006 #include <linux/list.h>
0007 #include <linux/cpumask.h>
0008 #include <linux/mman.h>
0009 #include <linux/pgtable.h>
0010 
0011 #include <linux/atomic.h>
0012 #include <linux/user_namespace.h>
0013 #include <linux/ioasid.h>
0014 #include <asm/mmu.h>
0015 
0016 #ifndef INIT_MM_CONTEXT
0017 #define INIT_MM_CONTEXT(name)
0018 #endif
0019 
0020 /*
0021  * For dynamically allocated mm_structs, there is a dynamically sized cpumask
0022  * at the end of the structure, the size of which depends on the maximum CPU
0023  * number the system can see. That way we allocate only as much memory for
0024  * mm_cpumask() as needed for the hundreds, or thousands of processes that
0025  * a system typically runs.
0026  *
0027  * Since there is only one init_mm in the entire system, keep it simple
0028  * and size this cpu_bitmask to NR_CPUS.
0029  */
0030 struct mm_struct init_mm = {
0031     .mm_rb      = RB_ROOT,
0032     .pgd        = swapper_pg_dir,
0033     .mm_users   = ATOMIC_INIT(2),
0034     .mm_count   = ATOMIC_INIT(1),
0035     .write_protect_seq = SEQCNT_ZERO(init_mm.write_protect_seq),
0036     MMAP_LOCK_INITIALIZER(init_mm)
0037     .page_table_lock =  __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock),
0038     .arg_lock   =  __SPIN_LOCK_UNLOCKED(init_mm.arg_lock),
0039     .mmlist     = LIST_HEAD_INIT(init_mm.mmlist),
0040     .user_ns    = &init_user_ns,
0041     .cpu_bitmap = CPU_BITS_NONE,
0042 #ifdef CONFIG_IOMMU_SVA
0043     .pasid      = INVALID_IOASID,
0044 #endif
0045     INIT_MM_CONTEXT(init_mm)
0046 };
0047 
0048 void setup_initial_init_mm(void *start_code, void *end_code,
0049                void *end_data, void *brk)
0050 {
0051     init_mm.start_code = (unsigned long)start_code;
0052     init_mm.end_code = (unsigned long)end_code;
0053     init_mm.end_data = (unsigned long)end_data;
0054     init_mm.brk = (unsigned long)brk;
0055 }