Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * include/asm-s390/mmu_context.h |
| 3 | * |
| 4 | * S390 version |
| 5 | * |
| 6 | * Derived from "include/asm-i386/mmu_context.h" |
| 7 | */ |
| 8 | |
| 9 | #ifndef __S390_MMU_CONTEXT_H |
| 10 | #define __S390_MMU_CONTEXT_H |
| 11 | |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 12 | #include <asm/pgalloc.h> |
Jeremy Fitzhardinge | d6dd61c | 2007-05-02 19:27:14 +0200 | [diff] [blame] | 13 | #include <asm-generic/mm_hooks.h> |
| 14 | |
Martin Schwidefsky | 6f457e1 | 2008-01-26 14:10:58 +0100 | [diff] [blame] | 15 | static inline int init_new_context(struct task_struct *tsk, |
| 16 | struct mm_struct *mm) |
| 17 | { |
| 18 | mm->context = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS; |
| 19 | #ifdef CONFIG_64BIT |
| 20 | mm->context |= _ASCE_TYPE_REGION3; |
| 21 | #endif |
| 22 | return 0; |
| 23 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | |
| 25 | #define destroy_context(mm) do { } while (0) |
| 26 | |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 27 | #ifndef __s390x__ |
| 28 | #define LCTL_OPCODE "lctl" |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 29 | #else |
| 30 | #define LCTL_OPCODE "lctlg" |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 31 | #endif |
| 32 | |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame] | 33 | static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
Martin Schwidefsky | 6f457e1 | 2008-01-26 14:10:58 +0100 | [diff] [blame] | 35 | S390_lowcore.user_asce = mm->context | __pa(mm->pgd); |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame] | 36 | if (switch_amode) { |
| 37 | /* Load primary space page table origin. */ |
Martin Schwidefsky | 6f457e1 | 2008-01-26 14:10:58 +0100 | [diff] [blame] | 38 | pgd_t *shadow_pgd = get_shadow_table(mm->pgd) ? : mm->pgd; |
| 39 | S390_lowcore.user_exec_asce = mm->context | __pa(shadow_pgd); |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame] | 40 | asm volatile(LCTL_OPCODE" 1,1,%0\n" |
| 41 | : : "m" (S390_lowcore.user_exec_asce) ); |
| 42 | } else |
| 43 | /* Load home space page table origin. */ |
| 44 | asm volatile(LCTL_OPCODE" 13,13,%0" |
| 45 | : : "m" (S390_lowcore.user_asce) ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next, |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 49 | struct task_struct *tsk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | { |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame] | 51 | if (unlikely(prev == next)) |
| 52 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | cpu_set(smp_processor_id(), next->cpu_vm_mask); |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame] | 54 | update_mm(next, tsk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame] | 57 | #define enter_lazy_tlb(mm,tsk) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #define deactivate_mm(tsk,mm) do { } while (0) |
| 59 | |
Adrian Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 60 | static inline void activate_mm(struct mm_struct *prev, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | struct mm_struct *next) |
| 62 | { |
| 63 | switch_mm(prev, next, current); |
| 64 | set_fs(current->thread.mm_segment); |
| 65 | } |
| 66 | |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 67 | #endif /* __S390_MMU_CONTEXT_H */ |