From patchwork Fri Oct 25 15:11:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13850944 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46043D0BB56 for ; Fri, 25 Oct 2024 15:13:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC7466B00A5; Fri, 25 Oct 2024 11:13:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D508A6B00A6; Fri, 25 Oct 2024 11:13:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCAA96B00A7; Fri, 25 Oct 2024 11:13:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 96FE06B00A5 for ; Fri, 25 Oct 2024 11:13:23 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D9D641C6912 for ; Fri, 25 Oct 2024 15:13:00 +0000 (UTC) X-FDA: 82712467488.27.6BE614F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 73368160026 for ; Fri, 25 Oct 2024 15:13:08 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SZ8ZTNH3; spf=pass (imf08.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729869124; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=duV64aDOzPCg70Erai+k0MR4CZFFfLJs/Tny3PQhGqo=; b=I5R8+8qM9Jkv9msQomxizBgCcG4LFdh/b/QRNUcR2zzpH0KKCfup2J+61URD2S/gGxZPbl l4nfblgqPSliy1yvJfzg1t+BC8PE/joSFJ2ztgjGR2WSg7Sf3dyYNkS30VsYg2mCEmVW7X D5cBrV+WPpR1QMENU05ns2WuBHjG304= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SZ8ZTNH3; spf=pass (imf08.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729869124; a=rsa-sha256; cv=none; b=MloU7+bwtzS8uXTg54rkhhofPQ/m7oeuKoEllQlqUii+w/7+2J/XWeEuvNdoBtIkj9qKPq LKUYGAlNy/f/lfAJmiwSbyQIaEq7yMHFCHguWwXkQQt84B6M0OVS26GVbIwGF87UW3JUyo ZPwzJAUlaVQzfxqzQhvnGUd6gL4wjz4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729869201; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=duV64aDOzPCg70Erai+k0MR4CZFFfLJs/Tny3PQhGqo=; b=SZ8ZTNH32jWnPI1YGwlhe4guDJlFRSM9ZOOU5udU2HtrvbrKCUYYNDkKwNnsnInQgIeavu 0ajlt5XqGfEPZSh76m5fngw+Hs3yeLPJqyrfqbG4AA1lzeeTEnlS6qT9oRMJe2OS0fJgYj dQ2lSEK31Y8xL/hdD7AmJygxbQayAf0= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-44-_q3EKHFQNEmGt7K_9EZzAQ-1; Fri, 25 Oct 2024 11:13:19 -0400 X-MC-Unique: _q3EKHFQNEmGt7K_9EZzAQ-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 750F61956096; Fri, 25 Oct 2024 15:13:17 +0000 (UTC) Received: from t14s.redhat.com (unknown [10.22.65.27]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 27021300018D; Fri, 25 Oct 2024 15:13:08 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-s390@vger.kernel.org, virtualization@lists.linux.dev, kvm@vger.kernel.org, linux-fsdevel@vger.kernel.org, kexec@lists.infradead.org, David Hildenbrand , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , =?utf-8?q?Eugenio_P=C3=A9rez?= , Baoquan He , Vivek Goyal , Dave Young , Thomas Huth , Cornelia Huck , Janosch Frank , Claudio Imbrenda , Eric Farman , Andrew Morton Subject: [PATCH v1 11/11] s390/kdump: virtio-mem kdump support (CONFIG_PROC_VMCORE_DEVICE_RAM) Date: Fri, 25 Oct 2024 17:11:33 +0200 Message-ID: <20241025151134.1275575-12-david@redhat.com> In-Reply-To: <20241025151134.1275575-1-david@redhat.com> References: <20241025151134.1275575-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 73368160026 X-Stat-Signature: 6ixq47gxk81a8g6t5reprqqmidrx4cu7 X-HE-Tag: 1729869188-553503 X-HE-Meta: U2FsdGVkX19YLkJbSbCicsZupW6Msc20CGPf0Qg17H+5XOAcwu8n4FqfNwS69/PQ9U48Y6habujRbybwDfUFf8qbWkN2+nmYtz3cNjVq9XonvLIsIzLlvj+2F/tkkbZpK7GWYrnDADmi9KfWH5d6q/hwQ59jdPzxJ1pabWmk+zxjDuS5tuBVvJvtguXYWURcB1GslO1v/61Z+wejnMbko8XIcbh12/bvZmCZWL6JhJ/8g+wfk0+VxHFkjmfZ2HVAOVlOMrmF1YcGcbQVBrWsR4Rmt+zWIDa4wj9WtPkglU5Mlzx5P15ZrDcQfwSaeUNYpEdsAK15H1/mUQ+zqVg4dx4H3frGUlMdjG7/IfosiUIDernWDMIrJlxpmQVKkzKIq4eBGCSOOM1aHdRhOPImmzfaOmIRzbVOKwNHezWYucgqhkwSk49FQ1mlz0fRmVbtWqXwPpmoKZmU/Z6+omvkDefu/rrenXD97H3VDFIyjupLhYG94PLzb0+mC78/xbKaFdGP8ohao7tFRspCAodYeC5UEJqNh2ppyfN3s6rmllHjaI8Te4UMBSj5lJPy3YKlDKcylxM1tZ0xRED8TObOeIhSQuDGM2dSc7efwRi8Q+Lv3xfXBxvXbObPKb3zZIp1oHbLAFc6wHqRQCoFplPudxhSNmakYfoJsnzaviToUaKZ1axVdj27nO79BFbGjPOvdpYxTYYOAJkBOD0ayRH5OMoqJwB25cklgUA2VtaI0EWp9E6ZekFRp3SM1Umv0NJWHtVOIIw9n6NCRZm66+NhAnsprb8Nk0422UFfKsf56uc2eQogrMGjLjaBlHOJ8s2+jmmViKT3tQCyiVhQOF96Cb4+veBU+0LqMqpCf7n8YXVJTwVm/Iy/RR6HWJKmF4CRDuTLdKR3Ie6EVbISbggIkWOnVkM2ipD5Gx5xfF7N2HvitTJ4MAlB7wBB+7pnRGN3UAXBIoXadYAIVfvgIOI rDabAWij gvpwfqrw7cxM6ynYgkEYWOFtDJVvJVhHa/WtrwaXQqVJb72/UalyfAKsXb9Fw44ryPQ6hR00RF9SoZzWXsNcJ4v8jyJ0Kd/rNOuvNPd3TkGiSNJrQg15tSKWR8KPRD/ci/2rkA/869DwcgjNevxbMwLi/7Mwb4W14Qg1ySTWg/lqe0SsQc79QMUINixWYpqWI4VB2CgXdJDu7bffNdQV35hCsYJNT0v2yw6a6/NAdmC2DLEadQgXDhTEZeEXE6IJ81FNoX47S0l3BrobtAkLYvj0s3BPryZJr6w2pzJoW6yi0FJclgDyUVb8tyKrJurQQWx6wmXyqQ9W8D/k8qgLTNuNcBHBVr2g7vkNSH1zlu1dLDB/6Xx9oW10QEQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 --- arch/s390/Kconfig | 1 + arch/s390/kernel/crash_dump.c | 39 ++++++++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index d339fe4fdedf..d80450d957a9 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -230,6 +230,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 diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c index edae13416196..97b9e71b734d 100644 --- a/arch/s390/kernel/crash_dump.c +++ b/arch/s390/kernel/crash_dump.c @@ -497,6 +497,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) */ @@ -509,14 +522,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++; } } @@ -526,6 +533,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 */