1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASMS390_SET_MEMORY_H 3 #define _ASMS390_SET_MEMORY_H 4 5 #include <linux/mutex.h> 6 7 extern struct mutex cpa_mutex; 8 9 enum { 10 _SET_MEMORY_RO_BIT, 11 _SET_MEMORY_RW_BIT, 12 _SET_MEMORY_NX_BIT, 13 _SET_MEMORY_X_BIT, 14 _SET_MEMORY_4K_BIT, 15 _SET_MEMORY_INV_BIT, 16 _SET_MEMORY_DEF_BIT, 17 }; 18 19 #define SET_MEMORY_RO BIT(_SET_MEMORY_RO_BIT) 20 #define SET_MEMORY_RW BIT(_SET_MEMORY_RW_BIT) 21 #define SET_MEMORY_NX BIT(_SET_MEMORY_NX_BIT) 22 #define SET_MEMORY_X BIT(_SET_MEMORY_X_BIT) 23 #define SET_MEMORY_4K BIT(_SET_MEMORY_4K_BIT) 24 #define SET_MEMORY_INV BIT(_SET_MEMORY_INV_BIT) 25 #define SET_MEMORY_DEF BIT(_SET_MEMORY_DEF_BIT) 26 27 int __set_memory(unsigned long addr, int numpages, unsigned long flags); 28 29 static inline int set_memory_ro(unsigned long addr, int numpages) 30 { 31 return __set_memory(addr, numpages, SET_MEMORY_RO); 32 } 33 34 static inline int set_memory_rw(unsigned long addr, int numpages) 35 { 36 return __set_memory(addr, numpages, SET_MEMORY_RW); 37 } 38 39 static inline int set_memory_nx(unsigned long addr, int numpages) 40 { 41 return __set_memory(addr, numpages, SET_MEMORY_NX); 42 } 43 44 static inline int set_memory_x(unsigned long addr, int numpages) 45 { 46 return __set_memory(addr, numpages, SET_MEMORY_X); 47 } 48 49 #define set_memory_rox set_memory_rox 50 static inline int set_memory_rox(unsigned long addr, int numpages) 51 { 52 return __set_memory(addr, numpages, SET_MEMORY_RO | SET_MEMORY_X); 53 } 54 55 static inline int set_memory_rwnx(unsigned long addr, int numpages) 56 { 57 return __set_memory(addr, numpages, SET_MEMORY_RW | SET_MEMORY_NX); 58 } 59 60 static inline int set_memory_4k(unsigned long addr, int numpages) 61 { 62 return __set_memory(addr, numpages, SET_MEMORY_4K); 63 } 64 65 int set_direct_map_invalid_noflush(struct page *page); 66 int set_direct_map_default_noflush(struct page *page); 67 68 #endif 69