From patchwork Wed Dec 4 12:54:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13893717 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 A86E9E7716E for ; Wed, 4 Dec 2024 12:55:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B117B6B00AA; Wed, 4 Dec 2024 07:55:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id ABF876B00AB; Wed, 4 Dec 2024 07:55:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8EACE6B00AC; Wed, 4 Dec 2024 07:55:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6A7B56B00AA for ; Wed, 4 Dec 2024 07:55:30 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id DC2FB120513 for ; Wed, 4 Dec 2024 12:55:29 +0000 (UTC) X-FDA: 82857272106.08.D4BAE00 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 3CDE980013 for ; Wed, 4 Dec 2024 12:55:00 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HaGf3Ilb; spf=pass (imf30.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@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=1733316918; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QMLpjiP43p31BywTFNffjh3NzCBHssnVGTYWU2BwGcs=; b=7NmWrWhLPPEg+UDjRi7NoBFMdJvcpk1T71RC0+0i80iE7RRyg4hrWIOX2+zNTJ5UKpVmv0 rlRSjmhGPXJRe7pAdhBNScGj97GYZjal6+3mOCbUjtJ+MpRn1fpKfxscYo5E8AD8uMUlSg rC+G13X6281HXSzcpr01bFlp0t78Was= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733316918; a=rsa-sha256; cv=none; b=5C9ZGf3CXgQxnFPRFqDOwDH4uG0T4d8polQWrxKmHjmKkJUoAuzxfJwj+0CEtA9ZpzWlVm /GZfpKk6fhHHxPG7Ri68MQWPIRc2Q2RdG4q+xJML8wfQQ78+GHQEX8eB9m7nkhGSSAITn/ qTTCUu9kZwYinwSdAckcVRRIxOHQ4aE= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HaGf3Ilb; spf=pass (imf30.hostedemail.com: domain of dhildenb@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhildenb@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733316927; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QMLpjiP43p31BywTFNffjh3NzCBHssnVGTYWU2BwGcs=; b=HaGf3IlbJ2Adk/Tq/5c69KLVUKaWWX5T2E9knbtsjei6OUKgLBAuWQTcBtqa6bdI5N300B A9D1ciSccIg9CZKgLH1M3FsNrCNf1787TymUDqf56oYA0l1gnuj1G+jSm6xO7GeUR+q4rJ irpoA3MCINn9MzNGLQQUc+dPJqSh54Y= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-640-N635yaQPNOqweAAon7wXyA-1; Wed, 04 Dec 2024 07:55:25 -0500 X-MC-Unique: N635yaQPNOqweAAon7wXyA-1 X-Mimecast-MFC-AGG-ID: N635yaQPNOqweAAon7wXyA Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-434a37a57dfso55382435e9.0 for ; Wed, 04 Dec 2024 04:55:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733316924; x=1733921724; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QMLpjiP43p31BywTFNffjh3NzCBHssnVGTYWU2BwGcs=; b=e49EYE2t5n247wFvuDi8+Ko9mHMj2UGxMo4fZWgTHUyuGa4361Q4Yv9nStqeJTguTS 5VBQMrPwnNvbGUC+NJhqdzZsKWYYaO5VcAQAwc37DAV9h8AtL5dJaqQCb8mPjcgRDPO+ t2OsycJ6FCr16QQk7mRREMvuh1Q2YvYRDNNQKaFoxFqR9/iBwh0pXjK/leb5ONcAv/mA 2eL/MmnlEMUFiG2DtQsnTa/VcXFSYD6ZIz73NjK0uMdLB0K3UlDLKBm7wY4INMHjbHLC esrEWVPREGIC/EBWP6wq4sheZK3MRjRsPIc4pL9UGzbui4UCL+KRK1JtKaJvgXhEC7Z8 RS1A== X-Gm-Message-State: AOJu0YwRUHitZuVPAXljcDmUsPFeJx/QJtaxO6oqFwwwiBXoSXLQMD2O DSFgNBFoLiQUnzPAS6qGzQtmz603izXhqohjyd+PaxmdYcWDu0jkU8JqfmvSl/tr3P9y9nINDvS AKA6lJ48tMihrwSC2M15KuuON122z5e/n8uzsjTZJaXGvRaNX X-Gm-Gg: ASbGncvtPqJzQW6ZssJgKg36JVgl+VY7/fNDMPHtcey1/HdaKkX1bCP7OsxZTCpvAXD ejV0PyK9/RZBgRuCZcQd+0vaXZPx5MUZAUt3R82LPc+ft7UaaiH0vHJBE5Aqf+fDt/FZJkaAiX3 CkpIxJRlY7j8hJkXQQUvaC6Wg5qEH0kZixkwRcpTVM8T+IoF7Y73MGy/hzLfqDFXDklKbBFjY4R tnggU/7FGOiOsvd2aR48XruANiucCkvn5ONp5KVj9NheoMsDhaa1zsP4vxl8tYbl7XPkKremTy+ b6qAh8J//VISWTyiqOppw64SlJK/NJ9ea7I= X-Received: by 2002:a05:600c:1910:b0:434:a962:2aa2 with SMTP id 5b1f17b1804b1-434d0a178d4mr49286505e9.33.1733316924456; Wed, 04 Dec 2024 04:55:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFzA2SYKI5zve6AhLcTcIqYEQR+M/xeFfejA5VMHPdifDyO5ycBtXVIAK8EC4IQe7u0N0Ewg== X-Received: by 2002:a05:600c:1910:b0:434:a962:2aa2 with SMTP id 5b1f17b1804b1-434d0a178d4mr49286335e9.33.1733316924087; Wed, 04 Dec 2024 04:55:24 -0800 (PST) Received: from localhost (p200300cbc70be10038d68aa111b0a20a.dip0.t-ipconnect.de. [2003:cb:c70b:e100:38d6:8aa1:11b0:a20a]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-434d52c0bc7sm23531055e9.35.2024.12.04.04.55.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Dec 2024 04:55:22 -0800 (PST) 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 v2 12/12] s390/kdump: virtio-mem kdump support (CONFIG_PROC_VMCORE_DEVICE_RAM) Date: Wed, 4 Dec 2024 13:54:43 +0100 Message-ID: <20241204125444.1734652-13-david@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241204125444.1734652-1-david@redhat.com> References: <20241204125444.1734652-1-david@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LOvuYJR59SSSxVfn8ORnLhoCqjWVvTID0FIXyi7hmT0_1733316924 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 3CDE980013 X-Stat-Signature: 4sa6qjou9r8omccjuywa6p8sa1h1qs4s X-Rspam-User: X-HE-Tag: 1733316900-871910 X-HE-Meta: U2FsdGVkX1+2NyicWz8yi3g/S0iH/8/LGM5VwydmbFQF4b6AzWdVmlB5Lqr+TFwkuYSuWGBVFJYNpMptacCBmdKjWSaRnAkfeoKVbL03FEa0mIL0kPAk56ZKCHs1ltvrA3PlohgbLsu/bKrfdX5KWzoI8Dr+gwSNvWC8lwifwlhsy7q9OvnQwHjcxgMRdCkMOuZFq5MYIAaBAruJzoXKpk0lkoC9JyU0YMh3e1IAk86b7N55tvVaH4WQ/v/eDSZiollaqVepXbm04hhzXzCXNWCFkQ3lkDs/kUwXZYOPKJB8KuChBMoGWyWoZjpCcubijZUehRfFq72K5CVJDX7wrZseuVdY+W1Xb2Sl/GoWAJ8fPDFkOzChovPpGg6nO3Ur+xRf+TQFthY9LmtPGUIfaQ2e6yw5xNY6JFdstYyC4/Pf2O90KNAVBF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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 0077969170e8..c230bad7f5cc 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -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 diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c index cd0c93a8fb8b..f699df2a2b11 100644 --- a/arch/s390/kernel/crash_dump.c +++ b/arch/s390/kernel/crash_dump.c @@ -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 */