18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * MM context support for the Hexagon architecture 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved. 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef _ASM_MMU_CONTEXT_H 98c2ecf20Sopenharmony_ci#define _ASM_MMU_CONTEXT_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/mm_types.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#include <asm/setup.h> 148c2ecf20Sopenharmony_ci#include <asm/page.h> 158c2ecf20Sopenharmony_ci#include <asm/pgalloc.h> 168c2ecf20Sopenharmony_ci#include <asm/mem-layout.h> 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistatic inline void destroy_context(struct mm_struct *mm) 198c2ecf20Sopenharmony_ci{ 208c2ecf20Sopenharmony_ci} 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * VM port hides all TLB management, so "lazy TLB" isn't very 248c2ecf20Sopenharmony_ci * meaningful. Even for ports to architectures with visble TLBs, 258c2ecf20Sopenharmony_ci * this is almost invariably a null function. 268c2ecf20Sopenharmony_ci */ 278c2ecf20Sopenharmony_cistatic inline void enter_lazy_tlb(struct mm_struct *mm, 288c2ecf20Sopenharmony_ci struct task_struct *tsk) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci} 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci/* 338c2ecf20Sopenharmony_ci * Architecture-specific actions, if any, for memory map deactivation. 348c2ecf20Sopenharmony_ci */ 358c2ecf20Sopenharmony_cistatic inline void deactivate_mm(struct task_struct *tsk, 368c2ecf20Sopenharmony_ci struct mm_struct *mm) 378c2ecf20Sopenharmony_ci{ 388c2ecf20Sopenharmony_ci} 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/** 418c2ecf20Sopenharmony_ci * init_new_context - initialize context related info for new mm_struct instance 428c2ecf20Sopenharmony_ci * @tsk: pointer to a task struct 438c2ecf20Sopenharmony_ci * @mm: pointer to a new mm struct 448c2ecf20Sopenharmony_ci */ 458c2ecf20Sopenharmony_cistatic inline int init_new_context(struct task_struct *tsk, 468c2ecf20Sopenharmony_ci struct mm_struct *mm) 478c2ecf20Sopenharmony_ci{ 488c2ecf20Sopenharmony_ci /* mm->context is set up by pgd_alloc */ 498c2ecf20Sopenharmony_ci return 0; 508c2ecf20Sopenharmony_ci} 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/* 538c2ecf20Sopenharmony_ci * Switch active mm context 548c2ecf20Sopenharmony_ci */ 558c2ecf20Sopenharmony_cistatic inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, 568c2ecf20Sopenharmony_ci struct task_struct *tsk) 578c2ecf20Sopenharmony_ci{ 588c2ecf20Sopenharmony_ci int l1; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci /* 618c2ecf20Sopenharmony_ci * For virtual machine, we have to update system map if it's been 628c2ecf20Sopenharmony_ci * touched. 638c2ecf20Sopenharmony_ci */ 648c2ecf20Sopenharmony_ci if (next->context.generation < prev->context.generation) { 658c2ecf20Sopenharmony_ci for (l1 = MIN_KERNEL_SEG; l1 <= max_kernel_seg; l1++) 668c2ecf20Sopenharmony_ci next->pgd[l1] = init_mm.pgd[l1]; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci next->context.generation = prev->context.generation; 698c2ecf20Sopenharmony_ci } 708c2ecf20Sopenharmony_ci 718c2ecf20Sopenharmony_ci __vmnewmap((void *)next->context.ptbase); 728c2ecf20Sopenharmony_ci} 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci/* 758c2ecf20Sopenharmony_ci * Activate new memory map for task 768c2ecf20Sopenharmony_ci */ 778c2ecf20Sopenharmony_cistatic inline void activate_mm(struct mm_struct *prev, struct mm_struct *next) 788c2ecf20Sopenharmony_ci{ 798c2ecf20Sopenharmony_ci unsigned long flags; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci local_irq_save(flags); 828c2ecf20Sopenharmony_ci switch_mm(prev, next, current_thread_info()->task); 838c2ecf20Sopenharmony_ci local_irq_restore(flags); 848c2ecf20Sopenharmony_ci} 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ci/* Generic hooks for arch_dup_mmap and arch_exit_mmap */ 878c2ecf20Sopenharmony_ci#include <asm-generic/mm_hooks.h> 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#endif 90