Skip to content

Commit e7ed248

Browse files
committed
s390/kdump: virtio-mem kdump support (CONFIG_PROC_VMCORE_DEVICE_RAM)
JIRA: https://issues.redhat.com/browse/RHEL-72992 commit 212c3a8 Author: David Hildenbrand <david@redhat.com> Date: Wed Dec 4 13:54:43 2024 +0100 s390/kdump: virtio-mem kdump support (CONFIG_PROC_VMCORE_DEVICE_RAM) 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> Signed-off-by: Thomas Huth <thuth@redhat.com>
1 parent b7f5553 commit e7ed248

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

arch/s390/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ config S390
230230
select MODULES_USE_ELF_RELA
231231
select NEED_DMA_MAP_STATE if PCI
232232
select NEED_PER_CPU_EMBED_FIRST_CHUNK
233+
select NEED_PROC_VMCORE_DEVICE_RAM if PROC_VMCORE
233234
select NEED_SG_DMA_LENGTH if PCI
234235
select OLD_SIGACTION
235236
select OLD_SIGSUSPEND3

arch/s390/kernel/crash_dump.c

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,19 @@ static int get_mem_chunk_cnt(void)
497497
return cnt;
498498
}
499499

500+
static void fill_ptload(Elf64_Phdr *phdr, unsigned long paddr,
501+
unsigned long vaddr, unsigned long size)
502+
{
503+
phdr->p_type = PT_LOAD;
504+
phdr->p_vaddr = vaddr;
505+
phdr->p_offset = paddr;
506+
phdr->p_paddr = paddr;
507+
phdr->p_filesz = size;
508+
phdr->p_memsz = size;
509+
phdr->p_flags = PF_R | PF_W | PF_X;
510+
phdr->p_align = PAGE_SIZE;
511+
}
512+
500513
/*
501514
* Initialize ELF loads (new kernel)
502515
*/
@@ -509,14 +522,8 @@ static void loads_init(Elf64_Phdr *phdr, bool os_info_has_vm)
509522
if (os_info_has_vm)
510523
old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);
511524
for_each_physmem_range(idx, &oldmem_type, &start, &end) {
512-
phdr->p_type = PT_LOAD;
513-
phdr->p_vaddr = old_identity_base + start;
514-
phdr->p_offset = start;
515-
phdr->p_paddr = start;
516-
phdr->p_filesz = end - start;
517-
phdr->p_memsz = end - start;
518-
phdr->p_flags = PF_R | PF_W | PF_X;
519-
phdr->p_align = PAGE_SIZE;
525+
fill_ptload(phdr, start, old_identity_base + start,
526+
end - start);
520527
phdr++;
521528
}
522529
}
@@ -526,6 +533,22 @@ static bool os_info_has_vm(void)
526533
return os_info_old_value(OS_INFO_KASLR_OFFSET);
527534
}
528535

536+
#ifdef CONFIG_PROC_VMCORE_DEVICE_RAM
537+
/*
538+
* Fill PT_LOAD for a physical memory range owned by a device and detected by
539+
* its device driver.
540+
*/
541+
void elfcorehdr_fill_device_ram_ptload_elf64(Elf64_Phdr *phdr,
542+
unsigned long long paddr, unsigned long long size)
543+
{
544+
unsigned long old_identity_base = 0;
545+
546+
if (os_info_has_vm())
547+
old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);
548+
fill_ptload(phdr, paddr, old_identity_base + paddr, size);
549+
}
550+
#endif
551+
529552
/*
530553
* Prepare PT_LOAD type program header for kernel image region
531554
*/

0 commit comments

Comments
 (0)