]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
s390/kdump: virtio-mem kdump support (CONFIG_PROC_VMCORE_DEVICE_RAM)
authorDavid Hildenbrand <david@redhat.com>
Wed, 4 Dec 2024 12:54:43 +0000 (13:54 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 27 Jan 2025 14:39:25 +0000 (09:39 -0500)
Let's add support for including virtio-mem device RAM in the crash dump,
setting NEED_PROC_VMCORE_DEVICE_RAM, and implementing
elfcorehdr_fill_device_ram_ptload_elf64().

To avoid code duplication, factor out the code to fill a PT_LOAD entry.

Signed-off-by: David Hildenbrand <david@redhat.com>
Message-Id: <20241204125444.1734652-13-david@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
arch/s390/Kconfig
arch/s390/kernel/crash_dump.c

index 0077969170e8b4ca4c99e87ec75f6ea94f3e8e00..c230bad7f5ccf4ac33b02b3e1755c78074041610 100644 (file)
@@ -240,6 +240,7 @@ config S390
        select MODULES_USE_ELF_RELA
        select NEED_DMA_MAP_STATE       if PCI
        select NEED_PER_CPU_EMBED_FIRST_CHUNK
+       select NEED_PROC_VMCORE_DEVICE_RAM if PROC_VMCORE
        select NEED_SG_DMA_LENGTH       if PCI
        select OLD_SIGACTION
        select OLD_SIGSUSPEND3
index cd0c93a8fb8bb5b6af985cd983d4e50e673feefa..f699df2a2b1128ed988287a15a337a2b7fe51848 100644 (file)
@@ -508,6 +508,19 @@ static int get_mem_chunk_cnt(void)
        return cnt;
 }
 
+static void fill_ptload(Elf64_Phdr *phdr, unsigned long paddr,
+               unsigned long vaddr, unsigned long size)
+{
+       phdr->p_type = PT_LOAD;
+       phdr->p_vaddr = vaddr;
+       phdr->p_offset = paddr;
+       phdr->p_paddr = paddr;
+       phdr->p_filesz = size;
+       phdr->p_memsz = size;
+       phdr->p_flags = PF_R | PF_W | PF_X;
+       phdr->p_align = PAGE_SIZE;
+}
+
 /*
  * Initialize ELF loads (new kernel)
  */
@@ -520,14 +533,8 @@ static void loads_init(Elf64_Phdr *phdr, bool os_info_has_vm)
        if (os_info_has_vm)
                old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);
        for_each_physmem_range(idx, &oldmem_type, &start, &end) {
-               phdr->p_type = PT_LOAD;
-               phdr->p_vaddr = old_identity_base + start;
-               phdr->p_offset = start;
-               phdr->p_paddr = start;
-               phdr->p_filesz = end - start;
-               phdr->p_memsz = end - start;
-               phdr->p_flags = PF_R | PF_W | PF_X;
-               phdr->p_align = PAGE_SIZE;
+               fill_ptload(phdr, start, old_identity_base + start,
+                           end - start);
                phdr++;
        }
 }
@@ -537,6 +544,22 @@ static bool os_info_has_vm(void)
        return os_info_old_value(OS_INFO_KASLR_OFFSET);
 }
 
+#ifdef CONFIG_PROC_VMCORE_DEVICE_RAM
+/*
+ * Fill PT_LOAD for a physical memory range owned by a device and detected by
+ * its device driver.
+ */
+void elfcorehdr_fill_device_ram_ptload_elf64(Elf64_Phdr *phdr,
+               unsigned long long paddr, unsigned long long size)
+{
+       unsigned long old_identity_base = 0;
+
+       if (os_info_has_vm())
+               old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);
+       fill_ptload(phdr, paddr, old_identity_base + paddr, size);
+}
+#endif
+
 /*
  * Prepare PT_LOAD type program header for kernel image region
  */