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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | /* |
| 16 | * get a new mmu context.. S390 don't know about contexts. |
| 17 | */ |
| 18 | #define init_new_context(tsk,mm) 0 |
| 19 | |
| 20 | #define destroy_context(mm) do { } while (0) |
| 21 | |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 22 | #ifndef __s390x__ |
| 23 | #define LCTL_OPCODE "lctl" |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 24 | #else |
| 25 | #define LCTL_OPCODE "lctlg" |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 26 | #endif |
| 27 | |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame^] | 28 | 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] | 29 | { |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame^] | 30 | pgd_t *pgd = mm->pgd; |
| 31 | unsigned long asce_bits; |
| 32 | |
| 33 | /* Calculate asce bits from the first pgd table entry. */ |
| 34 | asce_bits = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS; |
| 35 | #ifdef CONFIG_64BIT |
| 36 | asce_bits |= _ASCE_TYPE_REGION3; |
| 37 | #endif |
| 38 | S390_lowcore.user_asce = asce_bits | __pa(pgd); |
| 39 | if (switch_amode) { |
| 40 | /* Load primary space page table origin. */ |
| 41 | pgd_t *shadow_pgd = get_shadow_table(pgd) ? : pgd; |
| 42 | S390_lowcore.user_exec_asce = asce_bits | __pa(shadow_pgd); |
| 43 | asm volatile(LCTL_OPCODE" 1,1,%0\n" |
| 44 | : : "m" (S390_lowcore.user_exec_asce) ); |
| 45 | } else |
| 46 | /* Load home space page table origin. */ |
| 47 | asm volatile(LCTL_OPCODE" 13,13,%0" |
| 48 | : : "m" (S390_lowcore.user_asce) ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | 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] | 52 | struct task_struct *tsk) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame^] | 54 | if (unlikely(prev == next)) |
| 55 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | cpu_set(smp_processor_id(), next->cpu_vm_mask); |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame^] | 57 | update_mm(next, tsk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Martin Schwidefsky | 3610cce | 2007-10-22 12:52:47 +0200 | [diff] [blame^] | 60 | #define enter_lazy_tlb(mm,tsk) do { } while (0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | #define deactivate_mm(tsk,mm) do { } while (0) |
| 62 | |
Adrian Bunk | 4448aaf | 2005-11-08 21:34:42 -0800 | [diff] [blame] | 63 | static inline void activate_mm(struct mm_struct *prev, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | struct mm_struct *next) |
| 65 | { |
| 66 | switch_mm(prev, next, current); |
| 67 | set_fs(current->thread.mm_segment); |
| 68 | } |
| 69 | |
Gerald Schaefer | c1821c2 | 2007-02-05 21:18:17 +0100 | [diff] [blame] | 70 | #endif /* __S390_MMU_CONTEXT_H */ |