| 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, unsigned long numpages, unsigned long flags); |
| 28 |
|
| 29 |
#define set_memory_rox set_memory_rox |
| 30 |
|
| 31 |
/* |
| 32 |
* Generate two variants of each set_memory() function: |
| 33 |
* |
| 34 |
* set_memory_yy(unsigned long addr, int numpages); |
| 35 |
* __set_memory_yy(void *start, void *end); |
| 36 |
* |
| 37 |
* The second variant exists for both convenience to avoid the usual |
| 38 |
* (unsigned long) casts, but unlike the first variant it can also be used |
| 39 |
* for areas larger than 8TB, which may happen at memory initialization. |
| 40 |
*/ |
| 41 |
#define __SET_MEMORY_FUNC(fname, flags) \ |
| 42 |
static inline int fname(unsigned long addr, int numpages) \ |
| 43 |
{ \ |
| 44 |
return __set_memory(addr, numpages, (flags)); \ |
| 45 |
} \ |
| 46 |
\ |
| 47 |
static inline int __##fname(void *start, void *end) \ |
| 48 |
{ \ |
| 49 |
unsigned long numpages; \ |
| 50 |
\ |
| 51 |
numpages = (end - start) >> PAGE_SHIFT; \ |
| 52 |
return __set_memory((unsigned long)start, numpages, (flags)); \ |
| 53 |
} |
| 54 |
|
| 55 |
__SET_MEMORY_FUNC(set_memory_ro, SET_MEMORY_RO) |
| 56 |
__SET_MEMORY_FUNC(set_memory_rw, SET_MEMORY_RW) |
| 57 |
__SET_MEMORY_FUNC(set_memory_nx, SET_MEMORY_NX) |
| 58 |
__SET_MEMORY_FUNC(set_memory_x, SET_MEMORY_X) |
| 59 |
__SET_MEMORY_FUNC(set_memory_rox, SET_MEMORY_RO | SET_MEMORY_X) |
| 60 |
__SET_MEMORY_FUNC(set_memory_rwnx, SET_MEMORY_RW | SET_MEMORY_NX) |
| 61 |
__SET_MEMORY_FUNC(set_memory_4k, SET_MEMORY_4K) |
| 62 |
|
| 63 |
int set_direct_map_invalid_noflush(struct page *page); |
| 64 |
int set_direct_map_default_noflush(struct page *page); |
| 65 |
int set_direct_map_valid_noflush(struct page *page, unsigned nr, bool valid); |
| 66 |
bool kernel_page_present(struct page *page); |
| 67 |
|
| 68 |
#endif |