1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_HIGHMEM_H 3 #define _ASM_HIGHMEM_H 4 5 #include <asm/kmap_types.h> 6 7 #define PKMAP_BASE (PAGE_OFFSET - PMD_SIZE) 8 #define LAST_PKMAP PTRS_PER_PTE 9 #define LAST_PKMAP_MASK (LAST_PKMAP - 1) 10 #define PKMAP_NR(virt) (((virt) - PKMAP_BASE) >> PAGE_SHIFT) 11 #define PKMAP_ADDR(nr) (PKMAP_BASE + ((nr) << PAGE_SHIFT)) 12 13 #define kmap_prot PAGE_KERNEL 14 15 #define flush_cache_kmaps() \ 16 do { \ 17 if (cache_is_vivt()) \ 18 flush_cache_all(); \ 19 } while (0) 20 21 extern pte_t *pkmap_page_table; 22 23 /* 24 * The reason for kmap_high_get() is to ensure that the currently kmap'd 25 * page usage count does not decrease to zero while we're using its 26 * existing virtual mapping in an atomic context. With a VIVT cache this 27 * is essential to do, but with a VIPT cache this is only an optimization 28 * so not to pay the price of establishing a second mapping if an existing 29 * one can be used. However, on platforms without hardware TLB maintenance 30 * broadcast, we simply cannot use ARCH_NEEDS_KMAP_HIGH_GET at all since 31 * the locking involved must also disable IRQs which is incompatible with 32 * the IPI mechanism used by global TLB operations. 33 */ 34 #define ARCH_NEEDS_KMAP_HIGH_GET 35 #if defined(CONFIG_SMP) && defined(CONFIG_CPU_TLB_V6) 36 #undef ARCH_NEEDS_KMAP_HIGH_GET 37 #if defined(CONFIG_HIGHMEM) && defined(CONFIG_CPU_CACHE_VIVT) 38 #error "The sum of features in your kernel config cannot be supported together" 39 #endif 40 #endif 41 42 /* 43 * Needed to be able to broadcast the TLB invalidation for kmap. 44 */ 45 #ifdef CONFIG_ARM_ERRATA_798181 46 #undef ARCH_NEEDS_KMAP_HIGH_GET 47 #endif 48 49 #ifdef ARCH_NEEDS_KMAP_HIGH_GET 50 extern void *kmap_high_get(struct page *page); 51 #else 52 static inline void *kmap_high_get(struct page *page) 53 { 54 return NULL; 55 } 56 #endif 57 58 /* 59 * The following functions are already defined by <linux/highmem.h> 60 * when CONFIG_HIGHMEM is not set. 61 */ 62 #ifdef CONFIG_HIGHMEM 63 extern void *kmap_atomic_pfn(unsigned long pfn); 64 #endif 65 66 #endif 67