mmu_context.h 3.0 KB

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