cacheflush.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef _ASM_X86_CACHEFLUSH_H
  2. #define _ASM_X86_CACHEFLUSH_H
  3. /* Caches aren't brain-dead on the intel. */
  4. #include <asm-generic/cacheflush.h>
  5. #include <asm/special_insns.h>
  6. #include <asm/uaccess.h>
  7. /*
  8. * The set_memory_* API can be used to change various attributes of a virtual
  9. * address range. The attributes include:
  10. * Cachability : UnCached, WriteCombining, WriteThrough, WriteBack
  11. * Executability : eXeutable, NoteXecutable
  12. * Read/Write : ReadOnly, ReadWrite
  13. * Presence : NotPresent
  14. *
  15. * Within a category, the attributes are mutually exclusive.
  16. *
  17. * The implementation of this API will take care of various aspects that
  18. * are associated with changing such attributes, such as:
  19. * - Flushing TLBs
  20. * - Flushing CPU caches
  21. * - Making sure aliases of the memory behind the mapping don't violate
  22. * coherency rules as defined by the CPU in the system.
  23. *
  24. * What this API does not do:
  25. * - Provide exclusion between various callers - including callers that
  26. * operation on other mappings of the same physical page
  27. * - Restore default attributes when a page is freed
  28. * - Guarantee that mappings other than the requested one are
  29. * in any state, other than that these do not violate rules for
  30. * the CPU you have. Do not depend on any effects on other mappings,
  31. * CPUs other than the one you have may have more relaxed rules.
  32. * The caller is required to take care of these.
  33. */
  34. int _set_memory_uc(unsigned long addr, int numpages);
  35. int _set_memory_wc(unsigned long addr, int numpages);
  36. int _set_memory_wt(unsigned long addr, int numpages);
  37. int _set_memory_wb(unsigned long addr, int numpages);
  38. int set_memory_uc(unsigned long addr, int numpages);
  39. int set_memory_wc(unsigned long addr, int numpages);
  40. int set_memory_wt(unsigned long addr, int numpages);
  41. int set_memory_wb(unsigned long addr, int numpages);
  42. int set_memory_x(unsigned long addr, int numpages);
  43. int set_memory_nx(unsigned long addr, int numpages);
  44. int set_memory_ro(unsigned long addr, int numpages);
  45. int set_memory_rw(unsigned long addr, int numpages);
  46. int set_memory_np(unsigned long addr, int numpages);
  47. int set_memory_4k(unsigned long addr, int numpages);
  48. int set_memory_array_uc(unsigned long *addr, int addrinarray);
  49. int set_memory_array_wc(unsigned long *addr, int addrinarray);
  50. int set_memory_array_wt(unsigned long *addr, int addrinarray);
  51. int set_memory_array_wb(unsigned long *addr, int addrinarray);
  52. int set_pages_array_uc(struct page **pages, int addrinarray);
  53. int set_pages_array_wc(struct page **pages, int addrinarray);
  54. int set_pages_array_wt(struct page **pages, int addrinarray);
  55. int set_pages_array_wb(struct page **pages, int addrinarray);
  56. /*
  57. * For legacy compatibility with the old APIs, a few functions
  58. * are provided that work on a "struct page".
  59. * These functions operate ONLY on the 1:1 kernel mapping of the
  60. * memory that the struct page represents, and internally just
  61. * call the set_memory_* function. See the description of the
  62. * set_memory_* function for more details on conventions.
  63. *
  64. * These APIs should be considered *deprecated* and are likely going to
  65. * be removed in the future.
  66. * The reason for this is the implicit operation on the 1:1 mapping only,
  67. * making this not a generally useful API.
  68. *
  69. * Specifically, many users of the old APIs had a virtual address,
  70. * called virt_to_page() or vmalloc_to_page() on that address to
  71. * get a struct page* that the old API required.
  72. * To convert these cases, use set_memory_*() on the original
  73. * virtual address, do not use these functions.
  74. */
  75. int set_pages_uc(struct page *page, int numpages);
  76. int set_pages_wb(struct page *page, int numpages);
  77. int set_pages_x(struct page *page, int numpages);
  78. int set_pages_nx(struct page *page, int numpages);
  79. int set_pages_ro(struct page *page, int numpages);
  80. int set_pages_rw(struct page *page, int numpages);
  81. void clflush_cache_range(void *addr, unsigned int size);
  82. #define mmio_flush_range(addr, size) clflush_cache_range(addr, size)
  83. #ifdef CONFIG_DEBUG_RODATA
  84. void mark_rodata_ro(void);
  85. extern const int rodata_test_data;
  86. extern int kernel_set_to_readonly;
  87. void set_kernel_text_rw(void);
  88. void set_kernel_text_ro(void);
  89. #else
  90. static inline void set_kernel_text_rw(void) { }
  91. static inline void set_kernel_text_ro(void) { }
  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 /* _ASM_X86_CACHEFLUSH_H */