Skip to content

Commit 212c3a8

Browse files
davidhildenbrandmstsirkin
authored andcommitted
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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent c6a8239 commit 212c3a8

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
@@ -240,6 +240,7 @@ config S390
240240
select MODULES_USE_ELF_RELA
241241
select NEED_DMA_MAP_STATE if PCI
242242
select NEED_PER_CPU_EMBED_FIRST_CHUNK
243+
select NEED_PROC_VMCORE_DEVICE_RAM if PROC_VMCORE
243244
select NEED_SG_DMA_LENGTH if PCI
244245
select OLD_SIGACTION
245246
select OLD_SIGSUSPEND3

arch/s390/kernel/crash_dump.c

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,19 @@ static int get_mem_chunk_cnt(void)
508508
return cnt;
509509
}
510510

511+
static void fill_ptload(Elf64_Phdr *phdr, unsigned long paddr,
512+
unsigned long vaddr, unsigned long size)
513+
{
514+
phdr->p_type = PT_LOAD;
515+
phdr->p_vaddr = vaddr;
516+
phdr->p_offset = paddr;
517+
phdr->p_paddr = paddr;
518+
phdr->p_filesz = size;
519+
phdr->p_memsz = size;
520+
phdr->p_flags = PF_R | PF_W | PF_X;
521+
phdr->p_align = PAGE_SIZE;
522+
}
523+
511524
/*
512525
* Initialize ELF loads (new kernel)
513526
*/
@@ -520,14 +533,8 @@ static void loads_init(Elf64_Phdr *phdr, bool os_info_has_vm)
520533
if (os_info_has_vm)
521534
old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);
522535
for_each_physmem_range(idx, &oldmem_type, &start, &end) {
523-
phdr->p_type = PT_LOAD;
524-
phdr->p_vaddr = old_identity_base + start;
525-
phdr->p_offset = start;
526-
phdr->p_paddr = start;
527-
phdr->p_filesz = end - start;
528-
phdr->p_memsz = end - start;
529-
phdr->p_flags = PF_R | PF_W | PF_X;
530-
phdr->p_align = PAGE_SIZE;
536+
fill_ptload(phdr, start, old_identity_base + start,
537+
end - start);
531538
phdr++;
532539
}
533540
}
@@ -537,6 +544,22 @@ static bool os_info_has_vm(void)
537544
return os_info_old_value(OS_INFO_KASLR_OFFSET);
538545
}
539546

547+
#ifdef CONFIG_PROC_VMCORE_DEVICE_RAM
548+
/*
549+
* Fill PT_LOAD for a physical memory range owned by a device and detected by
550+
* its device driver.
551+
*/
552+
void elfcorehdr_fill_device_ram_ptload_elf64(Elf64_Phdr *phdr,
553+
unsigned long long paddr, unsigned long long size)
554+
{
555+
unsigned long old_identity_base = 0;
556+
557+
if (os_info_has_vm())
558+
old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);
559+
fill_ptload(phdr, paddr, old_identity_base + paddr, size);
560+
}
561+
#endif
562+
540563
/*
541564
* Prepare PT_LOAD type program header for kernel image region
542565
*/

0 commit comments

Comments
 (0)