blob: cd71273ec49d91aacffe3eff8883617ef94d8627 [file] [log] [blame]
Laura Abbott299878b2017-05-08 15:57:59 -07001#ifndef _ASM_X86_SET_MEMORY_H
2#define _ASM_X86_SET_MEMORY_H
3
4#include <asm/page.h>
5#include <asm-generic/set_memory.h>
6
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
Tom Lendacky77bd2342017-07-17 16:10:19 -050014 * Encryption : Encrypted, Decrypted
Laura Abbott299878b2017-05-08 15:57:59 -070015 *
16 * Within a category, the attributes are mutually exclusive.
17 *
18 * The implementation of this API will take care of various aspects that
19 * are associated with changing such attributes, such as:
20 * - Flushing TLBs
21 * - Flushing CPU caches
22 * - Making sure aliases of the memory behind the mapping don't violate
23 * coherency rules as defined by the CPU in the system.
24 *
25 * What this API does not do:
26 * - Provide exclusion between various callers - including callers that
27 * operation on other mappings of the same physical page
28 * - Restore default attributes when a page is freed
29 * - Guarantee that mappings other than the requested one are
30 * 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 * CPUs other than the one you have may have more relaxed rules.
33 * The caller is required to take care of these.
34 */
35
36int _set_memory_uc(unsigned long addr, int numpages);
37int _set_memory_wc(unsigned long addr, int numpages);
38int _set_memory_wt(unsigned long addr, int numpages);
39int _set_memory_wb(unsigned long addr, int numpages);
40int set_memory_uc(unsigned long addr, int numpages);
41int set_memory_wc(unsigned long addr, int numpages);
42int set_memory_wt(unsigned long addr, int numpages);
43int set_memory_wb(unsigned long addr, int numpages);
44int set_memory_np(unsigned long addr, int numpages);
45int set_memory_4k(unsigned long addr, int numpages);
Tom Lendacky77bd2342017-07-17 16:10:19 -050046int set_memory_encrypted(unsigned long addr, int numpages);
47int set_memory_decrypted(unsigned long addr, int numpages);
Laura Abbott299878b2017-05-08 15:57:59 -070048
49int set_memory_array_uc(unsigned long *addr, int addrinarray);
50int set_memory_array_wc(unsigned long *addr, int addrinarray);
51int set_memory_array_wt(unsigned long *addr, int addrinarray);
52int set_memory_array_wb(unsigned long *addr, int addrinarray);
53
54int set_pages_array_uc(struct page **pages, int addrinarray);
55int set_pages_array_wc(struct page **pages, int addrinarray);
56int set_pages_array_wt(struct page **pages, int addrinarray);
57int set_pages_array_wb(struct page **pages, int addrinarray);
58
59/*
60 * For legacy compatibility with the old APIs, a few functions
61 * are provided that work on a "struct page".
62 * These functions operate ONLY on the 1:1 kernel mapping of the
63 * memory that the struct page represents, and internally just
64 * call the set_memory_* function. See the description of the
65 * set_memory_* function for more details on conventions.
66 *
67 * These APIs should be considered *deprecated* and are likely going to
68 * be removed in the future.
69 * The reason for this is the implicit operation on the 1:1 mapping only,
70 * making this not a generally useful API.
71 *
72 * Specifically, many users of the old APIs had a virtual address,
73 * called virt_to_page() or vmalloc_to_page() on that address to
74 * get a struct page* that the old API required.
75 * To convert these cases, use set_memory_*() on the original
76 * virtual address, do not use these functions.
77 */
78
79int set_pages_uc(struct page *page, int numpages);
80int set_pages_wb(struct page *page, int numpages);
81int set_pages_x(struct page *page, int numpages);
82int set_pages_nx(struct page *page, int numpages);
83int set_pages_ro(struct page *page, int numpages);
84int set_pages_rw(struct page *page, int numpages);
85
86extern int kernel_set_to_readonly;
87void set_kernel_text_rw(void);
88void set_kernel_text_ro(void);
89
90#endif /* _ASM_X86_SET_MEMORY_H */