1 // SPDX-License-Identifier: GPL-2.0 2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. 3 4 #include <linux/kernel.h> 5 #include <linux/mm.h> 6 #include <linux/fs.h> 7 #include <linux/syscalls.h> 8 #include <linux/spinlock.h> 9 #include <asm/page.h> 10 #include <asm/cache.h> 11 #include <asm/cacheflush.h> 12 #include <asm/cachectl.h> 13 14 void flush_dcache_page(struct page *page) 15 { 16 struct address_space *mapping = page_mapping(page); 17 unsigned long addr; 18 19 if (mapping && !mapping_mapped(mapping)) { 20 set_bit(PG_arch_1, &(page)->flags); 21 return; 22 } 23 24 /* 25 * We could delay the flush for the !page_mapping case too. But that 26 * case is for exec env/arg pages and those are %99 certainly going to 27 * get faulted into the tlb (and thus flushed) anyways. 28 */ 29 addr = (unsigned long) page_address(page); 30 dcache_wb_range(addr, addr + PAGE_SIZE); 31 } 32 33 void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, 34 pte_t *pte) 35 { 36 unsigned long addr; 37 struct page *page; 38 unsigned long pfn; 39 40 pfn = pte_pfn(*pte); 41 if (unlikely(!pfn_valid(pfn))) 42 return; 43 44 page = pfn_to_page(pfn); 45 addr = (unsigned long) page_address(page); 46 47 if (vma->vm_flags & VM_EXEC || 48 pages_do_alias(addr, address & PAGE_MASK)) 49 cache_wbinv_all(); 50 51 clear_bit(PG_arch_1, &(page)->flags); 52 } 53