162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _ASM_GENERIC_CACHEFLUSH_H 362306a36Sopenharmony_ci#define _ASM_GENERIC_CACHEFLUSH_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <linux/instrumented.h> 662306a36Sopenharmony_ci 762306a36Sopenharmony_cistruct mm_struct; 862306a36Sopenharmony_cistruct vm_area_struct; 962306a36Sopenharmony_cistruct page; 1062306a36Sopenharmony_cistruct address_space; 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci/* 1362306a36Sopenharmony_ci * The cache doesn't need to be flushed when TLB entries change when 1462306a36Sopenharmony_ci * the cache is mapped to physical memory, not virtual memory 1562306a36Sopenharmony_ci */ 1662306a36Sopenharmony_ci#ifndef flush_cache_all 1762306a36Sopenharmony_cistatic inline void flush_cache_all(void) 1862306a36Sopenharmony_ci{ 1962306a36Sopenharmony_ci} 2062306a36Sopenharmony_ci#endif 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#ifndef flush_cache_mm 2362306a36Sopenharmony_cistatic inline void flush_cache_mm(struct mm_struct *mm) 2462306a36Sopenharmony_ci{ 2562306a36Sopenharmony_ci} 2662306a36Sopenharmony_ci#endif 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#ifndef flush_cache_dup_mm 2962306a36Sopenharmony_cistatic inline void flush_cache_dup_mm(struct mm_struct *mm) 3062306a36Sopenharmony_ci{ 3162306a36Sopenharmony_ci} 3262306a36Sopenharmony_ci#endif 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#ifndef flush_cache_range 3562306a36Sopenharmony_cistatic inline void flush_cache_range(struct vm_area_struct *vma, 3662306a36Sopenharmony_ci unsigned long start, 3762306a36Sopenharmony_ci unsigned long end) 3862306a36Sopenharmony_ci{ 3962306a36Sopenharmony_ci} 4062306a36Sopenharmony_ci#endif 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#ifndef flush_cache_page 4362306a36Sopenharmony_cistatic inline void flush_cache_page(struct vm_area_struct *vma, 4462306a36Sopenharmony_ci unsigned long vmaddr, 4562306a36Sopenharmony_ci unsigned long pfn) 4662306a36Sopenharmony_ci{ 4762306a36Sopenharmony_ci} 4862306a36Sopenharmony_ci#endif 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_ci#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 5162306a36Sopenharmony_cistatic inline void flush_dcache_page(struct page *page) 5262306a36Sopenharmony_ci{ 5362306a36Sopenharmony_ci} 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0 5662306a36Sopenharmony_ci#endif 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci#ifndef flush_dcache_mmap_lock 5962306a36Sopenharmony_cistatic inline void flush_dcache_mmap_lock(struct address_space *mapping) 6062306a36Sopenharmony_ci{ 6162306a36Sopenharmony_ci} 6262306a36Sopenharmony_ci#endif 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci#ifndef flush_dcache_mmap_unlock 6562306a36Sopenharmony_cistatic inline void flush_dcache_mmap_unlock(struct address_space *mapping) 6662306a36Sopenharmony_ci{ 6762306a36Sopenharmony_ci} 6862306a36Sopenharmony_ci#endif 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#ifndef flush_icache_range 7162306a36Sopenharmony_cistatic inline void flush_icache_range(unsigned long start, unsigned long end) 7262306a36Sopenharmony_ci{ 7362306a36Sopenharmony_ci} 7462306a36Sopenharmony_ci#endif 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci#ifndef flush_icache_user_range 7762306a36Sopenharmony_ci#define flush_icache_user_range flush_icache_range 7862306a36Sopenharmony_ci#endif 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci#ifndef flush_icache_user_page 8162306a36Sopenharmony_cistatic inline void flush_icache_user_page(struct vm_area_struct *vma, 8262306a36Sopenharmony_ci struct page *page, 8362306a36Sopenharmony_ci unsigned long addr, int len) 8462306a36Sopenharmony_ci{ 8562306a36Sopenharmony_ci} 8662306a36Sopenharmony_ci#endif 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci#ifndef flush_cache_vmap 8962306a36Sopenharmony_cistatic inline void flush_cache_vmap(unsigned long start, unsigned long end) 9062306a36Sopenharmony_ci{ 9162306a36Sopenharmony_ci} 9262306a36Sopenharmony_ci#endif 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci#ifndef flush_cache_vmap_early 9562306a36Sopenharmony_cistatic inline void flush_cache_vmap_early(unsigned long start, unsigned long end) 9662306a36Sopenharmony_ci{ 9762306a36Sopenharmony_ci} 9862306a36Sopenharmony_ci#endif 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_ci#ifndef flush_cache_vunmap 10162306a36Sopenharmony_cistatic inline void flush_cache_vunmap(unsigned long start, unsigned long end) 10262306a36Sopenharmony_ci{ 10362306a36Sopenharmony_ci} 10462306a36Sopenharmony_ci#endif 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ci#ifndef copy_to_user_page 10762306a36Sopenharmony_ci#define copy_to_user_page(vma, page, vaddr, dst, src, len) \ 10862306a36Sopenharmony_ci do { \ 10962306a36Sopenharmony_ci instrument_copy_to_user((void __user *)dst, src, len); \ 11062306a36Sopenharmony_ci memcpy(dst, src, len); \ 11162306a36Sopenharmony_ci flush_icache_user_page(vma, page, vaddr, len); \ 11262306a36Sopenharmony_ci } while (0) 11362306a36Sopenharmony_ci#endif 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci#ifndef copy_from_user_page 11762306a36Sopenharmony_ci#define copy_from_user_page(vma, page, vaddr, dst, src, len) \ 11862306a36Sopenharmony_ci do { \ 11962306a36Sopenharmony_ci instrument_copy_from_user_before(dst, (void __user *)src, \ 12062306a36Sopenharmony_ci len); \ 12162306a36Sopenharmony_ci memcpy(dst, src, len); \ 12262306a36Sopenharmony_ci instrument_copy_from_user_after(dst, (void __user *)src, len, \ 12362306a36Sopenharmony_ci 0); \ 12462306a36Sopenharmony_ci } while (0) 12562306a36Sopenharmony_ci#endif 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci#endif /* _ASM_GENERIC_CACHEFLUSH_H */ 128