tlbflush.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 <davidm@hpl.hp.com>
  7. */
  8. #include <linux/mm.h>
  9. #include <asm/intrinsics.h>
  10. #include <asm/mmu_context.h>
  11. #include <asm/page.h>
  12. /*
  13. * Now for some TLB flushing routines. This is the kind of stuff that
  14. * can be very expensive, so try to avoid them whenever possible.
  15. */
  16. extern void setup_ptcg_sem(int max_purges, int from_palo);
  17. /*
  18. * Flush everything (kernel mapping may also have changed due to
  19. * vmalloc/vfree).
  20. */
  21. extern void local_flush_tlb_all (void);
  22. #ifdef CONFIG_SMP
  23. extern void smp_flush_tlb_all (void);
  24. extern void smp_flush_tlb_mm (struct mm_struct *mm);
  25. extern void smp_flush_tlb_cpumask (cpumask_t xcpumask);
  26. # define flush_tlb_all() smp_flush_tlb_all()
  27. #else
  28. # define flush_tlb_all() local_flush_tlb_all()
  29. # define smp_flush_tlb_cpumask(m) local_flush_tlb_all()
  30. #endif
  31. static inline void
  32. local_finish_flush_tlb_mm (struct mm_struct *mm)
  33. {
  34. if (mm == current->active_mm)
  35. activate_context(mm);
  36. }
  37. /*
  38. * Flush a specified user mapping. This is called, e.g., as a result of fork() and
  39. * exit(). fork() ends up here because the copy-on-write mechanism needs to write-protect
  40. * the PTEs of the parent task.
  41. */
  42. static inline void
  43. flush_tlb_mm (struct mm_struct *mm)
  44. {
  45. if (!mm)
  46. return;
  47. set_bit(mm->context, ia64_ctx.flushmap);
  48. mm->context = 0;
  49. if (atomic_read(&mm->mm_users) == 0)
  50. return; /* happens as a result of exit_mmap() */
  51. #ifdef CONFIG_SMP
  52. smp_flush_tlb_mm(mm);
  53. #else
  54. local_finish_flush_tlb_mm(mm);
  55. #endif
  56. }
  57. extern void flush_tlb_range (struct vm_area_struct *vma, unsigned long start, unsigned long end);
  58. /*
  59. * Page-granular tlb flush.
  60. */
  61. static inline void
  62. flush_tlb_page (struct vm_area_struct *vma, unsigned long addr)
  63. {
  64. #ifdef CONFIG_SMP
  65. flush_tlb_range(vma, (addr & PAGE_MASK), (addr & PAGE_MASK) + PAGE_SIZE);
  66. #else
  67. if (vma->vm_mm == current->active_mm)
  68. ia64_ptcl(addr, (PAGE_SHIFT << 2));
  69. else
  70. vma->vm_mm->context = 0;
  71. #endif
  72. }
  73. /*
  74. * Flush the local TLB. Invoked from another cpu using an IPI.
  75. */
  76. #ifdef CONFIG_SMP
  77. void smp_local_flush_tlb(void);
  78. #else
  79. #define smp_local_flush_tlb()
  80. #endif
  81. static inline void flush_tlb_kernel_range(unsigned long start,
  82. unsigned long end)
  83. {
  84. flush_tlb_all(); /* XXX fix me */
  85. }
  86. #endif /* _ASM_IA64_TLBFLUSH_H */