Skip to contentSkip to conversation

s390/kdump: write protect the crash kernel memory by its virtual address

PATCH In review Mike Rapoport (Microsoft) 3 participants 3 messages Nov 17 s390

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 s390/kdump: write protect the crash kernel memory by its virtual address

crash_protect_pages() passes crashk_res.start to set_memory_ro() and set_memory_rw(). That is a physical address. Since the identity mapping may start above zero, it is not the address of the crash kernel memory in the kernel page tables.

With CONFIG_RANDOMIZE_IDENTITY_BASE the page table walk finds no mapping at that address and fails. The error is ignored, and the crash kernel memory stays writable after "kexec -p" loads it.

Use the identity mapping address of the crash kernel memory.

Fixes c98d2ecae08f ("s390/mm: Uncouple physical vs virtual address spaces")

---
I found this while working on a generic implementation of the set_memory APIs. Only build tested.

---
 arch/s390/kernel/machine_kexec.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
arch/s390/kernel/machine_kexec.c +4 -3
index baeb3dcfc1c8..20ea3018462f 100644
@@ -151,15 +151,16 @@ void crash_free_reserved_phys_range(unsigned long begin, unsigned long end)
 
 static void crash_protect_pages(int protect)
 {
-	unsigned long size;
+	unsigned long addr, size;
 
 	if (!crashk_res.end)
 		return;
+	addr = (unsigned long)__va(crashk_res.start);
 	size = resource_size(&crashk_res);
 	if (protect)
-		set_memory_ro(crashk_res.start, size >> PAGE_SHIFT);
+		set_memory_ro(addr, size >> PAGE_SHIFT);
 	else
-		set_memory_rw(crashk_res.start, size >> PAGE_SHIFT);
+		set_memory_rw(addr, size >> PAGE_SHIFT);
 }
 
 void arch_kexec_protect_crashkres(void)

---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261117-fixes-s390-82943938787a

--
Sincerely yours,
Mike.

#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines

crash_protect_pages() passes crashk_res.start to set_memory_ro() and set_memory_rw(). That is a physical address. Since the identity mapping may start above zero, it is not the address of the crash kernel memory in the kernel page tables.

Quoted 8 lines

With CONFIG_RANDOMIZE_IDENTITY_BASE the page table walk finds no mapping at that address and fails. The error is ignored, and the crash kernel memory stays writable after "kexec -p" loads it.

Use the identity mapping address of the crash kernel memory.

Fixes c98d2ecae08f ("s390/mm: Uncouple physical vs virtual address spaces")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Mike Rapoport (Microsoft)
Quoted 11 lines · Mike Rapoport (Microsoft)

crash_protect_pages() passes crashk_res.start to set_memory_ro() and set_memory_rw(). That is a physical address. Since the identity mapping may start above zero, it is not the address of the crash kernel memory in the kernel page tables.

With CONFIG_RANDOMIZE_IDENTITY_BASE the page table walk finds no mapping at that address and fails. The error is ignored, and the crash kernel memory stays writable after "kexec -p" loads it.

Use the identity mapping address of the crash kernel memory.

Quoted 8 lines
Fixes c98d2ecae08f ("s390/mm: Uncouple physical vs virtual address spaces")

---
I found this while working on a generic implementation of the set_memory APIs. Only build tested.

---
 arch/s390/kernel/machine_kexec.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)