Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright 2017, Michael Ellerman, IBM Corporation.
0004  */
0005 #ifndef _LINUX_SET_MEMORY_H_
0006 #define _LINUX_SET_MEMORY_H_
0007 
0008 #ifdef CONFIG_ARCH_HAS_SET_MEMORY
0009 #include <asm/set_memory.h>
0010 #else
0011 static inline int set_memory_ro(unsigned long addr, int numpages) { return 0; }
0012 static inline int set_memory_rw(unsigned long addr, int numpages) { return 0; }
0013 static inline int set_memory_x(unsigned long addr,  int numpages) { return 0; }
0014 static inline int set_memory_nx(unsigned long addr, int numpages) { return 0; }
0015 #endif
0016 
0017 #ifndef CONFIG_ARCH_HAS_SET_DIRECT_MAP
0018 static inline int set_direct_map_invalid_noflush(struct page *page)
0019 {
0020     return 0;
0021 }
0022 static inline int set_direct_map_default_noflush(struct page *page)
0023 {
0024     return 0;
0025 }
0026 
0027 static inline bool kernel_page_present(struct page *page)
0028 {
0029     return true;
0030 }
0031 #else /* CONFIG_ARCH_HAS_SET_DIRECT_MAP */
0032 /*
0033  * Some architectures, e.g. ARM64 can disable direct map modifications at
0034  * boot time. Let them overrive this query.
0035  */
0036 #ifndef can_set_direct_map
0037 static inline bool can_set_direct_map(void)
0038 {
0039     return true;
0040 }
0041 #define can_set_direct_map can_set_direct_map
0042 #endif
0043 #endif /* CONFIG_ARCH_HAS_SET_DIRECT_MAP */
0044 
0045 #ifdef CONFIG_X86_64
0046 int set_mce_nospec(unsigned long pfn);
0047 int clear_mce_nospec(unsigned long pfn);
0048 #else
0049 static inline int set_mce_nospec(unsigned long pfn)
0050 {
0051     return 0;
0052 }
0053 static inline int clear_mce_nospec(unsigned long pfn)
0054 {
0055     return 0;
0056 }
0057 #endif
0058 
0059 #ifndef CONFIG_ARCH_HAS_MEM_ENCRYPT
0060 static inline int set_memory_encrypted(unsigned long addr, int numpages)
0061 {
0062     return 0;
0063 }
0064 
0065 static inline int set_memory_decrypted(unsigned long addr, int numpages)
0066 {
0067     return 0;
0068 }
0069 #endif /* CONFIG_ARCH_HAS_MEM_ENCRYPT */
0070 
0071 #endif /* _LINUX_SET_MEMORY_H_ */