Lines Matching refs:mm

54 	struct mm_struct *mm = __mm;  in flush_ldt()  local
56 if (this_cpu_read(cpu_tlbstate.loaded_mm) != mm) in flush_ldt()
59 load_mm_ldt(mm); in flush_ldt()
105 static void do_sanity_check(struct mm_struct *mm, in do_sanity_check() argument
109 if (mm->context.ldt) { in do_sanity_check()
150 static void map_ldt_struct_to_user(struct mm_struct *mm) in map_ldt_struct_to_user() argument
152 pgd_t *k_pgd = pgd_offset(mm, LDT_BASE_ADDR); in map_ldt_struct_to_user()
159 if (boot_cpu_has(X86_FEATURE_PTI) && !mm->context.ldt) in map_ldt_struct_to_user()
163 static void sanity_check_ldt_mapping(struct mm_struct *mm) in sanity_check_ldt_mapping() argument
165 pgd_t *k_pgd = pgd_offset(mm, LDT_BASE_ADDR); in sanity_check_ldt_mapping()
175 do_sanity_check(mm, had_kernel, had_user); in sanity_check_ldt_mapping()
180 static void map_ldt_struct_to_user(struct mm_struct *mm) in map_ldt_struct_to_user() argument
182 pgd_t *pgd = pgd_offset(mm, LDT_BASE_ADDR); in map_ldt_struct_to_user()
184 if (boot_cpu_has(X86_FEATURE_PTI) && !mm->context.ldt) in map_ldt_struct_to_user()
188 static void sanity_check_ldt_mapping(struct mm_struct *mm) in sanity_check_ldt_mapping() argument
190 pgd_t *pgd = pgd_offset(mm, LDT_BASE_ADDR); in sanity_check_ldt_mapping()
194 do_sanity_check(mm, had_kernel, had_user); in sanity_check_ldt_mapping()
204 map_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt, int slot) in map_ldt_struct() argument
221 sanity_check_ldt_mapping(mm); in map_ldt_struct()
242 ptep = get_locked_pte(mm, va, &ptl); in map_ldt_struct()
254 set_pte_at(mm, va, ptep, pte); in map_ldt_struct()
259 map_ldt_struct_to_user(mm); in map_ldt_struct()
265 static void unmap_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt) in unmap_ldt_struct() argument
285 ptep = get_locked_pte(mm, va, &ptl); in unmap_ldt_struct()
286 pte_clear(mm, va, ptep); in unmap_ldt_struct()
291 flush_tlb_mm_range(mm, va, va + nr_pages * PAGE_SIZE, PAGE_SHIFT, false); in unmap_ldt_struct()
297 map_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt, int slot) in map_ldt_struct() argument
302 static void unmap_ldt_struct(struct mm_struct *mm, struct ldt_struct *ldt) in unmap_ldt_struct() argument
307 static void free_ldt_pgtables(struct mm_struct *mm) in free_ldt_pgtables() argument
317 tlb_gather_mmu(&tlb, mm, start, end); in free_ldt_pgtables()
329 static void install_ldt(struct mm_struct *mm, struct ldt_struct *ldt) in install_ldt() argument
331 mutex_lock(&mm->context.lock); in install_ldt()
334 smp_store_release(&mm->context.ldt, ldt); in install_ldt()
337 on_each_cpu_mask(mm_cpumask(mm), flush_ldt, mm, true); in install_ldt()
339 mutex_unlock(&mm->context.lock); in install_ldt()
359 int ldt_dup_context(struct mm_struct *old_mm, struct mm_struct *mm) in ldt_dup_context() argument
381 retval = map_ldt_struct(mm, new_ldt, 0); in ldt_dup_context()
383 free_ldt_pgtables(mm); in ldt_dup_context()
387 mm->context.ldt = new_ldt; in ldt_dup_context()
399 void destroy_context_ldt(struct mm_struct *mm) in destroy_context_ldt() argument
401 free_ldt_struct(mm->context.ldt); in destroy_context_ldt()
402 mm->context.ldt = NULL; in destroy_context_ldt()
405 void ldt_arch_exit_mmap(struct mm_struct *mm) in ldt_arch_exit_mmap() argument
407 free_ldt_pgtables(mm); in ldt_arch_exit_mmap()
412 struct mm_struct *mm = current->mm; in read_ldt() local
416 down_read(&mm->context.ldt_usr_sem); in read_ldt()
418 if (!mm->context.ldt) { in read_ldt()
426 entries_size = mm->context.ldt->nr_entries * LDT_ENTRY_SIZE; in read_ldt()
430 if (copy_to_user(ptr, mm->context.ldt->entries, entries_size)) { in read_ldt()
445 up_read(&mm->context.ldt_usr_sem); in read_ldt()
466 struct mm_struct *mm = current->mm; in write_ldt() local
505 if (down_write_killable(&mm->context.ldt_usr_sem)) in write_ldt()
508 old_ldt = mm->context.ldt; in write_ldt()
529 error = map_ldt_struct(mm, new_ldt, old_ldt ? !old_ldt->slot : 0); in write_ldt()
537 free_ldt_pgtables(mm); in write_ldt()
542 install_ldt(mm, new_ldt); in write_ldt()
543 unmap_ldt_struct(mm, old_ldt); in write_ldt()
548 up_write(&mm->context.ldt_usr_sem); in write_ldt()