cacheflush.h 2.6 KB

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