Merge tag 'nfs-for-4.5-2' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
[deliverable/linux.git] / arch / x86 / include / asm / cacheflush.h
CommitLineData
1965aae3
PA
1#ifndef _ASM_X86_CACHEFLUSH_H
2#define _ASM_X86_CACHEFLUSH_H
b2bba72c 3
b2bba72c 4/* Caches aren't brain-dead on the intel. */
cc67ba63 5#include <asm-generic/cacheflush.h>
f05e798a 6#include <asm/special_insns.h>
61031952 7#include <asm/uaccess.h>
b2bba72c 8
7219bebd
AV
9/*
10 * The set_memory_* API can be used to change various attributes of a virtual
11 * address range. The attributes include:
623dffb2 12 * Cachability : UnCached, WriteCombining, WriteThrough, WriteBack
7219bebd
AV
13 * Executability : eXeutable, NoteXecutable
14 * Read/Write : ReadOnly, ReadWrite
15 * Presence : NotPresent
16 *
0d2eb44f 17 * Within a category, the attributes are mutually exclusive.
7219bebd
AV
18 *
19 * The implementation of this API will take care of various aspects that
20 * are associated with changing such attributes, such as:
21 * - Flushing TLBs
22 * - Flushing CPU caches
23 * - Making sure aliases of the memory behind the mapping don't violate
24 * coherency rules as defined by the CPU in the system.
25 *
26 * What this API does not do:
27 * - Provide exclusion between various callers - including callers that
28 * operation on other mappings of the same physical page
29 * - Restore default attributes when a page is freed
30 * - Guarantee that mappings other than the requested one are
31 * in any state, other than that these do not violate rules for
32 * the CPU you have. Do not depend on any effects on other mappings,
33 * CPUs other than the one you have may have more relaxed rules.
34 * The caller is required to take care of these.
35 */
75cbade8 36
1219333d 37int _set_memory_uc(unsigned long addr, int numpages);
ef354af4 38int _set_memory_wc(unsigned long addr, int numpages);
623dffb2 39int _set_memory_wt(unsigned long addr, int numpages);
1219333d 40int _set_memory_wb(unsigned long addr, int numpages);
75cbade8 41int set_memory_uc(unsigned long addr, int numpages);
ef354af4 42int set_memory_wc(unsigned long addr, int numpages);
623dffb2 43int set_memory_wt(unsigned long addr, int numpages);
75cbade8
AV
44int set_memory_wb(unsigned long addr, int numpages);
45int set_memory_x(unsigned long addr, int numpages);
46int set_memory_nx(unsigned long addr, int numpages);
47int set_memory_ro(unsigned long addr, int numpages);
48int set_memory_rw(unsigned long addr, int numpages);
f62d0f00 49int set_memory_np(unsigned long addr, int numpages);
c9caa02c 50int set_memory_4k(unsigned long addr, int numpages);
75cbade8 51
d75586ad 52int set_memory_array_uc(unsigned long *addr, int addrinarray);
4f646254 53int set_memory_array_wc(unsigned long *addr, int addrinarray);
623dffb2 54int set_memory_array_wt(unsigned long *addr, int addrinarray);
d75586ad
SL
55int set_memory_array_wb(unsigned long *addr, int addrinarray);
56
0f350755 57int set_pages_array_uc(struct page **pages, int addrinarray);
4f646254 58int set_pages_array_wc(struct page **pages, int addrinarray);
623dffb2 59int set_pages_array_wt(struct page **pages, int addrinarray);
0f350755 60int set_pages_array_wb(struct page **pages, int addrinarray);
61
7219bebd
AV
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
82int set_pages_uc(struct page *page, int numpages);
83int set_pages_wb(struct page *page, int numpages);
84int set_pages_x(struct page *page, int numpages);
85int set_pages_nx(struct page *page, int numpages);
86int set_pages_ro(struct page *page, int numpages);
87int set_pages_rw(struct page *page, int numpages);
88
89
4c61afcd 90void clflush_cache_range(void *addr, unsigned int size);
b2bba72c 91
67a3e8fe
RZ
92#define mmio_flush_range(addr, size) clflush_cache_range(addr, size)
93
b2bba72c
TG
94#ifdef CONFIG_DEBUG_RODATA
95void mark_rodata_ro(void);
7bfeab9a 96extern const int rodata_test_data;
502f6604 97extern int kernel_set_to_readonly;
16239630
SR
98void set_kernel_text_rw(void);
99void set_kernel_text_ro(void);
100#else
101static inline void set_kernel_text_rw(void) { }
102static inline void set_kernel_text_ro(void) { }
b2bba72c 103#endif
7bfeab9a 104
edeed305 105#ifdef CONFIG_DEBUG_RODATA_TEST
7bfeab9a 106int rodata_test(void);
edeed305 107#else
7bfeab9a 108static inline int rodata_test(void)
edeed305 109{
7bfeab9a 110 return 0;
edeed305
AV
111}
112#endif
b2bba72c 113
1965aae3 114#endif /* _ASM_X86_CACHEFLUSH_H */
This page took 0.547184 seconds and 5 git commands to generate.