mmu_context.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. mm->context.has_pgste = 0;
  22. mm->context.asce_limit = STACK_TOP_MAX;
  23. crst_table_init((unsigned long *) mm->pgd, pgd_entry_type(mm));
  24. return 0;
  25. }
  26. #define destroy_context(mm) do { } while (0)
  27. #ifndef CONFIG_64BIT
  28. #define LCTL_OPCODE "lctl"
  29. #else
  30. #define LCTL_OPCODE "lctlg"
  31. #endif
  32. static inline void update_mm(struct mm_struct *mm, struct task_struct *tsk)
  33. {
  34. pgd_t *pgd = mm->pgd;
  35. S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd);
  36. if (s390_user_mode != HOME_SPACE_MODE) {
  37. /* Load primary space page table origin. */
  38. asm volatile(LCTL_OPCODE" 1,1,%0\n"
  39. : : "m" (S390_lowcore.user_asce) );
  40. } else
  41. /* Load home space page table origin. */
  42. asm volatile(LCTL_OPCODE" 13,13,%0"
  43. : : "m" (S390_lowcore.user_asce) );
  44. set_fs(current->thread.mm_segment);
  45. }
  46. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  47. struct task_struct *tsk)
  48. {
  49. cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
  50. update_mm(next, tsk);
  51. atomic_dec(&prev->context.attach_count);
  52. WARN_ON(atomic_read(&prev->context.attach_count) < 0);
  53. atomic_inc(&next->context.attach_count);
  54. /* Check for TLBs not flushed yet */
  55. __tlb_flush_mm_lazy(next);
  56. }
  57. #define enter_lazy_tlb(mm,tsk) do { } while (0)
  58. #define deactivate_mm(tsk,mm) do { } while (0)
  59. static inline void activate_mm(struct mm_struct *prev,
  60. struct mm_struct *next)
  61. {
  62. switch_mm(prev, next, current);
  63. }
  64. static inline void arch_dup_mmap(struct mm_struct *oldmm,
  65. struct mm_struct *mm)
  66. {
  67. #ifdef CONFIG_64BIT
  68. if (oldmm->context.asce_limit < mm->context.asce_limit)
  69. crst_table_downgrade(mm, oldmm->context.asce_limit);
  70. #endif
  71. }
  72. static inline void arch_exit_mmap(struct mm_struct *mm)
  73. {
  74. }
  75. #endif /* __S390_MMU_CONTEXT_H */