tlb.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * TLB shootdown specifics for powerpc
  4. *
  5. * Copyright (C) 2002 Anton Blanchard, IBM Corp.
  6. * Copyright (C) 2002 Paul Mackerras, IBM Corp.
  7. */
  8. #ifndef _ASM_POWERPC_TLB_H
  9. #define _ASM_POWERPC_TLB_H
  10. #ifdef __KERNEL__
  11. #ifndef __powerpc64__
  12. #include <linux/pgtable.h>
  13. #endif
  14. #ifndef __powerpc64__
  15. #include <asm/page.h>
  16. #include <asm/mmu.h>
  17. #endif
  18. #include <linux/pagemap.h>
  19. #define __tlb_remove_tlb_entry __tlb_remove_tlb_entry
  20. #define tlb_flush tlb_flush
  21. extern void tlb_flush(struct mmu_gather *tlb);
  22. /*
  23. * book3s:
  24. * Hash does not use the linux page-tables, so we can avoid
  25. * the TLB invalidate for page-table freeing, Radix otoh does use the
  26. * page-tables and needs the TLBI.
  27. *
  28. * nohash:
  29. * We still do TLB invalidate in the __pte_free_tlb routine before we
  30. * add the page table pages to mmu gather table batch.
  31. */
  32. #define tlb_needs_table_invalidate() radix_enabled()
  33. /* Get the generic bits... */
  34. #include <asm-generic/tlb.h>
  35. static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep,
  36. unsigned long address)
  37. {
  38. #ifdef CONFIG_PPC_BOOK3S_32
  39. if (pte_val(*ptep) & _PAGE_HASHPTE)
  40. flush_hash_entry(tlb->mm, ptep, address);
  41. #endif
  42. }
  43. #ifdef CONFIG_SMP
  44. static inline int mm_is_core_local(struct mm_struct *mm)
  45. {
  46. return cpumask_subset(mm_cpumask(mm),
  47. topology_sibling_cpumask(smp_processor_id()));
  48. }
  49. #ifdef CONFIG_PPC_BOOK3S_64
  50. static inline int mm_is_thread_local(struct mm_struct *mm)
  51. {
  52. if (atomic_read(&mm->context.active_cpus) > 1)
  53. return false;
  54. return cpumask_test_cpu(smp_processor_id(), mm_cpumask(mm));
  55. }
  56. #else /* CONFIG_PPC_BOOK3S_64 */
  57. static inline int mm_is_thread_local(struct mm_struct *mm)
  58. {
  59. return cpumask_equal(mm_cpumask(mm),
  60. cpumask_of(smp_processor_id()));
  61. }
  62. #endif /* !CONFIG_PPC_BOOK3S_64 */
  63. #else /* CONFIG_SMP */
  64. static inline int mm_is_core_local(struct mm_struct *mm)
  65. {
  66. return 1;
  67. }
  68. static inline int mm_is_thread_local(struct mm_struct *mm)
  69. {
  70. return 1;
  71. }
  72. #endif
  73. #define arch_supports_page_table_move arch_supports_page_table_move
  74. static inline bool arch_supports_page_table_move(void)
  75. {
  76. return radix_enabled();
  77. }
  78. #endif /* __KERNEL__ */
  79. #endif /* __ASM_POWERPC_TLB_H */