Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *  TLB shootdown specifics for powerpc
0004  *
0005  * Copyright (C) 2002 Anton Blanchard, IBM Corp.
0006  * Copyright (C) 2002 Paul Mackerras, IBM Corp.
0007  */
0008 #ifndef _ASM_POWERPC_TLB_H
0009 #define _ASM_POWERPC_TLB_H
0010 #ifdef __KERNEL__
0011 
0012 #ifndef __powerpc64__
0013 #include <linux/pgtable.h>
0014 #endif
0015 #ifndef __powerpc64__
0016 #include <asm/page.h>
0017 #include <asm/mmu.h>
0018 #endif
0019 
0020 #include <linux/pagemap.h>
0021 
0022 #define __tlb_remove_tlb_entry  __tlb_remove_tlb_entry
0023 
0024 #define tlb_flush tlb_flush
0025 extern void tlb_flush(struct mmu_gather *tlb);
0026 /*
0027  * book3s:
0028  * Hash does not use the linux page-tables, so we can avoid
0029  * the TLB invalidate for page-table freeing, Radix otoh does use the
0030  * page-tables and needs the TLBI.
0031  *
0032  * nohash:
0033  * We still do TLB invalidate in the __pte_free_tlb routine before we
0034  * add the page table pages to mmu gather table batch.
0035  */
0036 #define tlb_needs_table_invalidate()    radix_enabled()
0037 
0038 /* Get the generic bits... */
0039 #include <asm-generic/tlb.h>
0040 
0041 static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep,
0042                       unsigned long address)
0043 {
0044 #ifdef CONFIG_PPC_BOOK3S_32
0045     if (pte_val(*ptep) & _PAGE_HASHPTE)
0046         flush_hash_entry(tlb->mm, ptep, address);
0047 #endif
0048 }
0049 
0050 #ifdef CONFIG_SMP
0051 static inline int mm_is_core_local(struct mm_struct *mm)
0052 {
0053     return cpumask_subset(mm_cpumask(mm),
0054                   topology_sibling_cpumask(smp_processor_id()));
0055 }
0056 
0057 #ifdef CONFIG_PPC_BOOK3S_64
0058 static inline int mm_is_thread_local(struct mm_struct *mm)
0059 {
0060     if (atomic_read(&mm->context.active_cpus) > 1)
0061         return false;
0062     return cpumask_test_cpu(smp_processor_id(), mm_cpumask(mm));
0063 }
0064 #else /* CONFIG_PPC_BOOK3S_64 */
0065 static inline int mm_is_thread_local(struct mm_struct *mm)
0066 {
0067     return cpumask_equal(mm_cpumask(mm),
0068                   cpumask_of(smp_processor_id()));
0069 }
0070 #endif /* !CONFIG_PPC_BOOK3S_64 */
0071 
0072 #else /* CONFIG_SMP */
0073 static inline int mm_is_core_local(struct mm_struct *mm)
0074 {
0075     return 1;
0076 }
0077 
0078 static inline int mm_is_thread_local(struct mm_struct *mm)
0079 {
0080     return 1;
0081 }
0082 #endif
0083 
0084 #define arch_supports_page_table_move arch_supports_page_table_move
0085 static inline bool arch_supports_page_table_move(void)
0086 {
0087     return radix_enabled();
0088 }
0089 
0090 #endif /* __KERNEL__ */
0091 #endif /* __ASM_POWERPC_TLB_H */