[PATCH 3/8] s390/kexec: Let crash_protect_pages() warn in case of an error

From: Heiko Carstens

Date: Wed Nov 18 2026 - 09:48:38 EST


Let crash_protect_pages() print an error message in case set_memory*()
fails.

This doesn't buy too much since a failing set_memory_rw() would result in
a crash of the caller as soon as a write to the memory area happens.
Fixing that requires larger changes - for now only print a message.

Signed-off-by: Heiko Carstens <hca@xxxxxxxxxxxxx>
---
arch/s390/kernel/machine_kexec.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/s390/kernel/machine_kexec.c b/arch/s390/kernel/machine_kexec.c
index baeb3dcfc1c8..bf65bea5fa01 100644
--- a/arch/s390/kernel/machine_kexec.c
+++ b/arch/s390/kernel/machine_kexec.c
@@ -152,14 +152,17 @@ void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
static void crash_protect_pages(int protect)
{
unsigned long size;
+ int rc;

if (!crashk_res.end)
return;
size = resource_size(&crashk_res);
if (protect)
- set_memory_ro(crashk_res.start, size >> PAGE_SHIFT);
+ rc = set_memory_ro(crashk_res.start, size >> PAGE_SHIFT);
else
- set_memory_rw(crashk_res.start, size >> PAGE_SHIFT);
+ rc = set_memory_rw(crashk_res.start, size >> PAGE_SHIFT);
+ if (rc)
+ pr_warn("Failed to %sprotect crashkernel memory: %d\n", protect ? "" : "un", rc);
}

void arch_kexec_protect_crashkres(void)
--
2.56.1