s390/irq: Use defines for external interruption codes
[linux-2.6-block.git] / arch / s390 / include / asm / mmu_context.h
CommitLineData
1da177e4 1/*
1da177e4
LT
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
c1821c2e 10#include <asm/pgalloc.h>
146e4b3c 11#include <asm/uaccess.h>
050eef36 12#include <asm/tlbflush.h>
a0616cde 13#include <asm/ctl_reg.h>
d6dd61c8 14
6f457e1a
MS
15static inline int init_new_context(struct task_struct *tsk,
16 struct mm_struct *mm)
17{
050eef36
MS
18 atomic_set(&mm->context.attach_count, 0);
19 mm->context.flush_mm = 0;
146e4b3c 20 mm->context.asce_bits = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS;
6f457e1a 21#ifdef CONFIG_64BIT
6252d702 22 mm->context.asce_bits |= _ASCE_TYPE_REGION3;
6f457e1a 23#endif
3eabaee9 24 mm->context.has_pgste = 0;
6252d702
MS
25 mm->context.asce_limit = STACK_TOP_MAX;
26 crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));
6f457e1a
MS
27 return 0;
28}
1da177e4
LT
29
30#define destroy_context(mm) do { } while (0)
31
f4815ac6 32#ifndef CONFIG_64BIT
c1821c2e 33#define LCTL_OPCODE "lctl"
c1821c2e
GS
34#else
35#define LCTL_OPCODE "lctlg"
c1821c2e
GS
36#endif
37
3610cce8 38static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk)
1da177e4 39{
146e4b3c
MS
40 pgd_t *pgd = mm->pgd;
41
42 S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd);
e258d719
MS
43 /* Load primary space page table origin. */
44 asm volatile(LCTL_OPCODE" 1,1,%0\n" : : "m" (S390_lowcore.user_asce));
6252d702 45 set_fs(current->thread.mm_segment);
1da177e4
LT
46}
47
48static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
c1821c2e 49 struct task_struct *tsk)
1da177e4 50{
53e857f3
MS
51 int cpu = smp_processor_id();
52
53 if (prev == next)
54 return;
55 if (atomic_inc_return(&next->context.attach_count) >> 16) {
56 /* Delay update_mm until all TLB flushes are done. */
57 set_tsk_thread_flag(tsk, TIF_TLB_WAIT);
58 } else {
59 cpumask_set_cpu(cpu, mm_cpumask(next));
60 update_mm(next, tsk);
61 if (next->context.flush_mm)
62 /* Flush pending TLBs */
63 __tlb_flush_mm(next);
64 }
050eef36
MS
65 atomic_dec(&prev->context.attach_count);
66 WARN_ON(atomic_read(&prev->context.attach_count) < 0);
53e857f3
MS
67}
68
69#define finish_arch_post_lock_switch finish_arch_post_lock_switch
70static inline void finish_arch_post_lock_switch(void)
71{
72 struct task_struct *tsk = current;
73 struct mm_struct *mm = tsk->mm;
74
75 if (!test_tsk_thread_flag(tsk, TIF_TLB_WAIT))
76 return;
77 preempt_disable();
78 clear_tsk_thread_flag(tsk, TIF_TLB_WAIT);
79 while (atomic_read(&mm->context.attach_count) >> 16)
80 cpu_relax();
81
82 cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm));
83 update_mm(mm, tsk);
84 if (mm->context.flush_mm)
85 __tlb_flush_mm(mm);
86 preempt_enable();
1da177e4
LT
87}
88
3610cce8 89#define enter_lazy_tlb(mm,tsk) do { } while (0)
1da177e4
LT
90#define deactivate_mm(tsk,mm) do { } while (0)
91
4448aaf0 92static inline void activate_mm(struct mm_struct *prev,
1da177e4
LT
93 struct mm_struct *next)
94{
95 switch_mm(prev, next, current);
1da177e4
LT
96}
97
0f6f281b
MS
98static inline void arch_dup_mmap(struct mm_struct *oldmm,
99 struct mm_struct *mm)
100{
101#ifdef CONFIG_64BIT
102 if (oldmm->context.asce_limit < mm->context.asce_limit)
103 crst_table_downgrade(mm, oldmm->context.asce_limit);
104#endif
105}
106
107static inline void arch_exit_mmap(struct mm_struct *mm)
108{
109}
110
c1821c2e 111#endif /* __S390_MMU_CONTEXT_H */