cacheflush.h 2.7 KB

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