cacheflush.h 4.3 KB

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