cacheflush.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #ifndef ASM_X86__CACHEFLUSH_H
  2. #define ASM_X86__CACHEFLUSH_H
  3. /* Keep includes the same across arches. */
  4. #include <linux/mm.h>
  5. /* Caches aren't brain-dead on the intel. */
  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 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_icache_range(start, end) do { } while (0)
  15. #define flush_icache_page(vma, pg) do { } while (0)
  16. #define flush_icache_user_range(vma, pg, adr, len) do { } while (0)
  17. #define flush_cache_vmap(start, end) do { } while (0)
  18. #define flush_cache_vunmap(start, end) do { } while (0)
  19. #define copy_to_user_page(vma, page, vaddr, dst, src, len) \
  20. memcpy((dst), (src), (len))
  21. #define copy_from_user_page(vma, page, vaddr, dst, src, len) \
  22. memcpy((dst), (src), (len))
  23. #define PG_non_WB PG_arch_1
  24. PAGEFLAG(NonWB, non_WB)
  25. /*
  26. * The set_memory_* API can be used to change various attributes of a virtual
  27. * address range. The attributes include:
  28. * Cachability : UnCached, WriteCombining, WriteBack
  29. * Executability : eXeutable, NoteXecutable
  30. * Read/Write : ReadOnly, ReadWrite
  31. * Presence : NotPresent
  32. *
  33. * Within a catagory, the attributes are mutually exclusive.
  34. *
  35. * The implementation of this API will take care of various aspects that
  36. * are associated with changing such attributes, such as:
  37. * - Flushing TLBs
  38. * - Flushing CPU caches
  39. * - Making sure aliases of the memory behind the mapping don't violate
  40. * coherency rules as defined by the CPU in the system.
  41. *
  42. * What this API does not do:
  43. * - Provide exclusion between various callers - including callers that
  44. * operation on other mappings of the same physical page
  45. * - Restore default attributes when a page is freed
  46. * - Guarantee that mappings other than the requested one are
  47. * in any state, other than that these do not violate rules for
  48. * the CPU you have. Do not depend on any effects on other mappings,
  49. * CPUs other than the one you have may have more relaxed rules.
  50. * The caller is required to take care of these.
  51. */
  52. int _set_memory_uc(unsigned long addr, int numpages);
  53. int _set_memory_wc(unsigned long addr, int numpages);
  54. int _set_memory_wb(unsigned long addr, int numpages);
  55. int set_memory_uc(unsigned long addr, int numpages);
  56. int set_memory_wc(unsigned long addr, int numpages);
  57. int set_memory_wb(unsigned long addr, int numpages);
  58. int set_memory_x(unsigned long addr, int numpages);
  59. int set_memory_nx(unsigned long addr, int numpages);
  60. int set_memory_ro(unsigned long addr, int numpages);
  61. int set_memory_rw(unsigned long addr, int numpages);
  62. int set_memory_np(unsigned long addr, int numpages);
  63. int set_memory_4k(unsigned long addr, int numpages);
  64. int set_memory_array_uc(unsigned long *addr, int addrinarray);
  65. int set_memory_array_wb(unsigned long *addr, int addrinarray);
  66. /*
  67. * For legacy compatibility with the old APIs, a few functions
  68. * are provided that work on a "struct page".
  69. * These functions operate ONLY on the 1:1 kernel mapping of the
  70. * memory that the struct page represents, and internally just
  71. * call the set_memory_* function. See the description of the
  72. * set_memory_* function for more details on conventions.
  73. *
  74. * These APIs should be considered *deprecated* and are likely going to
  75. * be removed in the future.
  76. * The reason for this is the implicit operation on the 1:1 mapping only,
  77. * making this not a generally useful API.
  78. *
  79. * Specifically, many users of the old APIs had a virtual address,
  80. * called virt_to_page() or vmalloc_to_page() on that address to
  81. * get a struct page* that the old API required.
  82. * To convert these cases, use set_memory_*() on the original
  83. * virtual address, do not use these functions.
  84. */
  85. int set_pages_uc(struct page *page, int numpages);
  86. int set_pages_wb(struct page *page, int numpages);
  87. int set_pages_x(struct page *page, int numpages);
  88. int set_pages_nx(struct page *page, int numpages);
  89. int set_pages_ro(struct page *page, int numpages);
  90. int set_pages_rw(struct page *page, int numpages);
  91. void clflush_cache_range(void *addr, unsigned int size);
  92. #ifdef CONFIG_DEBUG_RODATA
  93. void mark_rodata_ro(void);
  94. extern const int rodata_test_data;
  95. #endif
  96. #ifdef CONFIG_DEBUG_RODATA_TEST
  97. int rodata_test(void);
  98. #else
  99. static inline int rodata_test(void)
  100. {
  101. return 0;
  102. }
  103. #endif
  104. #endif /* ASM_X86__CACHEFLUSH_H */