mmu_context.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. /* Load primary space page table origin. */
  37. asm volatile(LCTL_OPCODE" 1,1,%0\n" : : "m" (S390_lowcore.user_asce));
  38. set_fs(current->thread.mm_segment);
  39. }
  40. static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
  41. struct task_struct *tsk)
  42. {
  43. cpumask_set_cpu(smp_processor_id(), mm_cpumask(next));
  44. update_mm(next, tsk);
  45. atomic_dec(&prev->context.attach_count);
  46. WARN_ON(atomic_read(&prev->context.attach_count) < 0);
  47. atomic_inc(&next->context.attach_count);
  48. /* Check for TLBs not flushed yet */
  49. __tlb_flush_mm_lazy(next);
  50. }
  51. #define enter_lazy_tlb(mm,tsk) do { } while (0)
  52. #define deactivate_mm(tsk,mm) do { } while (0)
  53. static inline void activate_mm(struct mm_struct *prev,
  54. struct mm_struct *next)
  55. {
  56. switch_mm(prev, next, current);
  57. }
  58. static inline void arch_dup_mmap(struct mm_struct *oldmm,
  59. struct mm_struct *mm)
  60. {
  61. #ifdef CONFIG_64BIT
  62. if (oldmm->context.asce_limit < mm->context.asce_limit)
  63. crst_table_downgrade(mm, oldmm->context.asce_limit);
  64. #endif
  65. }
  66. static inline void arch_exit_mmap(struct mm_struct *mm)
  67. {
  68. }
  69. #endif /* __S390_MMU_CONTEXT_H */