cacheflush.h 2.5 KB

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