1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2bb1f17b0SAlexey Dobriyan #include <linux/mm_types.h>
3d4af56c5SLiam R. Howlett #include <linux/maple_tree.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>
8a2ae8c05SBen Dooks (Codethink) #include <linux/mman.h>
965fddcfcSMike Rapoport #include <linux/pgtable.h>
10bb1f17b0SAlexey Dobriyan
1160063497SArun Sharma #include <linux/atomic.h>
12bfedb589SEric W. Biederman #include <linux/user_namespace.h>
13fffaed1eSJacob Pan #include <linux/iommu.h>
14a1b200e2SHeiko Carstens #include <asm/mmu.h>
15a1b200e2SHeiko Carstens
16a1b200e2SHeiko Carstens #ifndef INIT_MM_CONTEXT
17a1b200e2SHeiko Carstens #define INIT_MM_CONTEXT(name)
18a1b200e2SHeiko Carstens #endif
19bb1f17b0SAlexey Dobriyan
20*9a9d0b82SMateusz Guzik const struct vm_operations_struct vma_dummy_vm_ops;
21*9a9d0b82SMateusz Guzik
22c1a2f7f0SRik van Riel /*
23c1a2f7f0SRik van Riel * For dynamically allocated mm_structs, there is a dynamically sized cpumask
24c1a2f7f0SRik van Riel * at the end of the structure, the size of which depends on the maximum CPU
25c1a2f7f0SRik van Riel * number the system can see. That way we allocate only as much memory for
26c1a2f7f0SRik van Riel * mm_cpumask() as needed for the hundreds, or thousands of processes that
27c1a2f7f0SRik van Riel * a system typically runs.
28c1a2f7f0SRik van Riel *
29c1a2f7f0SRik van Riel * Since there is only one init_mm in the entire system, keep it simple
30c1a2f7f0SRik van Riel * and size this cpu_bitmask to NR_CPUS.
31c1a2f7f0SRik van Riel */
32bb1f17b0SAlexey Dobriyan struct mm_struct init_mm = {
33d4af56c5SLiam R. Howlett .mm_mt = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS, init_mm.mmap_lock),
34bb1f17b0SAlexey Dobriyan .pgd = swapper_pg_dir,
35bb1f17b0SAlexey Dobriyan .mm_users = ATOMIC_INIT(2),
36bb1f17b0SAlexey Dobriyan .mm_count = ATOMIC_INIT(1),
3757efa1feSJason Gunthorpe .write_protect_seq = SEQCNT_ZERO(init_mm.write_protect_seq),
3814c3656bSMichel Lespinasse MMAP_LOCK_INITIALIZER(init_mm)
39bb1f17b0SAlexey Dobriyan .page_table_lock = __SPIN_LOCK_UNLOCKED(init_mm.page_table_lock),
4088aa7cc6SYang Shi .arg_lock = __SPIN_LOCK_UNLOCKED(init_mm.arg_lock),
41bb1f17b0SAlexey Dobriyan .mmlist = LIST_HEAD_INIT(init_mm.mmlist),
425e31275cSSuren Baghdasaryan #ifdef CONFIG_PER_VMA_LOCK
435e31275cSSuren Baghdasaryan .mm_lock_seq = 0,
445e31275cSSuren Baghdasaryan #endif
45bfedb589SEric W. Biederman .user_ns = &init_user_ns,
462286bf4eSMike Rapoport .cpu_bitmap = CPU_BITS_NONE,
47a6cbd440SFenghua Yu #ifdef CONFIG_IOMMU_SVA
48fffaed1eSJacob Pan .pasid = IOMMU_PASID_INVALID,
49a6cbd440SFenghua Yu #endif
50a1b200e2SHeiko Carstens INIT_MM_CONTEXT(init_mm)
51bb1f17b0SAlexey Dobriyan };
525748fbc5SKefeng Wang
setup_initial_init_mm(void * start_code,void * end_code,void * end_data,void * brk)535748fbc5SKefeng Wang void setup_initial_init_mm(void *start_code, void *end_code,
545748fbc5SKefeng Wang void *end_data, void *brk)
555748fbc5SKefeng Wang {
565748fbc5SKefeng Wang init_mm.start_code = (unsigned long)start_code;
575748fbc5SKefeng Wang init_mm.end_code = (unsigned long)end_code;
585748fbc5SKefeng Wang init_mm.end_data = (unsigned long)end_data;
595748fbc5SKefeng Wang init_mm.brk = (unsigned long)brk;
605748fbc5SKefeng Wang }
61