cacheflush.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ALPHA_CACHEFLUSH_H
  3. #define _ALPHA_CACHEFLUSH_H
  4. #include <linux/mm.h>
  5. /* Note that the following two definitions are _highly_ dependent
  6. on the contexts in which they are used in the kernel. I personally
  7. think it is criminal how loosely defined these macros are. */
  8. /* We need to flush the kernel's icache after loading modules. The
  9. only other use of this macro is in load_aout_interp which is not
  10. used on Alpha.
  11. Note that this definition should *not* be used for userspace
  12. icache flushing. While functional, it is _way_ overkill. The
  13. icache is tagged with ASNs and it suffices to allocate a new ASN
  14. for the process. */
  15. #ifndef CONFIG_SMP
  16. #define flush_icache_range(start, end) imb()
  17. #else
  18. #define flush_icache_range(start, end) smp_imb()
  19. extern void smp_imb(void);
  20. #endif
  21. /* We need to flush the userspace icache after setting breakpoints in
  22. ptrace.
  23. Instead of indiscriminately using imb, take advantage of the fact
  24. that icache entries are tagged with the ASN and load a new mm context. */
  25. /* ??? Ought to use this in arch/alpha/kernel/signal.c too. */
  26. #ifndef CONFIG_SMP
  27. #include <linux/sched.h>
  28. extern void __load_new_mm_context(struct mm_struct *);
  29. static inline void
  30. flush_icache_user_page(struct vm_area_struct *vma, struct page *page,
  31. unsigned long addr, int len)
  32. {
  33. if (vma->vm_flags & VM_EXEC) {
  34. struct mm_struct *mm = vma->vm_mm;
  35. if (current->active_mm == mm)
  36. __load_new_mm_context(mm);
  37. else
  38. mm->context[smp_processor_id()] = 0;
  39. }
  40. }
  41. #define flush_icache_user_page flush_icache_user_page
  42. #else /* CONFIG_SMP */
  43. extern void flush_icache_user_page(struct vm_area_struct *vma,
  44. struct page *page, unsigned long addr, int len);
  45. #define flush_icache_user_page flush_icache_user_page
  46. #endif /* CONFIG_SMP */
  47. /* This is used only in __do_fault and do_swap_page. */
  48. #define flush_icache_page(vma, page) \
  49. flush_icache_user_page((vma), (page), 0, 0)
  50. #include <asm-generic/cacheflush.h>
  51. #endif /* _ALPHA_CACHEFLUSH_H */