Commit a7eb2880 authored by Heiko Carstens's avatar Heiko Carstens

s390/mm: use __set_memory() variants where useful

Use the __set_memory_yy() variants instead of set_memory_yy() where
useful. This allows to make the code a bit more readable.

This also fixes the debug pagealloc case, where set_memory_4k() might be
called for an area larger than 8TB which would lead to an overflow of
the num_pages parameter of set_memory_4k().

However RELOC_HIDE() has to be used for the __set_memory_4k() case for
the time being, to avoid compiler warnings because of performing pointer
arithmetic on a NULL pointer, which has undefined behavior. This happens
because __va(0) always translates to NULL. However this will change, and
as soon as this happens the RELOC_HIDE() hack can be removed again.
Reviewed-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 850612c8
...@@ -107,7 +107,7 @@ void mark_rodata_ro(void) ...@@ -107,7 +107,7 @@ void mark_rodata_ro(void)
{ {
unsigned long size = __end_ro_after_init - __start_ro_after_init; unsigned long size = __end_ro_after_init - __start_ro_after_init;
set_memory_ro((unsigned long)__start_ro_after_init, size >> PAGE_SHIFT); __set_memory_ro(__start_ro_after_init, __end_ro_after_init);
pr_info("Write protected read-only-after-init data: %luk\n", size >> 10); pr_info("Write protected read-only-after-init data: %luk\n", size >> 10);
debug_checkwx(); debug_checkwx();
} }
......
...@@ -651,14 +651,10 @@ void vmem_unmap_4k_page(unsigned long addr) ...@@ -651,14 +651,10 @@ void vmem_unmap_4k_page(unsigned long addr)
void __init vmem_map_init(void) void __init vmem_map_init(void)
{ {
set_memory_rox((unsigned long)_stext, __set_memory_rox(_stext, _etext);
(unsigned long)(_etext - _stext) >> PAGE_SHIFT); __set_memory_ro(_etext, __end_rodata);
set_memory_ro((unsigned long)_etext, __set_memory_rox(_sinittext, _einittext);
(unsigned long)(__end_rodata - _etext) >> PAGE_SHIFT); __set_memory_rox(__stext_amode31, __etext_amode31);
set_memory_rox((unsigned long)_sinittext,
(unsigned long)(_einittext - _sinittext) >> PAGE_SHIFT);
set_memory_rox((unsigned long)__stext_amode31,
(unsigned long)(__etext_amode31 - __stext_amode31) >> PAGE_SHIFT);
/* /*
* If the BEAR-enhancement facility is not installed the first * If the BEAR-enhancement facility is not installed the first
* prefix page is used to return to the previous context with * prefix page is used to return to the previous context with
...@@ -667,8 +663,12 @@ void __init vmem_map_init(void) ...@@ -667,8 +663,12 @@ void __init vmem_map_init(void)
if (!static_key_enabled(&cpu_has_bear)) if (!static_key_enabled(&cpu_has_bear))
set_memory_x(0, 1); set_memory_x(0, 1);
if (debug_pagealloc_enabled()) { if (debug_pagealloc_enabled()) {
set_memory_4k((unsigned long)__va(0), /*
ident_map_size >> PAGE_SHIFT); * Use RELOC_HIDE() as long as __va(0) translates to NULL,
* since performing pointer arithmetic on a NULL pointer
* has undefined behavior and generates compiler warnings.
*/
__set_memory_4k(__va(0), RELOC_HIDE(__va(0), ident_map_size));
} }
if (MACHINE_HAS_NX) if (MACHINE_HAS_NX)
ctl_set_bit(0, 20); ctl_set_bit(0, 20);
......
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