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