s390/mm: split lowcore pages with set_memory_4k()
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 5 Sep 2022 12:18:27 +0000 (14:18 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Wed, 7 Sep 2022 12:04:52 +0000 (14:04 +0200)
Use set_memory_4k() to split lowcore pages within the kernel mapping
instead of using the quite subtle !addr check within modify_pmd_table()
and modify_pud_table() to prevent large pages for address zero.

With this lowcore might be mapped with 1MB / 2GB frames and only later
will be split. This way this mapping is handled like every other.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/mm/vmem.c

index c2583f921ca8d100251079ab701a4ce11ea1ac95..1c86de9dd87fd9b8be01e7706432f268c71f455b 100644 (file)
@@ -240,7 +240,7 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr,
                } else if (pmd_none(*pmd)) {
                        if (IS_ALIGNED(addr, PMD_SIZE) &&
                            IS_ALIGNED(next, PMD_SIZE) &&
-                           MACHINE_HAS_EDAT1 && addr && direct &&
+                           MACHINE_HAS_EDAT1 && direct &&
                            !debug_pagealloc_enabled()) {
                                set_pmd(pmd, __pmd(__pa(addr) | prot));
                                pages++;
@@ -336,7 +336,7 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end,
                } else if (pud_none(*pud)) {
                        if (IS_ALIGNED(addr, PUD_SIZE) &&
                            IS_ALIGNED(next, PUD_SIZE) &&
-                           MACHINE_HAS_EDAT2 && addr && direct &&
+                           MACHINE_HAS_EDAT2 && direct &&
                            !debug_pagealloc_enabled()) {
                                set_pud(pud, __pud(__pa(addr) | prot));
                                pages++;
@@ -584,6 +584,9 @@ void __init vmem_map_init(void)
        __set_memory(__stext_amode31, (__etext_amode31 - __stext_amode31) >> PAGE_SHIFT,
                     SET_MEMORY_RO | SET_MEMORY_X);
 
+       /* lowcore requires 4k mapping for real addresses / prefixing */
+       set_memory_4k(0, LC_PAGES);
+
        /* lowcore must be executable for LPSWE */
        if (!static_key_enabled(&cpu_has_bear))
                set_memory_x(0, 1);