1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_SET_MEMORY_H
3 #define _ASM_X86_SET_MEMORY_H
4 
5 #include <asm/page.h>
6 #include <asm-generic/set_memory.h>
7 
8 #define set_memory_rox set_memory_rox
9 int set_memory_rox(unsigned long addr, int numpages);
10 
11 /*
12  * The set_memory_* API can be used to change various attributes of a virtual
13  * address range. The attributes include:
14  * Cacheability  : UnCached, WriteCombining, WriteThrough, WriteBack
15  * Executability : eXecutable, NoteXecutable
16  * Read/Write    : ReadOnly, ReadWrite
17  * Presence      : NotPresent
18  * Encryption    : Encrypted, Decrypted
19  *
20  * Within a category, the attributes are mutually exclusive.
21  *
22  * The implementation of this API will take care of various aspects that
23  * are associated with changing such attributes, such as:
24  * - Flushing TLBs
25  * - Flushing CPU caches
26  * - Making sure aliases of the memory behind the mapping don't violate
27  *   coherency rules as defined by the CPU in the system.
28  *
29  * What this API does not do:
30  * - Provide exclusion between various callers - including callers that
31  *   operation on other mappings of the same physical page
32  * - Restore default attributes when a page is freed
33  * - Guarantee that mappings other than the requested one are
34  *   in any state, other than that these do not violate rules for
35  *   the CPU you have. Do not depend on any effects on other mappings,
36  *   CPUs other than the one you have may have more relaxed rules.
37  * The caller is required to take care of these.
38  */
39 
40 int _set_memory_uc(unsigned long addr, int numpages);
41 int _set_memory_wc(unsigned long addr, int numpages);
42 int _set_memory_wt(unsigned long addr, int numpages);
43 int _set_memory_wb(unsigned long addr, int numpages);
44 int set_memory_uc(unsigned long addr, int numpages);
45 int set_memory_wc(unsigned long addr, int numpages);
46 int set_memory_wb(unsigned long addr, int numpages);
47 int set_memory_np(unsigned long addr, int numpages);
48 int set_memory_p(unsigned long addr, int numpages);
49 int set_memory_4k(unsigned long addr, int numpages);
50 
51 bool set_memory_enc_stop_conversion(void);
52 int set_memory_encrypted(unsigned long addr, int numpages);
53 int set_memory_decrypted(unsigned long addr, int numpages);
54 
55 int set_memory_np_noalias(unsigned long addr, int numpages);
56 int set_memory_nonglobal(unsigned long addr, int numpages);
57 int set_memory_global(unsigned long addr, int numpages);
58 
59 int set_pages_array_uc(struct page **pages, int addrinarray);
60 int set_pages_array_wc(struct page **pages, int addrinarray);
61 int set_pages_array_wb(struct page **pages, int addrinarray);
62 
63 /*
64  * For legacy compatibility with the old APIs, a few functions
65  * are provided that work on a "struct page".
66  * These functions operate ONLY on the 1:1 kernel mapping of the
67  * memory that the struct page represents, and internally just
68  * call the set_memory_* function. See the description of the
69  * set_memory_* function for more details on conventions.
70  *
71  * These APIs should be considered *deprecated* and are likely going to
72  * be removed in the future.
73  * The reason for this is the implicit operation on the 1:1 mapping only,
74  * making this not a generally useful API.
75  *
76  * Specifically, many users of the old APIs had a virtual address,
77  * called virt_to_page() or vmalloc_to_page() on that address to
78  * get a struct page* that the old API required.
79  * To convert these cases, use set_memory_*() on the original
80  * virtual address, do not use these functions.
81  */
82 
83 int set_pages_uc(struct page *page, int numpages);
84 int set_pages_wb(struct page *page, int numpages);
85 int set_pages_ro(struct page *page, int numpages);
86 int set_pages_rw(struct page *page, int numpages);
87 
88 int set_direct_map_invalid_noflush(struct page *page);
89 int set_direct_map_default_noflush(struct page *page);
90 int set_direct_map_valid_noflush(struct page *page, unsigned nr, bool valid);
91 bool kernel_page_present(struct page *page);
92 
93 extern int kernel_set_to_readonly;
94 
95 #endif /* _ASM_X86_SET_MEMORY_H */
96