KVM: x86: handle singlestep during emulation
[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
badb8bb9 24 if (current->mm && current->mm->context.alloc_pgste) {
250cf776
CB
25 /*
26 * alloc_pgste indicates, that any NEW context will be created
27 * with extended page tables. The old context is unchanged. The
28 * page table allocation and the page table operations will
29 * look at has_pgste to distinguish normal and extended page
30 * tables. The only way to create extended page tables is to
31 * set alloc_pgste and then create a new context (e.g. dup_mm).
32 * The page table allocation is called after init_new_context
33 * and if has_pgste is set, it will create extended page
34 * tables.
35 */
250cf776
CB
36 mm->context.has_pgste = 1;
37 mm->context.alloc_pgste = 1;
402b0862 38 } else {
250cf776
CB
39 mm->context.has_pgste = 0;
40 mm->context.alloc_pgste = 0;
402b0862 41 }
6252d702
MS
42 mm->context.asce_limit = STACK_TOP_MAX;
43 crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));
6f457e1a
MS
44 return 0;
45}
1da177e4
LT
46
47#define destroy_context(mm) do { } while (0)
48
f4815ac6 49#ifndef CONFIG_64BIT
c1821c2e 50#define LCTL_OPCODE "lctl"
c1821c2e
GS
51#else
52#define LCTL_OPCODE "lctlg"
c1821c2e
GS
53#endif
54
3610cce8 55static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk)
1da177e4 56{
146e4b3c
MS
57 pgd_t *pgd = mm->pgd;
58
59 S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd);
d1b0d842 60 if (s390_user_mode != HOME_SPACE_MODE) {
3610cce8 61 /* Load primary space page table origin. */
3610cce8 62 asm volatile(LCTL_OPCODE" 1,1,%0\n"
043d0708 63 : : "m" (S390_lowcore.user_asce) );
3610cce8
MS
64 } else
65 /* Load home space page table origin. */
66 asm volatile(LCTL_OPCODE" 13,13,%0"
67 : : "m" (S390_lowcore.user_asce) );
6252d702 68 set_fs(current->thread.mm_segment);
1da177e4
LT
69}
70
71static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
c1821c2e 72 struct task_struct *tsk)
1da177e4 73{
005f8eee 74 cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
3610cce8 75 update_mm(next, tsk);
050eef36
MS
76 atomic_dec(&prev->context.attach_count);
77 WARN_ON(atomic_read(&prev->context.attach_count) < 0);
78 atomic_inc(&next->context.attach_count);
79 /* Check for TLBs not flushed yet */
80 if (next->context.flush_mm)
81 __tlb_flush_mm(next);
1da177e4
LT
82}
83
3610cce8 84#define enter_lazy_tlb(mm,tsk) do { } while (0)
1da177e4
LT
85#define deactivate_mm(tsk,mm) do { } while (0)
86
4448aaf0 87static inline void activate_mm(struct mm_struct *prev,
1da177e4
LT
88 struct mm_struct *next)
89{
90 switch_mm(prev, next, current);
1da177e4
LT
91}
92
0f6f281b
MS
93static inline void arch_dup_mmap(struct mm_struct *oldmm,
94 struct mm_struct *mm)
95{
96#ifdef CONFIG_64BIT
97 if (oldmm->context.asce_limit < mm->context.asce_limit)
98 crst_table_downgrade(mm, oldmm->context.asce_limit);
99#endif
100}
101
102static inline void arch_exit_mmap(struct mm_struct *mm)
103{
104}
105
c1821c2e 106#endif /* __S390_MMU_CONTEXT_H */