1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2017, Michael Ellerman, IBM Corporation.
5 #ifndef _LINUX_SET_MEMORY_H_
6 #define _LINUX_SET_MEMORY_H_
8 #ifdef CONFIG_ARCH_HAS_SET_MEMORY
9 #include <asm/set_memory.h>
11 static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; }
12 static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; }
13 static inline int set_memory_x(unsigned long addr, int numpages) { return 0; }
14 static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; }
17 #ifndef set_memory_rox
18 static inline int set_memory_rox(unsigned long addr, int numpages)
20 int ret = set_memory_ro(addr, numpages);
23 return set_memory_x(addr, numpages);
27 #ifndef CONFIG_ARCH_HAS_SET_DIRECT_MAP
28 static inline int set_direct_map_invalid_noflush(struct page *page)
32 static inline int set_direct_map_default_noflush(struct page *page)
37 static inline bool kernel_page_present(struct page *page)
41 #else /* CONFIG_ARCH_HAS_SET_DIRECT_MAP */
43 * Some architectures, e.g. ARM64 can disable direct map modifications at
44 * boot time. Let them overrive this query.
46 #ifndef can_set_direct_map
47 static inline bool can_set_direct_map(void)
51 #define can_set_direct_map can_set_direct_map
53 #endif /* CONFIG_ARCH_HAS_SET_DIRECT_MAP */
56 int set_mce_nospec(unsigned long pfn);
57 int clear_mce_nospec(unsigned long pfn);
59 static inline int set_mce_nospec(unsigned long pfn)
63 static inline int clear_mce_nospec(unsigned long pfn)
69 #ifndef CONFIG_ARCH_HAS_MEM_ENCRYPT
70 static inline int set_memory_encrypted(unsigned long addr, int numpages)
75 static inline int set_memory_decrypted(unsigned long addr, int numpages)
79 #endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */
81 #endif /* _LINUX_SET_MEMORY_H_ */