12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2b8b572e1SStephen Rothwell /*
3b8b572e1SStephen Rothwell * TLB shootdown specifics for powerpc
4b8b572e1SStephen Rothwell *
5b8b572e1SStephen Rothwell * Copyright (C) 2002 Anton Blanchard, IBM Corp.
6b8b572e1SStephen Rothwell * Copyright (C) 2002 Paul Mackerras, IBM Corp.
7b8b572e1SStephen Rothwell */
8b8b572e1SStephen Rothwell #ifndef _ASM_POWERPC_TLB_H
9b8b572e1SStephen Rothwell #define _ASM_POWERPC_TLB_H
10b8b572e1SStephen Rothwell #ifdef __KERNEL__
11b8b572e1SStephen Rothwell
12b8b572e1SStephen Rothwell #ifndef __powerpc64__
13ca5999fdSMike Rapoport #include <linux/pgtable.h>
14b8b572e1SStephen Rothwell #endif
15b8b572e1SStephen Rothwell #ifndef __powerpc64__
16b8b572e1SStephen Rothwell #include <asm/page.h>
17b8b572e1SStephen Rothwell #include <asm/mmu.h>
18b8b572e1SStephen Rothwell #endif
19b8b572e1SStephen Rothwell
20b8b572e1SStephen Rothwell #include <linux/pagemap.h>
21b8b572e1SStephen Rothwell
22fb7332a9SWill Deacon #define __tlb_remove_tlb_entry __tlb_remove_tlb_entry
23b8b572e1SStephen Rothwell
245f307be1SPeter Zijlstra #define tlb_flush tlb_flush
25b8b572e1SStephen Rothwell extern void tlb_flush(struct mmu_gather *tlb);
260ed13259SPeter Zijlstra /*
270ed13259SPeter Zijlstra * book3s:
280ed13259SPeter Zijlstra * Hash does not use the linux page-tables, so we can avoid
290ed13259SPeter Zijlstra * the TLB invalidate for page-table freeing, Radix otoh does use the
300ed13259SPeter Zijlstra * page-tables and needs the TLBI.
310ed13259SPeter Zijlstra *
320ed13259SPeter Zijlstra * nohash:
330ed13259SPeter Zijlstra * We still do TLB invalidate in the __pte_free_tlb routine before we
340ed13259SPeter Zijlstra * add the page table pages to mmu gather table batch.
350ed13259SPeter Zijlstra */
360ed13259SPeter Zijlstra #define tlb_needs_table_invalidate() radix_enabled()
37b8b572e1SStephen Rothwell
38b8b572e1SStephen Rothwell /* Get the generic bits... */
39b8b572e1SStephen Rothwell #include <asm-generic/tlb.h>
40b8b572e1SStephen Rothwell
__tlb_remove_tlb_entry(struct mmu_gather * tlb,pte_t * ptep,unsigned long address)41b8b572e1SStephen Rothwell static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep,
42b8b572e1SStephen Rothwell unsigned long address)
43b8b572e1SStephen Rothwell {
4468289ae9SChristophe Leroy #ifdef CONFIG_PPC_BOOK3S_32
45b8b572e1SStephen Rothwell if (pte_val(*ptep) & _PAGE_HASHPTE)
46b8b572e1SStephen Rothwell flush_hash_entry(tlb->mm, ptep, address);
47c7cc58a1SBenjamin Herrenschmidt #endif
48b8b572e1SStephen Rothwell }
49b8b572e1SStephen Rothwell
509d4dab11SAneesh Kumar K.V #ifdef CONFIG_SMP
mm_is_core_local(struct mm_struct * mm)519d4dab11SAneesh Kumar K.V static inline int mm_is_core_local(struct mm_struct *mm)
529d4dab11SAneesh Kumar K.V {
539d4dab11SAneesh Kumar K.V return cpumask_subset(mm_cpumask(mm),
549d4dab11SAneesh Kumar K.V topology_sibling_cpumask(smp_processor_id()));
559d4dab11SAneesh Kumar K.V }
56bd77c449SAneesh Kumar K.V
57a619e59cSBenjamin Herrenschmidt #ifdef CONFIG_PPC_BOOK3S_64
mm_is_thread_local(struct mm_struct * mm)58a619e59cSBenjamin Herrenschmidt static inline int mm_is_thread_local(struct mm_struct *mm)
59a619e59cSBenjamin Herrenschmidt {
60a619e59cSBenjamin Herrenschmidt if (atomic_read(&mm->context.active_cpus) > 1)
61a619e59cSBenjamin Herrenschmidt return false;
62a619e59cSBenjamin Herrenschmidt return cpumask_test_cpu(smp_processor_id(), mm_cpumask(mm));
63a619e59cSBenjamin Herrenschmidt }
64a619e59cSBenjamin Herrenschmidt #else /* CONFIG_PPC_BOOK3S_64 */
mm_is_thread_local(struct mm_struct * mm)65bd77c449SAneesh Kumar K.V static inline int mm_is_thread_local(struct mm_struct *mm)
66bd77c449SAneesh Kumar K.V {
67bd77c449SAneesh Kumar K.V return cpumask_equal(mm_cpumask(mm),
68bd77c449SAneesh Kumar K.V cpumask_of(smp_processor_id()));
69bd77c449SAneesh Kumar K.V }
70a619e59cSBenjamin Herrenschmidt #endif /* !CONFIG_PPC_BOOK3S_64 */
71bd77c449SAneesh Kumar K.V
72a619e59cSBenjamin Herrenschmidt #else /* CONFIG_SMP */
mm_is_core_local(struct mm_struct * mm)739d4dab11SAneesh Kumar K.V static inline int mm_is_core_local(struct mm_struct *mm)
749d4dab11SAneesh Kumar K.V {
759d4dab11SAneesh Kumar K.V return 1;
769d4dab11SAneesh Kumar K.V }
77bd77c449SAneesh Kumar K.V
mm_is_thread_local(struct mm_struct * mm)78bd77c449SAneesh Kumar K.V static inline int mm_is_thread_local(struct mm_struct *mm)
79bd77c449SAneesh Kumar K.V {
80bd77c449SAneesh Kumar K.V return 1;
81bd77c449SAneesh Kumar K.V }
829d4dab11SAneesh Kumar K.V #endif
839d4dab11SAneesh Kumar K.V
84*3bbda69cSAneesh Kumar K.V #define arch_supports_page_table_move arch_supports_page_table_move
arch_supports_page_table_move(void)85*3bbda69cSAneesh Kumar K.V static inline bool arch_supports_page_table_move(void)
86*3bbda69cSAneesh Kumar K.V {
87*3bbda69cSAneesh Kumar K.V return radix_enabled();
88*3bbda69cSAneesh Kumar K.V }
89*3bbda69cSAneesh Kumar K.V
90b8b572e1SStephen Rothwell #endif /* __KERNEL__ */
91b8b572e1SStephen Rothwell #endif /* __ASM_POWERPC_TLB_H */
92