tlbflush.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_POWERPC_NOHASH_TLBFLUSH_H
  3. #define _ASM_POWERPC_NOHASH_TLBFLUSH_H
  4. /*
  5. * TLB flushing:
  6. *
  7. * - flush_tlb_mm(mm) flushes the specified mm context TLB's
  8. * - flush_tlb_page(vma, vmaddr) flushes one page
  9. * - local_flush_tlb_mm(mm, full) flushes the specified mm context on
  10. * the local processor
  11. * - local_flush_tlb_page(vma, vmaddr) flushes one page on the local processor
  12. * - flush_tlb_range(vma, start, end) flushes a range of pages
  13. * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
  14. *
  15. */
  16. /*
  17. * TLB flushing for software loaded TLB chips
  18. *
  19. * TODO: (CONFIG_PPC_85xx) determine if flush_tlb_range &
  20. * flush_tlb_kernel_range are best implemented as tlbia vs
  21. * specific tlbie's
  22. */
  23. struct vm_area_struct;
  24. struct mm_struct;
  25. #define MMU_NO_CONTEXT ((unsigned int)-1)
  26. extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
  27. unsigned long end);
  28. #ifdef CONFIG_PPC_8xx
  29. static inline void local_flush_tlb_mm(struct mm_struct *mm)
  30. {
  31. unsigned int pid = READ_ONCE(mm->context.id);
  32. if (pid != MMU_NO_CONTEXT)
  33. asm volatile ("sync; tlbia; isync" : : : "memory");
  34. }
  35. static inline void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr)
  36. {
  37. asm volatile ("tlbie %0; sync" : : "r" (vmaddr) : "memory");
  38. }
  39. static inline void flush_tlb_kernel_range(unsigned long start, unsigned long end)
  40. {
  41. start &= PAGE_MASK;
  42. if (end - start <= PAGE_SIZE)
  43. asm volatile ("tlbie %0; sync" : : "r" (start) : "memory");
  44. else
  45. asm volatile ("sync; tlbia; isync" : : : "memory");
  46. }
  47. #else
  48. extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
  49. extern void local_flush_tlb_mm(struct mm_struct *mm);
  50. extern void local_flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
  51. extern void __local_flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
  52. int tsize, int ind);
  53. #endif
  54. #ifdef CONFIG_SMP
  55. extern void flush_tlb_mm(struct mm_struct *mm);
  56. extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
  57. extern void __flush_tlb_page(struct mm_struct *mm, unsigned long vmaddr,
  58. int tsize, int ind);
  59. #else
  60. #define flush_tlb_mm(mm) local_flush_tlb_mm(mm)
  61. #define flush_tlb_page(vma,addr) local_flush_tlb_page(vma,addr)
  62. #define __flush_tlb_page(mm,addr,p,i) __local_flush_tlb_page(mm,addr,p,i)
  63. #endif
  64. #endif /* _ASM_POWERPC_NOHASH_TLBFLUSH_H */