tlbflush.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_IA64_TLBFLUSH_H
  3. #define _ASM_IA64_TLBFLUSH_H
  4. /*
  5. * Copyright (C) 2002 Hewlett-Packard Co
  6. * David Mosberger-Tang <[email protected]>
  7. */
  8. #include <linux/mm.h>
  9. #include <asm/intrinsics.h>
  10. #include <asm/mmu_context.h>
  11. #include <asm/page.h>
  12. struct ia64_tr_entry {
  13. u64 ifa;
  14. u64 itir;
  15. u64 pte;
  16. u64 rr;
  17. }; /*Record for tr entry!*/
  18. extern int ia64_itr_entry(u64 target_mask, u64 va, u64 pte, u64 log_size);
  19. extern void ia64_ptr_entry(u64 target_mask, int slot);
  20. extern struct ia64_tr_entry *ia64_idtrs[NR_CPUS];
  21. /*
  22. region register macros
  23. */
  24. #define RR_TO_VE(val) (((val) >> 0) & 0x0000000000000001)
  25. #define RR_VE(val) (((val) & 0x0000000000000001) << 0)
  26. #define RR_VE_MASK 0x0000000000000001L
  27. #define RR_VE_SHIFT 0
  28. #define RR_TO_PS(val) (((val) >> 2) & 0x000000000000003f)
  29. #define RR_PS(val) (((val) & 0x000000000000003f) << 2)
  30. #define RR_PS_MASK 0x00000000000000fcL
  31. #define RR_PS_SHIFT 2
  32. #define RR_RID_MASK 0x00000000ffffff00L
  33. #define RR_TO_RID(val) ((val >> 8) & 0xffffff)
  34. /*
  35. * Now for some TLB flushing routines. This is the kind of stuff that
  36. * can be very expensive, so try to avoid them whenever possible.
  37. */
  38. extern void setup_ptcg_sem(int max_purges, int from_palo);
  39. /*
  40. * Flush everything (kernel mapping may also have changed due to
  41. * vmalloc/vfree).
  42. */
  43. extern void local_flush_tlb_all (void);
  44. #ifdef CONFIG_SMP
  45. extern void smp_flush_tlb_all (void);
  46. extern void smp_flush_tlb_mm (struct mm_struct *mm);
  47. extern void smp_flush_tlb_cpumask (cpumask_t xcpumask);
  48. # define flush_tlb_all() smp_flush_tlb_all()
  49. #else
  50. # define flush_tlb_all() local_flush_tlb_all()
  51. # define smp_flush_tlb_cpumask(m) local_flush_tlb_all()
  52. #endif
  53. static inline void
  54. local_finish_flush_tlb_mm (struct mm_struct *mm)
  55. {
  56. if (mm == current->active_mm)
  57. activate_context(mm);
  58. }
  59. /*
  60. * Flush a specified user mapping. This is called, e.g., as a result of fork() and
  61. * exit(). fork() ends up here because the copy-on-write mechanism needs to write-protect
  62. * the PTEs of the parent task.
  63. */
  64. static inline void
  65. flush_tlb_mm (struct mm_struct *mm)
  66. {
  67. if (!mm)
  68. return;
  69. set_bit(mm->context, ia64_ctx.flushmap);
  70. mm->context = 0;
  71. if (atomic_read(&mm->mm_users) == 0)
  72. return; /* happens as a result of exit_mmap() */
  73. #ifdef CONFIG_SMP
  74. smp_flush_tlb_mm(mm);
  75. #else
  76. local_finish_flush_tlb_mm(mm);
  77. #endif
  78. }
  79. extern void flush_tlb_range (struct vm_area_struct *vma, unsigned long start, unsigned long end);
  80. /*
  81. * Page-granular tlb flush.
  82. */
  83. static inline void
  84. flush_tlb_page (struct vm_area_struct *vma, unsigned long addr)
  85. {
  86. #ifdef CONFIG_SMP
  87. flush_tlb_range(vma, (addr & PAGE_MASK), (addr & PAGE_MASK) + PAGE_SIZE);
  88. #else
  89. if (vma->vm_mm == current->active_mm)
  90. ia64_ptcl(addr, (PAGE_SHIFT << 2));
  91. else
  92. vma->vm_mm->context = 0;
  93. #endif
  94. }
  95. /*
  96. * Flush the local TLB. Invoked from another cpu using an IPI.
  97. */
  98. #ifdef CONFIG_SMP
  99. void smp_local_flush_tlb(void);
  100. #else
  101. #define smp_local_flush_tlb()
  102. #endif
  103. static inline void flush_tlb_kernel_range(unsigned long start,
  104. unsigned long end)
  105. {
  106. flush_tlb_all(); /* XXX fix me */
  107. }
  108. #endif /* _ASM_IA64_TLBFLUSH_H */