Rev 6934 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6934 | Rev 7143 | ||
---|---|---|---|
1 | #ifndef _ASM_X86_CACHEFLUSH_H |
1 | #ifndef _ASM_X86_CACHEFLUSH_H |
2 | #define _ASM_X86_CACHEFLUSH_H |
2 | #define _ASM_X86_CACHEFLUSH_H |
3 | 3 | ||
4 | /* Caches aren't brain-dead on the intel. */ |
4 | /* Caches aren't brain-dead on the intel. */ |
5 | #include |
5 | #include |
6 | #include |
6 | #include |
- | 7 | #include |
|
7 | 8 | ||
8 | /* |
9 | /* |
9 | * The set_memory_* API can be used to change various attributes of a virtual |
10 | * The set_memory_* API can be used to change various attributes of a virtual |
10 | * address range. The attributes include: |
11 | * address range. The attributes include: |
11 | * Cachability : UnCached, WriteCombining, WriteThrough, WriteBack |
12 | * Cachability : UnCached, WriteCombining, WriteThrough, WriteBack |
12 | * Executability : eXeutable, NoteXecutable |
13 | * Executability : eXeutable, NoteXecutable |
13 | * Read/Write : ReadOnly, ReadWrite |
14 | * Read/Write : ReadOnly, ReadWrite |
14 | * Presence : NotPresent |
15 | * Presence : NotPresent |
15 | * |
16 | * |
16 | * Within a category, the attributes are mutually exclusive. |
17 | * Within a category, the attributes are mutually exclusive. |
17 | * |
18 | * |
18 | * The implementation of this API will take care of various aspects that |
19 | * The implementation of this API will take care of various aspects that |
19 | * are associated with changing such attributes, such as: |
20 | * are associated with changing such attributes, such as: |
20 | * - Flushing TLBs |
21 | * - Flushing TLBs |
21 | * - Flushing CPU caches |
22 | * - Flushing CPU caches |
22 | * - Making sure aliases of the memory behind the mapping don't violate |
23 | * - Making sure aliases of the memory behind the mapping don't violate |
23 | * coherency rules as defined by the CPU in the system. |
24 | * coherency rules as defined by the CPU in the system. |
24 | * |
25 | * |
25 | * What this API does not do: |
26 | * What this API does not do: |
26 | * - Provide exclusion between various callers - including callers that |
27 | * - Provide exclusion between various callers - including callers that |
27 | * operation on other mappings of the same physical page |
28 | * operation on other mappings of the same physical page |
28 | * - Restore default attributes when a page is freed |
29 | * - Restore default attributes when a page is freed |
29 | * - Guarantee that mappings other than the requested one are |
30 | * - Guarantee that mappings other than the requested one are |
30 | * in any state, other than that these do not violate rules for |
31 | * in any state, other than that these do not violate rules for |
31 | * the CPU you have. Do not depend on any effects on other mappings, |
32 | * the CPU you have. Do not depend on any effects on other mappings, |
32 | * CPUs other than the one you have may have more relaxed rules. |
33 | * CPUs other than the one you have may have more relaxed rules. |
33 | * The caller is required to take care of these. |
34 | * The caller is required to take care of these. |
34 | */ |
35 | */ |
35 | 36 | ||
36 | int _set_memory_uc(unsigned long addr, int numpages); |
37 | int _set_memory_uc(unsigned long addr, int numpages); |
37 | int _set_memory_wc(unsigned long addr, int numpages); |
38 | int _set_memory_wc(unsigned long addr, int numpages); |
38 | int _set_memory_wt(unsigned long addr, int numpages); |
39 | int _set_memory_wt(unsigned long addr, int numpages); |
39 | int _set_memory_wb(unsigned long addr, int numpages); |
40 | int _set_memory_wb(unsigned long addr, int numpages); |
40 | int set_memory_uc(unsigned long addr, int numpages); |
41 | int set_memory_uc(unsigned long addr, int numpages); |
41 | int set_memory_wc(unsigned long addr, int numpages); |
42 | int set_memory_wc(unsigned long addr, int numpages); |
42 | int set_memory_wt(unsigned long addr, int numpages); |
43 | int set_memory_wt(unsigned long addr, int numpages); |
43 | int set_memory_wb(unsigned long addr, int numpages); |
44 | int set_memory_wb(unsigned long addr, int numpages); |
44 | int set_memory_x(unsigned long addr, int numpages); |
45 | int set_memory_x(unsigned long addr, int numpages); |
45 | int set_memory_nx(unsigned long addr, int numpages); |
46 | int set_memory_nx(unsigned long addr, int numpages); |
46 | int set_memory_ro(unsigned long addr, int numpages); |
47 | int set_memory_ro(unsigned long addr, int numpages); |
47 | int set_memory_rw(unsigned long addr, int numpages); |
48 | int set_memory_rw(unsigned long addr, int numpages); |
48 | int set_memory_np(unsigned long addr, int numpages); |
49 | int set_memory_np(unsigned long addr, int numpages); |
49 | int set_memory_4k(unsigned long addr, int numpages); |
50 | int set_memory_4k(unsigned long addr, int numpages); |
50 | 51 | ||
51 | int set_memory_array_uc(unsigned long *addr, int addrinarray); |
52 | int set_memory_array_uc(unsigned long *addr, int addrinarray); |
52 | int set_memory_array_wc(unsigned long *addr, int addrinarray); |
53 | int set_memory_array_wc(unsigned long *addr, int addrinarray); |
53 | int set_memory_array_wt(unsigned long *addr, int addrinarray); |
54 | int set_memory_array_wt(unsigned long *addr, int addrinarray); |
54 | int set_memory_array_wb(unsigned long *addr, int addrinarray); |
55 | int set_memory_array_wb(unsigned long *addr, int addrinarray); |
55 | 56 | ||
56 | int set_pages_array_uc(struct page **pages, int addrinarray); |
57 | int set_pages_array_uc(struct page **pages, int addrinarray); |
57 | int set_pages_array_wc(struct page **pages, int addrinarray); |
58 | int set_pages_array_wc(struct page **pages, int addrinarray); |
58 | int set_pages_array_wt(struct page **pages, int addrinarray); |
59 | int set_pages_array_wt(struct page **pages, int addrinarray); |
59 | int set_pages_array_wb(struct page **pages, int addrinarray); |
60 | int set_pages_array_wb(struct page **pages, int addrinarray); |
60 | 61 | ||
61 | /* |
62 | /* |
62 | * For legacy compatibility with the old APIs, a few functions |
63 | * For legacy compatibility with the old APIs, a few functions |
63 | * are provided that work on a "struct page". |
64 | * are provided that work on a "struct page". |
64 | * These functions operate ONLY on the 1:1 kernel mapping of the |
65 | * These functions operate ONLY on the 1:1 kernel mapping of the |
65 | * memory that the struct page represents, and internally just |
66 | * memory that the struct page represents, and internally just |
66 | * call the set_memory_* function. See the description of the |
67 | * call the set_memory_* function. See the description of the |
67 | * set_memory_* function for more details on conventions. |
68 | * set_memory_* function for more details on conventions. |
68 | * |
69 | * |
69 | * These APIs should be considered *deprecated* and are likely going to |
70 | * These APIs should be considered *deprecated* and are likely going to |
70 | * be removed in the future. |
71 | * be removed in the future. |
71 | * The reason for this is the implicit operation on the 1:1 mapping only, |
72 | * The reason for this is the implicit operation on the 1:1 mapping only, |
72 | * making this not a generally useful API. |
73 | * making this not a generally useful API. |
73 | * |
74 | * |
74 | * Specifically, many users of the old APIs had a virtual address, |
75 | * Specifically, many users of the old APIs had a virtual address, |
75 | * called virt_to_page() or vmalloc_to_page() on that address to |
76 | * called virt_to_page() or vmalloc_to_page() on that address to |
76 | * get a struct page* that the old API required. |
77 | * get a struct page* that the old API required. |
77 | * To convert these cases, use set_memory_*() on the original |
78 | * To convert these cases, use set_memory_*() on the original |
78 | * virtual address, do not use these functions. |
79 | * virtual address, do not use these functions. |
79 | */ |
80 | */ |
80 | 81 | ||
81 | static int set_pages_uc(struct page *page, int numpages) |
82 | static int set_pages_uc(struct page *page, int numpages) |
82 | { |
83 | { |
83 | return 0; |
84 | return 0; |
84 | }; |
85 | }; |
85 | 86 | ||
86 | static int set_pages_wb(struct page *page, int numpages) |
87 | static int set_pages_wb(struct page *page, int numpages) |
87 | { |
88 | { |
88 | return 0; |
89 | return 0; |
89 | }; |
90 | }; |
90 | 91 | ||
91 | static int set_pages_x(struct page *page, int numpages) |
92 | static int set_pages_x(struct page *page, int numpages) |
92 | { |
93 | { |
93 | return 0; |
94 | return 0; |
94 | }; |
95 | }; |
95 | 96 | ||
96 | static int set_pages_nx(struct page *page, int numpages) |
97 | static int set_pages_nx(struct page *page, int numpages) |
97 | { |
98 | { |
98 | return 0; |
99 | return 0; |
99 | }; |
100 | }; |
100 | 101 | ||
101 | static int set_pages_ro(struct page *page, int numpages) |
102 | static int set_pages_ro(struct page *page, int numpages) |
102 | { |
103 | { |
103 | return 0; |
104 | return 0; |
104 | }; |
105 | }; |
105 | 106 | ||
106 | static int set_pages_rw(struct page *page, int numpages) |
107 | static int set_pages_rw(struct page *page, int numpages) |
107 | { |
108 | { |
108 | return 0; |
109 | return 0; |
109 | }; |
110 | }; |
110 | 111 | ||
111 | 112 | ||
112 | void clflush_cache_range(void *addr, unsigned int size); |
113 | void clflush_cache_range(void *addr, unsigned int size); |
113 | 114 | ||
114 | #define mmio_flush_range(addr, size) clflush_cache_range(addr, size) |
115 | #define mmio_flush_range(addr, size) clflush_cache_range(addr, size) |
115 | - | ||
116 | #ifdef CONFIG_DEBUG_RODATA |
- | |
117 | void mark_rodata_ro(void); |
116 | |
118 | extern const int rodata_test_data; |
117 | extern const int rodata_test_data; |
119 | extern int kernel_set_to_readonly; |
118 | extern int kernel_set_to_readonly; |
120 | void set_kernel_text_rw(void); |
119 | void set_kernel_text_rw(void); |
121 | void set_kernel_text_ro(void); |
120 | void set_kernel_text_ro(void); |
122 | #else |
- | |
123 | static inline void set_kernel_text_rw(void) { } |
- | |
124 | static inline void set_kernel_text_ro(void) { } |
- | |
125 | #endif |
- | |
126 | 121 | ||
127 | #ifdef CONFIG_DEBUG_RODATA_TEST |
122 | #ifdef CONFIG_DEBUG_RODATA_TEST |
128 | int rodata_test(void); |
123 | int rodata_test(void); |
129 | #else |
124 | #else |
130 | static inline int rodata_test(void) |
125 | static inline int rodata_test(void) |
131 | { |
126 | { |
132 | return 0; |
127 | return 0; |
133 | } |
128 | } |
134 | #endif |
129 | #endif |
135 | 130 | ||
136 | #endif /* _ASM_X86_CACHEFLUSH_H */ |
131 | #endif /* _ASM_X86_CACHEFLUSH_H */ |