cacheflush.h 2.6 KB

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