Commit f9b2d96c authored by Heiko Carstens's avatar Heiko Carstens Committed by Vasily Gorbik

s390/mm: use set_memory_*() helpers instead of open coding

Given that set_memory_rox() and set_memory_rwnx() exist, it is possible
to get rid of all open coded __set_memory() usages and replace them with
proper helper calls everywhere.
Reviewed-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent f0a2a7c5
...@@ -41,7 +41,7 @@ void *alloc_insn_page(void) ...@@ -41,7 +41,7 @@ void *alloc_insn_page(void)
page = module_alloc(PAGE_SIZE); page = module_alloc(PAGE_SIZE);
if (!page) if (!page)
return NULL; return NULL;
__set_memory((unsigned long) page, 1, SET_MEMORY_RO | SET_MEMORY_X); set_memory_rox((unsigned long)page, 1);
return page; return page;
} }
......
...@@ -176,9 +176,8 @@ void __init mem_init(void) ...@@ -176,9 +176,8 @@ void __init mem_init(void)
void free_initmem(void) void free_initmem(void)
{ {
__set_memory((unsigned long)_sinittext, set_memory_rwnx((unsigned long)_sinittext,
(unsigned long)(_einittext - _sinittext) >> PAGE_SHIFT, (unsigned long)(_einittext - _sinittext) >> PAGE_SHIFT);
SET_MEMORY_RW | SET_MEMORY_NX);
free_initmem_default(POISON_FREE_INITMEM); free_initmem_default(POISON_FREE_INITMEM);
} }
......
...@@ -732,30 +732,24 @@ void __init vmem_map_init(void) ...@@ -732,30 +732,24 @@ void __init vmem_map_init(void)
memblock_region_cmp, memblock_region_swap); memblock_region_cmp, memblock_region_swap);
__for_each_mem_range(i, &memblock.memory, &memory_rwx, __for_each_mem_range(i, &memblock.memory, &memory_rwx,
NUMA_NO_NODE, MEMBLOCK_NONE, &base, &end, NULL) { NUMA_NO_NODE, MEMBLOCK_NONE, &base, &end, NULL) {
__set_memory((unsigned long)__va(base), set_memory_rwnx((unsigned long)__va(base),
(end - base) >> PAGE_SHIFT, (end - base) >> PAGE_SHIFT);
SET_MEMORY_RW | SET_MEMORY_NX);
} }
#ifdef CONFIG_KASAN #ifdef CONFIG_KASAN
for_each_mem_range(i, &base, &end) for_each_mem_range(i, &base, &end) {
__set_memory(__sha(base), set_memory_rwnx(__sha(base),
(__sha(end) - __sha(base)) >> PAGE_SHIFT, (__sha(end) - __sha(base)) >> PAGE_SHIFT);
SET_MEMORY_RW | SET_MEMORY_NX); }
#endif #endif
set_memory_rox((unsigned long)_stext,
__set_memory((unsigned long)_stext, (unsigned long)(_etext - _stext) >> PAGE_SHIFT);
(unsigned long)(_etext - _stext) >> PAGE_SHIFT, set_memory_ro((unsigned long)_etext,
SET_MEMORY_RO | SET_MEMORY_X); (unsigned long)(__end_rodata - _etext) >> PAGE_SHIFT);
__set_memory((unsigned long)_etext, set_memory_rox((unsigned long)_sinittext,
(unsigned long)(__end_rodata - _etext) >> PAGE_SHIFT, (unsigned long)(_einittext - _sinittext) >> PAGE_SHIFT);
SET_MEMORY_RO); set_memory_rox(__stext_amode31,
__set_memory((unsigned long)_sinittext, (__etext_amode31 - __stext_amode31) >> PAGE_SHIFT);
(unsigned long)(_einittext - _sinittext) >> PAGE_SHIFT,
SET_MEMORY_RO | SET_MEMORY_X);
__set_memory(__stext_amode31,
(__etext_amode31 - __stext_amode31) >> PAGE_SHIFT,
SET_MEMORY_RO | SET_MEMORY_X);
/* lowcore must be executable for LPSWE */ /* lowcore must be executable for LPSWE */
if (static_key_enabled(&cpu_has_bear)) if (static_key_enabled(&cpu_has_bear))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment