1 /* 2 * S390 version 3 * 4 * Derived from "include/asm-i386/mmu_context.h" 5 */ 6 7 #ifndef __S390_MMU_CONTEXT_H 8 #define __S390_MMU_CONTEXT_H 9 10 #include <asm/pgalloc.h> 11 #include <asm/uaccess.h> 12 #include <asm/tlbflush.h> 13 #include <asm/ctl_reg.h> 14 15 static inline int init_new_context(struct task_struct *tsk, 16 struct mm_struct *mm) 17 { 18 atomic_set(&mm->context.attach_count, 0); 19 mm->context.flush_mm = 0; 20 mm->context.asce_bits = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS; 21 #ifdef CONFIG_64BIT 22 mm->context.asce_bits |= _ASCE_TYPE_REGION3; 23 #endif 24 mm->context.has_pgste = 0; 25 mm->context.asce_limit = STACK_TOP_MAX; 26 crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm)); 27 return 0; 28 } 29 30 #define destroy_context(mm) do { } while (0) 31 32 #ifndef CONFIG_64BIT 33 #define LCTL_OPCODE "lctl" 34 #else 35 #define LCTL_OPCODE "lctlg" 36 #endif 37 38 static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk) 39 { 40 pgd_t *pgd = mm->pgd; 41 42 S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd); 43 if (s390_user_mode != HOME_SPACE_MODE) { 44 /* Load primary space page table origin. */ 45 asm volatile(LCTL_OPCODE" 1,1,%0\n" 46 : : "m" (S390_lowcore.user_asce) ); 47 } else 48 /* Load home space page table origin. */ 49 asm volatile(LCTL_OPCODE" 13,13,%0" 50 : : "m" (S390_lowcore.user_asce) ); 51 set_fs(current->thread.mm_segment); 52 } 53 54 static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, 55 struct task_struct *tsk) 56 { 57 cpumask_set_cpu(smp_processor_id(), mm_cpumask(next)); 58 update_mm(next, tsk); 59 atomic_dec(&prev->context.attach_count); 60 WARN_ON(atomic_read(&prev->context.attach_count) < 0); 61 atomic_inc(&next->context.attach_count); 62 /* Check for TLBs not flushed yet */ 63 __tlb_flush_mm_lazy(next); 64 } 65 66 #define enter_lazy_tlb(mm,tsk) do { } while (0) 67 #define deactivate_mm(tsk,mm) do { } while (0) 68 69 static inline void activate_mm(struct mm_struct *prev, 70 struct mm_struct *next) 71 { 72 switch_mm(prev, next, current); 73 } 74 75 static inline void arch_dup_mmap(struct mm_struct *oldmm, 76 struct mm_struct *mm) 77 { 78 #ifdef CONFIG_64BIT 79 if (oldmm->context.asce_limit < mm->context.asce_limit) 80 crst_table_downgrade(mm, oldmm->context.asce_limit); 81 #endif 82 } 83 84 static inline void arch_exit_mmap(struct mm_struct *mm) 85 { 86 } 87 88 #endif /* __S390_MMU_CONTEXT_H */ 89