[PATCH RFC v2 45/54] s390/boot: map the identity map with 4K pages for debug_pagealloc

From: Mike Rapoport (Microsoft)

Date: Thu Nov 26 2026 - 06:21:58 EST


debug_pagealloc maps and unmaps single pages of the identity map, so it
needs the identity map to use 4K pages.

The decompressor maps it with large pages regardless, and vmem_map_init()
then splits it with __set_memory_4k().

The s390 implementation of change_page_attr() skips the PTE level for that
request, so the split costs little more than filling the new page tables.

The generic CPA core, which s390 is going to use, has no such shortcut:
after the split it would visit each page of the identity map, taking
cpa_lock and walking the page table for every one of them.

Parse debug_pagealloc in the decompressor and map the identity map with 4K
pages when it is enabled, like x86 and arm64 do for their direct and linear
maps. Drop the split from vmem_map_init().

Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
---
arch/s390/boot/boot.h | 1 +
arch/s390/boot/ipl_parm.c | 9 +++++++++
arch/s390/boot/vmem.c | 3 ++-
arch/s390/mm/vmem.c | 2 --
4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/arch/s390/boot/boot.h b/arch/s390/boot/boot.h
index 61a205b489fb..07ca806ff8ff 100644
--- a/arch/s390/boot/boot.h
+++ b/arch/s390/boot/boot.h
@@ -110,6 +110,7 @@ extern const char kernel_version[];
extern unsigned long memory_limit;
extern unsigned long vmalloc_size;
extern int vmalloc_size_set;
+extern bool debug_pagealloc;
extern char __boot_data_start[], __boot_data_end[];
extern char __boot_data_preserved_start[], __boot_data_preserved_end[];
extern char __vmlinux_relocs_64_start[], __vmlinux_relocs_64_end[];
diff --git a/arch/s390/boot/ipl_parm.c b/arch/s390/boot/ipl_parm.c
index ac4cf1ced71d..cf6c6679c5a5 100644
--- a/arch/s390/boot/ipl_parm.c
+++ b/arch/s390/boot/ipl_parm.c
@@ -34,6 +34,7 @@ int __bootdata_preserved(cmma_flag) = 1;
unsigned long vmalloc_size = VMALLOC_DEFAULT_SIZE;
unsigned long memory_limit;
int vmalloc_size_set;
+bool debug_pagealloc = IS_ENABLED(CONFIG_DEBUG_PAGEALLOC_ENABLE_DEFAULT);

static inline int __diag308(unsigned long subcode, void *addr)
{
@@ -332,6 +333,14 @@ void parse_boot_command_line(void)
stack_protector_debug = 1;
#endif

+#ifdef CONFIG_DEBUG_PAGEALLOC
+ if (parameq(param, "debug_pagealloc")) {
+ rc = kstrtobool(val, &enabled);
+ if (!rc)
+ debug_pagealloc = enabled;
+ }
+#endif
+
#if IS_ENABLED(CONFIG_KVM)
if (parameq(param, "prot_virt")) {
rc = kstrtobool(val, &enabled);
diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c
index ff6d58a476ba..3a6cd62c31ae 100644
--- a/arch/s390/boot/vmem.c
+++ b/arch/s390/boot/vmem.c
@@ -286,8 +286,9 @@ static unsigned long resolve_pa_may_alloc(unsigned long addr, unsigned long size
static bool large_page_mapping_allowed(enum populate_mode mode)
{
switch (mode) {
- case POPULATE_DIRECT:
case POPULATE_IDENTITY:
+ return !debug_pagealloc;
+ case POPULATE_DIRECT:
case POPULATE_KERNEL:
#ifdef CONFIG_KASAN
case POPULATE_KASAN_MAP_SHADOW:
diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c
index d2879ce860a1..191326ee7ec8 100644
--- a/arch/s390/mm/vmem.c
+++ b/arch/s390/mm/vmem.c
@@ -681,8 +681,6 @@ void __init vmem_map_init(void)
*/
if (!cpu_has_bear())
set_memory_x(0, 1);
- if (debug_pagealloc_enabled())
- __set_memory_4k(__va(0), absolute_pointer(__va(0)) + ident_map_size);
pr_info("Write protected kernel read-only data: %luk\n",
(unsigned long)(__end_rodata - _stext) >> 10);
}

--
2.53.0