^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifdef CONFIG_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/pgtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) /* the upper-most page table pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) extern pmd_t *top_pmd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) extern int icache_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * 0xffff8000 to 0xffffffff is reserved for any ARM architecture
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * specific hacks for copying pages efficiently, while 0xffff4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * is reserved for VIPT aliasing flushing by generic code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Note that we don't allow VIPT aliasing caches with SMP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define COPYPAGE_MINICACHE 0xffff8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #define COPYPAGE_V6_FROM 0xffff8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define COPYPAGE_V6_TO 0xffffc000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /* PFN alias flushing, for VIPT caches */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define FLUSH_ALIAS_START 0xffff4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static inline void set_top_pte(unsigned long va, pte_t pte)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) pte_t *ptep = pte_offset_kernel(top_pmd, va);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) set_pte_ext(ptep, pte, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) local_flush_tlb_kernel_page(va);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) static inline pte_t get_top_pte(unsigned long va)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) pte_t *ptep = pte_offset_kernel(top_pmd, va);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) return *ptep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct mem_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) pteval_t prot_pte;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) pteval_t prot_pte_s2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) pmdval_t prot_l1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) pmdval_t prot_sect;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned int domain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) const struct mem_type *get_mem_type(unsigned int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) extern void __flush_dcache_page(struct address_space *mapping, struct page *page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * ARM specific vm_struct->flags bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) /* (super)section-mapped I/O regions used by ioremap()/iounmap() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define VM_ARM_SECTION_MAPPING 0x80000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /* permanent static mappings from iotable_init() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define VM_ARM_STATIC_MAPPING 0x40000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) /* empty mapping */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define VM_ARM_EMPTY_MAPPING 0x20000000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* mapping type (attributes) for permanent static mappings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define VM_ARM_MTYPE(mt) ((mt) << 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define VM_ARM_MTYPE_MASK (0x1f << 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct static_vm {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct vm_struct vm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) extern struct list_head static_vmlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) extern struct static_vm *find_static_vm_vaddr(void *vaddr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) extern __init void add_static_vm_early(struct static_vm *svm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #ifdef CONFIG_ZONE_DMA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) extern phys_addr_t arm_dma_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) extern unsigned long arm_dma_pfn_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define arm_dma_limit ((phys_addr_t)~0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define arm_dma_pfn_limit (~0ul >> PAGE_SHIFT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) extern phys_addr_t arm_lowmem_limit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) void __init bootmem_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) void arm_mm_memblock_reserve(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) void dma_contiguous_remap(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) unsigned long __clear_cr(unsigned long mask);