cacheflush.h 4.1 KB

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