mmu_context.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * S390 version
  3. *
  4. * Derived from "include/asm-i386/mmu_context.h"
  5. */
  6. #ifndef __S390_MMU_CONTEXT_H
  7. #define __S390_MMU_CONTEXT_H
  8. #include <asm/pgalloc.h>
  9. #include <asm/uaccess.h>
  10. #include <asm/tlbflush.h>
  11. #include <asm/ctl_reg.h>
  12. #include <asm-generic/mm_hooks.h>
  13. static inline int init_new_context(struct task_struct *tsk,
  14. struct mm_struct *mm)
  15. {
  16. atomic_set(&mm->context.attach_count, 0);
  17. mm->context.flush_mm = 0;
  18. mm->context.asce_bits = _ASCE_TABLE_LENGTH | _ASCE_USER_BITS;
  19. #ifdef CONFIG_64BIT
  20. mm->context.asce_bits |= _ASCE_TYPE_REGION3;
  21. #endif
  22. if (current->mm && current->mm->context.alloc_pgste) {
  23. /*
  24. * alloc_pgste indicates, that any NEW context will be created
  25. * with extended page tables. The old context is unchanged. The
  26. * page table allocation and the page table operations will
  27. * look at has_pgste to distinguish normal and extended page
  28. * tables. The only way to create extended page tables is to
  29. * set alloc_pgste and then create a new context (e.g. dup_mm).
  30. * The page table allocation is called after init_new_context
  31. * and if has_pgste is set, it will create extended page
  32. * tables.
  33. */
  34. mm->context.has_pgste = 1;
  35. mm->context.alloc_pgste = 1;
  36. } else {
  37. mm->context.has_pgste = 0;
  38. mm->context.alloc_pgste = 0;
  39. }
  40. mm->context.asce_limit = STACK_TOP_MAX;
  41. crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));
  42. return 0;
  43. }
  44. #define destroy_context(mm) do { } while (0)
  45. #ifndef CONFIG_64BIT
  46. #define LCTL_OPCODE "lctl"
  47. #else
  48. #define LCTL_OPCODE "lctlg"
  49. #endif
  50. static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk)
  51. {
  52. pgd_t *pgd = mm->pgd;
  53. S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd);
  54. if (user_mode != HOME_SPACE_MODE) {
  55. /* Load primary space page table origin. */
  56. asm volatile(LCTL_OPCODE" 1,1,%0\n"
  57. : : "m" (S390_lowcore.user_asce) );
  58. } else
  59. /* Load home space page table origin. */
  60. asm volatile(LCTL_OPCODE" 13,13,%0"
  61. : : "m" (S390_lowcore.user_asce) );
  62. set_fs(current->thread.mm_segment);
  63. }
  64. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  65. struct task_struct *tsk)
  66. {
  67. cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
  68. update_mm(next, tsk);
  69. atomic_dec(&prev->context.attach_count);
  70. WARN_ON(atomic_read(&prev->context.attach_count) < 0);
  71. atomic_inc(&next->context.attach_count);
  72. /* Check for TLBs not flushed yet */
  73. if (next->context.flush_mm)
  74. __tlb_flush_mm(next);
  75. }
  76. #define enter_lazy_tlb(mm,tsk) do { } while (0)
  77. #define deactivate_mm(tsk,mm) do { } while (0)
  78. static inline void activate_mm(struct mm_struct *prev,
  79. struct mm_struct *next)
  80. {
  81. switch_mm(prev, next, current);
  82. }
  83. #endif /* __S390_MMU_CONTEXT_H */