18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _ALPHA_CACHEFLUSH_H 38c2ecf20Sopenharmony_ci#define _ALPHA_CACHEFLUSH_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#include <linux/mm.h> 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci/* Note that the following two definitions are _highly_ dependent 88c2ecf20Sopenharmony_ci on the contexts in which they are used in the kernel. I personally 98c2ecf20Sopenharmony_ci think it is criminal how loosely defined these macros are. */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* We need to flush the kernel's icache after loading modules. The 128c2ecf20Sopenharmony_ci only other use of this macro is in load_aout_interp which is not 138c2ecf20Sopenharmony_ci used on Alpha. 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci Note that this definition should *not* be used for userspace 168c2ecf20Sopenharmony_ci icache flushing. While functional, it is _way_ overkill. The 178c2ecf20Sopenharmony_ci icache is tagged with ASNs and it suffices to allocate a new ASN 188c2ecf20Sopenharmony_ci for the process. */ 198c2ecf20Sopenharmony_ci#ifndef CONFIG_SMP 208c2ecf20Sopenharmony_ci#define flush_icache_range(start, end) imb() 218c2ecf20Sopenharmony_ci#else 228c2ecf20Sopenharmony_ci#define flush_icache_range(start, end) smp_imb() 238c2ecf20Sopenharmony_ciextern void smp_imb(void); 248c2ecf20Sopenharmony_ci#endif 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci/* We need to flush the userspace icache after setting breakpoints in 278c2ecf20Sopenharmony_ci ptrace. 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci Instead of indiscriminately using imb, take advantage of the fact 308c2ecf20Sopenharmony_ci that icache entries are tagged with the ASN and load a new mm context. */ 318c2ecf20Sopenharmony_ci/* ??? Ought to use this in arch/alpha/kernel/signal.c too. */ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#ifndef CONFIG_SMP 348c2ecf20Sopenharmony_ci#include <linux/sched.h> 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ciextern void __load_new_mm_context(struct mm_struct *); 378c2ecf20Sopenharmony_cistatic inline void 388c2ecf20Sopenharmony_ciflush_icache_user_page(struct vm_area_struct *vma, struct page *page, 398c2ecf20Sopenharmony_ci unsigned long addr, int len) 408c2ecf20Sopenharmony_ci{ 418c2ecf20Sopenharmony_ci if (vma->vm_flags & VM_EXEC) { 428c2ecf20Sopenharmony_ci struct mm_struct *mm = vma->vm_mm; 438c2ecf20Sopenharmony_ci if (current->active_mm == mm) 448c2ecf20Sopenharmony_ci __load_new_mm_context(mm); 458c2ecf20Sopenharmony_ci else 468c2ecf20Sopenharmony_ci mm->context[smp_processor_id()] = 0; 478c2ecf20Sopenharmony_ci } 488c2ecf20Sopenharmony_ci} 498c2ecf20Sopenharmony_ci#define flush_icache_user_page flush_icache_user_page 508c2ecf20Sopenharmony_ci#else /* CONFIG_SMP */ 518c2ecf20Sopenharmony_ciextern void flush_icache_user_page(struct vm_area_struct *vma, 528c2ecf20Sopenharmony_ci struct page *page, unsigned long addr, int len); 538c2ecf20Sopenharmony_ci#define flush_icache_user_page flush_icache_user_page 548c2ecf20Sopenharmony_ci#endif /* CONFIG_SMP */ 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* This is used only in __do_fault and do_swap_page. */ 578c2ecf20Sopenharmony_ci#define flush_icache_page(vma, page) \ 588c2ecf20Sopenharmony_ci flush_icache_user_page((vma), (page), 0, 0) 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci#include <asm-generic/cacheflush.h> 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci#endif /* _ALPHA_CACHEFLUSH_H */ 63