Skip to content

Commit a7eb288

Browse files
committed
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: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent 850612c commit a7eb288

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

arch/s390/mm/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void mark_rodata_ro(void)
107107
{
108108
unsigned long size = __end_ro_after_init - __start_ro_after_init;
109109

110-
set_memory_ro((unsigned long)__start_ro_after_init, size >> PAGE_SHIFT);
110+
__set_memory_ro(__start_ro_after_init, __end_ro_after_init);
111111
pr_info("Write protected read-only-after-init data: %luk\n", size >> 10);
112112
debug_checkwx();
113113
}

arch/s390/mm/vmem.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -651,14 +651,10 @@ void vmem_unmap_4k_page(unsigned long addr)
651651

652652
void __init vmem_map_init(void)
653653
{
654-
set_memory_rox((unsigned long)_stext,
655-
(unsigned long)(_etext - _stext) >> PAGE_SHIFT);
656-
set_memory_ro((unsigned long)_etext,
657-
(unsigned long)(__end_rodata - _etext) >> PAGE_SHIFT);
658-
set_memory_rox((unsigned long)_sinittext,
659-
(unsigned long)(_einittext - _sinittext) >> PAGE_SHIFT);
660-
set_memory_rox((unsigned long)__stext_amode31,
661-
(unsigned long)(__etext_amode31 - __stext_amode31) >> PAGE_SHIFT);
654+
__set_memory_rox(_stext, _etext);
655+
__set_memory_ro(_etext, __end_rodata);
656+
__set_memory_rox(_sinittext, _einittext);
657+
__set_memory_rox(__stext_amode31, __etext_amode31);
662658
/*
663659
* If the BEAR-enhancement facility is not installed the first
664660
* prefix page is used to return to the previous context with
@@ -667,8 +663,12 @@ void __init vmem_map_init(void)
667663
if (!static_key_enabled(&cpu_has_bear))
668664
set_memory_x(0, 1);
669665
if (debug_pagealloc_enabled()) {
670-
set_memory_4k((unsigned long)__va(0),
671-
ident_map_size >> PAGE_SHIFT);
666+
/*
667+
* Use RELOC_HIDE() as long as __va(0) translates to NULL,
668+
* since performing pointer arithmetic on a NULL pointer
669+
* has undefined behavior and generates compiler warnings.
670+
*/
671+
__set_memory_4k(__va(0), RELOC_HIDE(__va(0), ident_map_size));
672672
}
673673
if (MACHINE_HAS_NX)
674674
ctl_set_bit(0, 20);

0 commit comments

Comments
 (0)