Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ALPHA_CACHEFLUSH_H
0003 #define _ALPHA_CACHEFLUSH_H
0004 
0005 #include <linux/mm.h>
0006 
0007 /* Note that the following two definitions are _highly_ dependent
0008    on the contexts in which they are used in the kernel.  I personally
0009    think it is criminal how loosely defined these macros are.  */
0010 
0011 /* We need to flush the kernel's icache after loading modules.  The
0012    only other use of this macro is in load_aout_interp which is not
0013    used on Alpha. 
0014 
0015    Note that this definition should *not* be used for userspace
0016    icache flushing.  While functional, it is _way_ overkill.  The
0017    icache is tagged with ASNs and it suffices to allocate a new ASN
0018    for the process.  */
0019 #ifndef CONFIG_SMP
0020 #define flush_icache_range(start, end)      imb()
0021 #else
0022 #define flush_icache_range(start, end)      smp_imb()
0023 extern void smp_imb(void);
0024 #endif
0025 
0026 /* We need to flush the userspace icache after setting breakpoints in
0027    ptrace.
0028 
0029    Instead of indiscriminately using imb, take advantage of the fact
0030    that icache entries are tagged with the ASN and load a new mm context.  */
0031 /* ??? Ought to use this in arch/alpha/kernel/signal.c too.  */
0032 
0033 #ifndef CONFIG_SMP
0034 #include <linux/sched.h>
0035 
0036 extern void __load_new_mm_context(struct mm_struct *);
0037 static inline void
0038 flush_icache_user_page(struct vm_area_struct *vma, struct page *page,
0039             unsigned long addr, int len)
0040 {
0041     if (vma->vm_flags & VM_EXEC) {
0042         struct mm_struct *mm = vma->vm_mm;
0043         if (current->active_mm == mm)
0044             __load_new_mm_context(mm);
0045         else
0046             mm->context[smp_processor_id()] = 0;
0047     }
0048 }
0049 #define flush_icache_user_page flush_icache_user_page
0050 #else /* CONFIG_SMP */
0051 extern void flush_icache_user_page(struct vm_area_struct *vma,
0052         struct page *page, unsigned long addr, int len);
0053 #define flush_icache_user_page flush_icache_user_page
0054 #endif /* CONFIG_SMP */
0055 
0056 /* This is used only in __do_fault and do_swap_page.  */
0057 #define flush_icache_page(vma, page) \
0058     flush_icache_user_page((vma), (page), 0, 0)
0059 
0060 #include <asm-generic/cacheflush.h>
0061 
0062 #endif /* _ALPHA_CACHEFLUSH_H */