/* SPDX-License-Identifier: GPL-2.0 */1#ifndef _ALPHA_CACHEFLUSH_H2#define _ALPHA_CACHEFLUSH_H34#include <linux/mm.h>56/* Note that the following two definitions are _highly_ dependent7on the contexts in which they are used in the kernel. I personally8think it is criminal how loosely defined these macros are. */910/* We need to flush the kernel's icache after loading modules. The11only other use of this macro is in load_aout_interp which is not12used on Alpha.1314Note that this definition should *not* be used for userspace15icache flushing. While functional, it is _way_ overkill. The16icache is tagged with ASNs and it suffices to allocate a new ASN17for the process. */18#ifndef CONFIG_SMP19#define flush_icache_range(start, end) imb()20#else21#define flush_icache_range(start, end) smp_imb()22extern void smp_imb(void);23#endif2425/* We need to flush the userspace icache after setting breakpoints in26ptrace.2728Instead of indiscriminately using imb, take advantage of the fact29that icache entries are tagged with the ASN and load a new mm context. */30/* ??? Ought to use this in arch/alpha/kernel/signal.c too. */3132#ifndef CONFIG_SMP33#include <linux/sched.h>3435extern void __load_new_mm_context(struct mm_struct *);36static inline void37flush_icache_user_page(struct vm_area_struct *vma, struct page *page,38unsigned long addr, int len)39{40if (vma->vm_flags & VM_EXEC) {41struct mm_struct *mm = vma->vm_mm;42if (current->active_mm == mm)43__load_new_mm_context(mm);44else45mm->context[smp_processor_id()] = 0;46}47}48#define flush_icache_user_page flush_icache_user_page49#else /* CONFIG_SMP */50extern void flush_icache_user_page(struct vm_area_struct *vma,51struct page *page, unsigned long addr, int len);52#define flush_icache_user_page flush_icache_user_page53#endif /* CONFIG_SMP */5455/*56* Both implementations of flush_icache_user_page flush the entire57* address space, so one call, no matter how many pages.58*/59static inline void flush_icache_pages(struct vm_area_struct *vma,60struct page *page, unsigned int nr)61{62flush_icache_user_page(vma, page, 0, 0);63}64#define flush_icache_pages flush_icache_pages6566#include <asm-generic/cacheflush.h>6768#endif /* _ALPHA_CACHEFLUSH_H */697071