162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef _ASMS390_SET_MEMORY_H 362306a36Sopenharmony_ci#define _ASMS390_SET_MEMORY_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <linux/mutex.h> 662306a36Sopenharmony_ci 762306a36Sopenharmony_ciextern struct mutex cpa_mutex; 862306a36Sopenharmony_ci 962306a36Sopenharmony_cienum { 1062306a36Sopenharmony_ci _SET_MEMORY_RO_BIT, 1162306a36Sopenharmony_ci _SET_MEMORY_RW_BIT, 1262306a36Sopenharmony_ci _SET_MEMORY_NX_BIT, 1362306a36Sopenharmony_ci _SET_MEMORY_X_BIT, 1462306a36Sopenharmony_ci _SET_MEMORY_4K_BIT, 1562306a36Sopenharmony_ci _SET_MEMORY_INV_BIT, 1662306a36Sopenharmony_ci _SET_MEMORY_DEF_BIT, 1762306a36Sopenharmony_ci}; 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ci#define SET_MEMORY_RO BIT(_SET_MEMORY_RO_BIT) 2062306a36Sopenharmony_ci#define SET_MEMORY_RW BIT(_SET_MEMORY_RW_BIT) 2162306a36Sopenharmony_ci#define SET_MEMORY_NX BIT(_SET_MEMORY_NX_BIT) 2262306a36Sopenharmony_ci#define SET_MEMORY_X BIT(_SET_MEMORY_X_BIT) 2362306a36Sopenharmony_ci#define SET_MEMORY_4K BIT(_SET_MEMORY_4K_BIT) 2462306a36Sopenharmony_ci#define SET_MEMORY_INV BIT(_SET_MEMORY_INV_BIT) 2562306a36Sopenharmony_ci#define SET_MEMORY_DEF BIT(_SET_MEMORY_DEF_BIT) 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ciint __set_memory(unsigned long addr, unsigned long numpages, unsigned long flags); 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#define set_memory_rox set_memory_rox 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci/* 3262306a36Sopenharmony_ci * Generate two variants of each set_memory() function: 3362306a36Sopenharmony_ci * 3462306a36Sopenharmony_ci * set_memory_yy(unsigned long addr, int numpages); 3562306a36Sopenharmony_ci * __set_memory_yy(void *start, void *end); 3662306a36Sopenharmony_ci * 3762306a36Sopenharmony_ci * The second variant exists for both convenience to avoid the usual 3862306a36Sopenharmony_ci * (unsigned long) casts, but unlike the first variant it can also be used 3962306a36Sopenharmony_ci * for areas larger than 8TB, which may happen at memory initialization. 4062306a36Sopenharmony_ci */ 4162306a36Sopenharmony_ci#define __SET_MEMORY_FUNC(fname, flags) \ 4262306a36Sopenharmony_cistatic inline int fname(unsigned long addr, int numpages) \ 4362306a36Sopenharmony_ci{ \ 4462306a36Sopenharmony_ci return __set_memory(addr, numpages, (flags)); \ 4562306a36Sopenharmony_ci} \ 4662306a36Sopenharmony_ci \ 4762306a36Sopenharmony_cistatic inline int __##fname(void *start, void *end) \ 4862306a36Sopenharmony_ci{ \ 4962306a36Sopenharmony_ci unsigned long numpages; \ 5062306a36Sopenharmony_ci \ 5162306a36Sopenharmony_ci numpages = (end - start) >> PAGE_SHIFT; \ 5262306a36Sopenharmony_ci return __set_memory((unsigned long)start, numpages, (flags)); \ 5362306a36Sopenharmony_ci} 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ci__SET_MEMORY_FUNC(set_memory_ro, SET_MEMORY_RO) 5662306a36Sopenharmony_ci__SET_MEMORY_FUNC(set_memory_rw, SET_MEMORY_RW) 5762306a36Sopenharmony_ci__SET_MEMORY_FUNC(set_memory_nx, SET_MEMORY_NX) 5862306a36Sopenharmony_ci__SET_MEMORY_FUNC(set_memory_x, SET_MEMORY_X) 5962306a36Sopenharmony_ci__SET_MEMORY_FUNC(set_memory_rox, SET_MEMORY_RO | SET_MEMORY_X) 6062306a36Sopenharmony_ci__SET_MEMORY_FUNC(set_memory_rwnx, SET_MEMORY_RW | SET_MEMORY_NX) 6162306a36Sopenharmony_ci__SET_MEMORY_FUNC(set_memory_4k, SET_MEMORY_4K) 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ciint set_direct_map_invalid_noflush(struct page *page); 6462306a36Sopenharmony_ciint set_direct_map_default_noflush(struct page *page); 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci#endif 67