From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658827580; cv=none; d=zohomail.com; s=zohoarc; b=SlHpQxd/fkzRgGXqwhNqWu80Epci7q/yA7BzHZcWMMv/dxtYt3DWYFUoFQ8Ld8FWwvAeYvFQUuSb5MlAOSuy9Envk8i0WkadP7rhhpGZrSExj47njscNv/Zd3HWz46o3djsKxjbOID63rBTBqjn/xz6C7LaAPRgOlyLXICzqC+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658827580; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VxegnwZvW+xAETkfyswh0EhnG1BjKHusc9M2zhmlUX0=; b=EpJlfWtlkPERUtjP05wAsAPViOZUlo4A9+YhCKy0SjQFHXfRn9OZGVQ4x+3egVtrI5tYj6cBT8q73teKYPOAqTT1pVpZBXKq2V6tV45mdbfDW5fM5Z8U3F6GBgnJt92HwV/0X7VZFpPBObR4S4S98Ttd93UjPqU7EsZL+D8w6a4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658827580434642.0754706144886; Tue, 26 Jul 2022 02:26:20 -0700 (PDT) Received: from localhost ([::1]:57088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGpX-00075k-6o for importer@patchew.org; Tue, 26 Jul 2022 05:26:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60034) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn0-000480-BD; Tue, 26 Jul 2022 05:23:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:16548) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGmx-0005XM-Gw; Tue, 26 Jul 2022 05:23:41 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9LYNN006830; Tue, 26 Jul 2022 09:23:35 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjpr1p3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:35 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9N7NG017156; Tue, 26 Jul 2022 09:23:35 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjpr1nh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:35 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LEI7026305; Tue, 26 Jul 2022 09:23:33 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3hg96wkjsy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:33 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NUeR22675864 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:30 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36D72A405F; Tue, 26 Jul 2022 09:23:30 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0B365A4054; Tue, 26 Jul 2022 09:23:29 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:28 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=VxegnwZvW+xAETkfyswh0EhnG1BjKHusc9M2zhmlUX0=; b=j5AS4okSVCdVS6UD6X7nfDQ39fkv6eMJu1xrS4VuskYnRjubqQwzuxz9qeHejlhvZj7b xI+v+Rq1J7TCT8AuKFxBFbvszy1UXdVbMGj50pLIeYkiJPfdEFKBgFgvVMNqmqweKAQl pSDg4bV00cFQPRiZ1wA1WM/qppJuObILSrInhFOItvBjYJi3klqCvRjKX5rM3Q2Petce +ZQVqDYVTv2xYorCvhj+Sa2kqn0ZCBqwokvu2LfAW1+yrEPmMQ/0wWy/0NtHL5KU+wqf XUXNh0V5AEZL20tKrUws4zrlMEIZc9fqDSf79tyYaqPxWlJy3YVG6303+OixuTFKE6Ui Pw== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 01/17] dump: Rename write_elf_loads to write_elf_phdr_loads Date: Tue, 26 Jul 2022 09:22:32 +0000 Message-Id: <20220726092248.128336-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 357A1lpw_DUJijV6ROJLeTG5CtCIjvXe X-Proofpoint-ORIG-GUID: BriHEpg0VFd7v3fhVTx7s919WtEHdj5O X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658827581331100001 Let's make it a bit clearer that we write the program headers of the PT_LOAD type. Signed-off-by: Janosch Frank Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Janis Schoetterl-Glausch Reviewed-by: Steffen Eiden --- dump/dump.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 4d9658ffa2..0ed7cf9c7b 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -490,7 +490,7 @@ static void get_offset_range(hwaddr phys_addr, } } =20 -static void write_elf_loads(DumpState *s, Error **errp) +static void write_elf_phdr_loads(DumpState *s, Error **errp) { ERRP_GUARD(); hwaddr offset, filesz; @@ -573,8 +573,8 @@ static void dump_begin(DumpState *s, Error **errp) return; } =20 - /* write all PT_LOAD to vmcore */ - write_elf_loads(s, errp); + /* write all PT_LOADs to vmcore */ + write_elf_phdr_loads(s, errp); if (*errp) { return; } --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658827568; cv=none; d=zohomail.com; s=zohoarc; b=RFdBDZkTyvwECgOp3cyXgD6V0s/dus+XkD1HPQeCS29S0vZ1pOe5xYhGMRqcUXSw+69J+O75Mh3hmFsYRW/k8zmnIMATArKUIGuQS5c9MsF9LPfS0fZm3Ea6EevtUq2dFmckb4WlYAFmvThi8L+GpdEZZE7DRhScIWIe8/v4UsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658827568; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WyJ2xf/GTmbbTbVk7+KYWPUgxHLFgqiliTyd91uchvo=; b=e7xzPDIz4Dmegx0HrmW4oHnGBJnj10SHV6kEeIwJB8nuoFx233TUVO4YlLKxMyKWiOHqQq/JAlRQ1opbjt2OM2M6eCXhWSQNGZqN8ThOLimO7Wd3gyJBRV1yyFk7FHYg3kDNARKvFBO5h2XnKWnw/nEMGRHgzLD+9T0cAvSmI+E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658827568801281.85945381564386; Tue, 26 Jul 2022 02:26:08 -0700 (PDT) Received: from localhost ([::1]:56832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGpL-0006u2-Gq for importer@patchew.org; Tue, 26 Jul 2022 05:26:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGmy-00047z-5d; Tue, 26 Jul 2022 05:23:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGmw-0005XS-92; Tue, 26 Jul 2022 05:23:39 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9LM44019809; Tue, 26 Jul 2022 09:23:37 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjm81px-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:37 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9LO79019893; Tue, 26 Jul 2022 09:23:36 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjm81p2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:36 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LALU007691; Tue, 26 Jul 2022 09:23:34 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3hg97tbjf8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:34 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NVmP23200126 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:31 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D46FA405C; Tue, 26 Jul 2022 09:23:31 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C494A4054; Tue, 26 Jul 2022 09:23:30 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:30 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=WyJ2xf/GTmbbTbVk7+KYWPUgxHLFgqiliTyd91uchvo=; b=cEE/g5uHhEh7RmOMYaTAJO6weEXJBgZRMU3274vQ/9MnlOHgr+TZJFI36sGl1cw35vyH VfHK29+KL1ObjitUwSUiGAR0JbpAZZ0eO6qC/4KcXte0ZTVBRorn9bPBX7QsNWt9Liwn KqL0Prski4B6bWBM/z2ereexpyioJGtU8UeLncan74ZPYpOzFkzf4p2caI01r/P3zzWB TWeraDMBk16oFx5UcgFo5eAoZ2pWgyNUFBZwdlXmxB3IFenwj/zCgFrHtijvpGYdbrMg 4uCjOxLLRaaBvygTNAh5bQsMgIm+ZRTEbL7lKwkeZkBzmnKd1R7qZRpMbZk7IPBOWp56 5w== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 02/17] dump: Introduce GuestPhysBlock offset and length filter functions Date: Tue, 26 Jul 2022 09:22:33 +0000 Message-Id: <20220726092248.128336-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0Ox4seX5ErDB_0cdd2vg8otqBkLuzFff X-Proofpoint-ORIG-GUID: tbdXcIWCTk_Pxlxpk7UU6N177mEkycIA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658827569298100003 Content-Type: text/plain; charset="utf-8" The iteration over the memblocks is hard to understand so it's about time to clean it up. Instead of manually grabbing the next memblock we can use QTAILQ_FOREACH to iterate over all memblocks. Additionally we move the calculation of the offset and length out by using the dump_get_memblock_*() functions. Signed-off-by: Janosch Frank Reviewed-by: Janis Schoetterl-Glausch --- dump/dump.c | 37 +++++++++++++++++++++++++++++++++++++ include/sysemu/dump.h | 5 +++++ 2 files changed, 42 insertions(+) diff --git a/dump/dump.c b/dump/dump.c index 0ed7cf9c7b..0fd7c76c1e 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -591,6 +591,43 @@ static void dump_begin(DumpState *s, Error **errp) write_elf_notes(s, errp); } =20 +int64_t dump_get_memblock_size(GuestPhysBlock *block, int64_t filter_area_= start, + int64_t filter_area_length) +{ + int64_t size, left, right; + + /* No filter, return full size */ + if (!filter_area_length) { + return block->target_end - block->target_start; + } + + /* calculate the overlapped region. */ + left =3D MAX(filter_area_start, block->target_start); + right =3D MIN(filter_area_start + filter_area_length, block->target_en= d); + size =3D right - left; + size =3D size > 0 ? size : 0; + + return size; +} + +int64_t dump_get_memblock_start(GuestPhysBlock *block, int64_t filter_area= _start, + int64_t filter_area_length) +{ + if (filter_area_length) { + /* return -1 if the block is not within filter area */ + if (block->target_start >=3D filter_area_start + filter_area_lengt= h || + block->target_end <=3D filter_area_start) { + return -1; + } + + if (filter_area_start > block->target_start) { + return filter_area_start - block->target_start; + } + } + + return 0; +} + static int get_next_block(DumpState *s, GuestPhysBlock *block) { while (1) { diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index ffc2ea1072..6ce3c24197 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -203,4 +203,9 @@ typedef struct DumpState { uint16_t cpu_to_dump16(DumpState *s, uint16_t val); uint32_t cpu_to_dump32(DumpState *s, uint32_t val); uint64_t cpu_to_dump64(DumpState *s, uint64_t val); + +int64_t dump_get_memblock_size(GuestPhysBlock *block, int64_t filter_area_= start, + int64_t filter_area_length); +int64_t dump_get_memblock_start(GuestPhysBlock *block, int64_t filter_area= _start, + int64_t filter_area_length); #endif --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658827868; cv=none; d=zohomail.com; s=zohoarc; b=mWDdyuN17E+lm76+IMxYAcRK+31YA0ckHHxnBjlykf+zPx4ej3AvqYv0OD8anI7DwKwV6Tv5qzQl4RtCyUjvhZmasljCVGik74s+S234/5pZlhsVSHXMMeydjal4jUzAXRQ3N5YL4KgTH82kSVa11OzhX5FDu6aTdeWtU/xfy5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658827868; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LS8pnEvpw99rgr0cK7XIWYWcq9881KCuKAGk8GYir3k=; b=PiRDp3XlJq9dh3HlpvLXET5M902mgdqt/jWrflVLV7ZUk7uNqV7eoCErIauGx6Pa8XOkFIDmFRr2h2MCLmD4G4BKSFQJW0MjVHTS/uovlVbgwOppsPbtIzW+Exs0SFq2l+7Zqwa7AidrRQhOTlR6pM48ZVv8SkFI7S+4R38x7Ek= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658827868318621.016351430427; Tue, 26 Jul 2022 02:31:08 -0700 (PDT) Received: from localhost ([::1]:37028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGuB-0004Dv-1C for importer@patchew.org; Tue, 26 Jul 2022 05:31:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn1-00049J-VB; Tue, 26 Jul 2022 05:23:43 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:22428) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGmz-0005Xq-Et; Tue, 26 Jul 2022 05:23:42 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q8rZpV003444; Tue, 26 Jul 2022 09:23:39 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtgg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:39 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q8tOh8011926; Tue, 26 Jul 2022 09:23:38 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtfm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:38 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9L1Ta017876; Tue, 26 Jul 2022 09:23:36 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3hh6euj8j4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:35 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NWsE21430708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:32 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4BE1A405B; Tue, 26 Jul 2022 09:23:32 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A39F5A4054; Tue, 26 Jul 2022 09:23:31 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:31 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=LS8pnEvpw99rgr0cK7XIWYWcq9881KCuKAGk8GYir3k=; b=AjyMeJPlGdFX965pg+zDmAKWPMb3+a4vCyplsslRfUPeejhR0AaUVOK3RHNhlMA3+zrX V3Tkxe5+I9hBOn0wBQDOvFZ6kP4w8kYCT4f4c3KBKAUkORmYvZOKhv42VchkihSnsFoP QOLP5dkzqA2T8qySMq47RkXhCdX81V7D790zCxyNYaG5rQXbwzfLyEjBU/KJDon2KcpX S0OWQdVL2o+D3IQG2X6n4f/DPjVzie95fG6mjmiC4Q2PObpIxruNJQ5d7DkGRpqE5OXm ovJyJlq+hPal3B+nlRkaT/VAQV9YtegMYgYWyTbxXauWrynRjRs3Rb3aqE5YKeB95kBY Kg== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 03/17] dump: Convert GuestPhysBlock iterators and use the filter functions Date: Tue, 26 Jul 2022 09:22:34 +0000 Message-Id: <20220726092248.128336-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Jk3yy2JKNMDFBJHbKldO1A9Uz_lvt-ZY X-Proofpoint-ORIG-GUID: fdIcymmzY054hS2rWR4DNaJ3JcI1Rydw X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658827869526100001 Content-Type: text/plain; charset="utf-8" The iteration over the memblocks is hard to understand so it's about time to clean it up. Instead of manually grabbing the next memblock we can use QTAILQ_FOREACH to iterate over all memblocks. Additionally we move the calculation of the offset and length out by using the dump_get_memblock_*() functions. Signed-off-by: Janosch Frank Reviewed-by: Janis Schoetterl-Glausch --- dump/dump.c | 51 +++++++++++---------------------------------------- 1 file changed, 11 insertions(+), 40 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 0fd7c76c1e..35b9833a00 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -628,56 +628,27 @@ int64_t dump_get_memblock_start(GuestPhysBlock *block= , int64_t filter_area_start return 0; } =20 -static int get_next_block(DumpState *s, GuestPhysBlock *block) -{ - while (1) { - block =3D QTAILQ_NEXT(block, next); - if (!block) { - /* no more block */ - return 1; - } - - s->start =3D 0; - s->next_block =3D block; - if (s->has_filter) { - if (block->target_start >=3D s->begin + s->length || - block->target_end <=3D s->begin) { - /* This block is out of the range */ - continue; - } - - if (s->begin > block->target_start) { - s->start =3D s->begin - block->target_start; - } - } - - return 0; - } -} - /* write all memory to vmcore */ static void dump_iterate(DumpState *s, Error **errp) { ERRP_GUARD(); GuestPhysBlock *block; - int64_t size; + int64_t memblock_size, memblock_start; =20 - do { - block =3D s->next_block; - - size =3D block->target_end - block->target_start; - if (s->has_filter) { - size -=3D s->start; - if (s->begin + s->length < block->target_end) { - size -=3D block->target_end - (s->begin + s->length); - } + QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) { + memblock_start =3D dump_get_memblock_start(block, s->begin, s->len= gth); + if (memblock_start =3D=3D -1) { + continue; } - write_memory(s, block, s->start, size, errp); + + memblock_size =3D dump_get_memblock_size(block, s->begin, s->lengt= h); + + /* Write the memory to file */ + write_memory(s, block, memblock_start, memblock_size, errp); if (*errp) { return; } - - } while (!get_next_block(s, block)); + } } =20 static void create_vmcore(DumpState *s, Error **errp) --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658827601; cv=none; d=zohomail.com; s=zohoarc; b=P9JSgE/ww5jDjDOyfkjcfrzvsckPVDhK6LBUPzDyC5vzLgRJL+kTv2Rw//iuK9Ub7r1e64tIFltU0jJaihkLc7scmPYfw9pHBa9+OtdhGXTzRqdcz68EITSYWzXOgH/fuvyGI8ssAWiuqWChQqQM57ItoUMHuYJakiB2yh9V+lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658827601; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M1mFnujovPpQdW0okbSzoTY+7ltrGORMcJD5SriZqMc=; b=ELjNwOz/FKpDcVxWEgykrwF8nhDFXU5Osu5WKWghHBh32EcPiumX4ywbo/R74TcFLvsY2aRx6wNOuw1ckpD9IrDgG1Z3CRVSXolONTTZjowuKZPhDDhrqYbV4mYqVTN1ImzJIhekLS63KBR/7bQ9wv42Y6SDr85+NC83qyalW7A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658827601178644.5223760808573; Tue, 26 Jul 2022 02:26:41 -0700 (PDT) Received: from localhost ([::1]:57190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGpp-00079f-9x for importer@patchew.org; Tue, 26 Jul 2022 05:26:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn2-00049G-07; Tue, 26 Jul 2022 05:23:44 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:63134) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGmz-0005Xs-65; Tue, 26 Jul 2022 05:23:42 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9LOcb019867; Tue, 26 Jul 2022 09:23:40 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjm81qq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:39 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9M69B022040; Tue, 26 Jul 2022 09:23:39 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjm81q8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:39 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9L4pT029671; Tue, 26 Jul 2022 09:23:37 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma01fra.de.ibm.com with ESMTP id 3hg98nbj1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:37 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9LZh823265578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:21:35 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 189CAA405F; Tue, 26 Jul 2022 09:23:34 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB1F0A4054; Tue, 26 Jul 2022 09:23:32 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:32 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=M1mFnujovPpQdW0okbSzoTY+7ltrGORMcJD5SriZqMc=; b=TOZgf8Styjzl9d6WbzuvRCkjF6MIPMHjZitwkh/kmW9ExaEso63ECwMvzJbdvWBs/cNT TKWq/SruZy+gEsk4HOfY+keTkcrMd0Yw+byWz/EIM3v1Q8zj5Lljh/H826JQFw3X/8UD oJLDkG1a35jm8fwi8XPM1P0J1I0S2bCp3c5eAqMEKs8HnruMjixo5TGmtTOmz7t9ZuCd Blh8ms1VAMMs6pTgu4ofTAhPJ22bsLNUF7ToVzUNMMr/0ynAYnYgwH6OYORDy5n6FrLu wsAYt+ppcgTkDSiSzJbAnm6XQSfO/Q2m5BcOvTsPQmfgMVnW/aShWMhx8QYg+bvOAztH Vw== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 04/17] dump: Rework get_start_block Date: Tue, 26 Jul 2022 09:22:35 +0000 Message-Id: <20220726092248.128336-5-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: woFI7y_RLLUIXsXUOBT3pe-A4wlu4o4Y X-Proofpoint-ORIG-GUID: uy9CM3bvWV74bHarUmeaZDIz0V17eZoW X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=931 priorityscore=1501 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658827601403100001 Content-Type: text/plain; charset="utf-8" get_start_block() returns the start address of the first memory block or -1. With the GuestPhysBlock iterator conversion we don't need to set the start address and can therefore remove that code. The only functionality left is the validation of the start block so it only makes sense to re-name the function to validate_start_block() Signed-off-by: Janosch Frank Reviewed-by: Janis Schoetterl-Glausch Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Steffen Eiden --- dump/dump.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 35b9833a00..b59faf9941 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -1498,30 +1498,22 @@ static void create_kdump_vmcore(DumpState *s, Error= **errp) } } =20 -static ram_addr_t get_start_block(DumpState *s) +static int validate_start_block(DumpState *s) { GuestPhysBlock *block; =20 if (!s->has_filter) { - s->next_block =3D QTAILQ_FIRST(&s->guest_phys_blocks.head); return 0; } =20 QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) { + /* This block is out of the range */ if (block->target_start >=3D s->begin + s->length || block->target_end <=3D s->begin) { - /* This block is out of the range */ continue; } - - s->next_block =3D block; - if (s->begin > block->target_start) { - s->start =3D s->begin - block->target_start; - } else { - s->start =3D 0; - } - return s->start; - } + return 0; + } =20 return -1; } @@ -1668,8 +1660,8 @@ static void dump_init(DumpState *s, int fd, bool has_= format, goto cleanup; } =20 - s->start =3D get_start_block(s); - if (s->start =3D=3D -1) { + /* Is the filter filtering everything? */ + if (validate_start_block(s) =3D=3D -1) { error_setg(errp, QERR_INVALID_PARAMETER, "begin"); goto cleanup; } --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658827911; cv=none; d=zohomail.com; s=zohoarc; b=VCzPG65hTjaJ7NjqAgWaD07UcXlzRGxaf9/TfXQC+W1NtjxFZUGTv/nZ8BMzhYPku0TC5DN06OH10eUkK7fBRoQm3/Ap7e8KVNQcBLW15VEgFn5to9xUz1qyFZy7Hi+/+g0pHgD3y/QLW6snmqxfWPy+hZrCfZbLXMdU6gea2kg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658827911; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/ejzETTvvstJB7+FkXZKzk+iZVxTBvrWgAs9MT4fj3o=; b=fBSJvbO+nggSoeGjmLuJtvytTKRsdKdocW+ZFfrv4rSiUFfOEOBZiXXeALiCD5lQdJlltA3Xd2qPc5X2vYFnFO8MtsHQi32GzOdYajsHseO6sLdJ5UuiAPh3R+pjVeE/4TgLA1/XJYJL72SXc36ZBYUSZkBRskGK/+vEBq41bZQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658827911159230.5066839273802; Tue, 26 Jul 2022 02:31:51 -0700 (PDT) Received: from localhost ([::1]:37580 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGuq-0004bu-Cx for importer@patchew.org; Tue, 26 Jul 2022 05:31:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn3-0004Az-Tj; Tue, 26 Jul 2022 05:23:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:7048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn0-0005Y8-DI; Tue, 26 Jul 2022 05:23:44 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q8lFYn014879; Tue, 26 Jul 2022 09:23:41 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd2j91c4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:41 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9KPqM038242; Tue, 26 Jul 2022 09:23:40 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd2j91bj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:40 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9L7K5007688; Tue, 26 Jul 2022 09:23:38 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma06ams.nl.ibm.com with ESMTP id 3hg97tbjfa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:38 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NZL014549290 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:35 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6923AA4054; Tue, 26 Jul 2022 09:23:35 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3F15BA405B; Tue, 26 Jul 2022 09:23:34 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:34 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=/ejzETTvvstJB7+FkXZKzk+iZVxTBvrWgAs9MT4fj3o=; b=c9UgrUqg7p5qmJqGtC/xipUytDcdzNLmVnNuKDe/dAYJpJ+LJrbTs+00JdprjF86YoPr sAPQkSLllu0V6KlsA9H6lIgFvFzzPY3cdJNzVblvuGGHXz8smdUGlTTIjb5jHSPJto0L PAL47UP+rRjmWtE2x542zawZnXAKzWtEBrkpf8ILf/6D3gBdfH+wvcnBWcY+CfC+GOa0 M6O5WuwYb+68O1Dr+AEGoVIzqp/nJ7K1tHdEViXT6u7L7D2TQxWRwHX6zrvpBM2Ubiu9 YKgBi1ltK/nYfpZ1n0a7pzEIK3gN4WAsDfaIowM4IWROERTVGC8mMiu/ZtBG9QAFvjf8 vw== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 05/17] dump: Cleanup and annotate guest memory related DumpState struct members Date: Tue, 26 Jul 2022 09:22:36 +0000 Message-Id: <20220726092248.128336-6-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: RoFKsUgNBF6lDXZ8SeTw5yYJ8QX2Hvvm X-Proofpoint-GUID: Y9QQ6Lx8bfM8sK9xJ6iY6FqW4xq1CvoN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 bulkscore=0 impostorscore=0 adultscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658827911736100001 Content-Type: text/plain; charset="utf-8" We can safely remove next_block and start as both of them aren't used anymore due to the block iteration re-work. Also we add comments to the remaining guest memory related struct members and a comment on top to group them. Signed-off-by: Janosch Frank Reviewed-by: Janis Schoetterl-Glausch Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/sysemu/dump.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 6ce3c24197..24ebb02660 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -166,11 +166,10 @@ typedef struct DumpState { hwaddr memory_offset; int fd; =20 - GuestPhysBlock *next_block; - ram_addr_t start; - bool has_filter; - int64_t begin; - int64_t length; + /* Guest memory related data */ + bool has_filter; /* Are we dumping parts of the memory? */ + int64_t begin; /* Start address of the chunk we want to du= mp */ + int64_t length; /* Length of the dump we want to dump */ =20 uint8_t *note_buf; /* buffer for notes */ size_t note_buf_offset; /* the writing place in note_buf */ --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658827894; cv=none; d=zohomail.com; s=zohoarc; b=ebwayEZC3uWM6NFyLlw17DTWLysodvtMPmgcBnZBGfOUY9iK8kg9smUuY9h8WUiV4nW96BqNXlYRgrcmSahMuC5uwqt6Y5duAPj4ogI3bUiFiXsyXulubReMnBvMeZ8Q5i1gtjfq+QdCSOYdbeHbDFdIorularmqWNF7yqwbC1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658827894; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X2Yf6LU7fHnSMQKqkG6uX3k7j7QPvOsYOk4GRYmLTOo=; b=Z5QoGd6n8HNx8brtOahkQv6Rtd3bJMdKOv0jzDKUyNO++SGLtAH6i8vO953lTksJDu/LCF0rLquCBI1ItMgZTp/HFLaQoz7KwNMvgQDBznHPnHCjrBE5hBfAUDj0MApdA6sGbcU8vUFJElNp5oa4HPGlI2wpqSRZEpt8IwDJJls= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658827894658501.94290703111096; Tue, 26 Jul 2022 02:31:34 -0700 (PDT) Received: from localhost ([::1]:37550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGua-0004ai-H7 for importer@patchew.org; Tue, 26 Jul 2022 05:31:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn5-0004EU-6u; Tue, 26 Jul 2022 05:23:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:15730 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn2-0005YK-0O; Tue, 26 Jul 2022 05:23:46 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9DueQ030610; Tue, 26 Jul 2022 09:23:42 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdeu081b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:42 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9GL7O006878; Tue, 26 Jul 2022 09:23:42 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdeu080r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:41 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LEI8026305; Tue, 26 Jul 2022 09:23:40 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 3hg96wkjt4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:39 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NaLm24510776 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:36 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0D02A405F; Tue, 26 Jul 2022 09:23:36 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F86FA4054; Tue, 26 Jul 2022 09:23:35 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:35 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=X2Yf6LU7fHnSMQKqkG6uX3k7j7QPvOsYOk4GRYmLTOo=; b=dURgToBfC6VeDWIM8xeXjyOZ6CTqIzza4GX2z/HoV/IYNhFRGPNGJnGtlZl6LJYxqGem TkQLPlp4i1SorHi+4fqFPWYioIZ/fi06ewT8tBkpFSaGbeaYMRkmQgnj63EVPdd4AjzK xUx44gw77Mt8/Qq5Ld1BMBdd1H7D/UP2YfB53mxxnMq9EkqjHqko6ClDsy+HY2dYPbD9 tS3BQSzrmYOnI+iM8UVzDHwEns/2Kv7Yd6Z0DPS7iCxaBinI8n3KaG3YuopyD/DzRVZr gj4PyI4c1LXXY+QFOT0glBh09JPS2zImIqJ6VkMVUfpIUGA7UvrkghN8rEqdazaEWK26 Jw== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 06/17] dump: Rework dump_calculate_size function Date: Tue, 26 Jul 2022 09:22:37 +0000 Message-Id: <20220726092248.128336-7-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 11OrLm-KEMsSZPF4CfFA7py_jN_ODlYi X-Proofpoint-ORIG-GUID: z_l844BfEj1cXeHD5HNLS7hyixWeDse_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658827895678100001 Content-Type: text/plain; charset="utf-8" dump_calculate_size() sums up all the sizes of the guest memory blocks. Since we already have a function that calculates the size of a single memory block (dump_get_memblock_size()) we can simply iterate over the blocks and use the function instead of calculating the size ourselves. Signed-off-by: Janosch Frank Reviewed-by: Marc-Andr=C3=A9 Lureau --- dump/dump.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index b59faf9941..57558a4d4b 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -1540,25 +1540,17 @@ bool qemu_system_dump_in_progress(void) return (qatomic_read(&state->status) =3D=3D DUMP_STATUS_ACTIVE); } =20 -/* calculate total size of memory to be dumped (taking filter into - * acoount.) */ +/* + * calculate total size of memory to be dumped (taking filter into + * account.) + */ static int64_t dump_calculate_size(DumpState *s) { GuestPhysBlock *block; - int64_t size =3D 0, total =3D 0, left =3D 0, right =3D 0; + int64_t total =3D 0; =20 QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) { - if (s->has_filter) { - /* calculate the overlapped region. */ - left =3D MAX(s->begin, block->target_start); - right =3D MIN(s->begin + s->length, block->target_end); - size =3D right - left; - size =3D size > 0 ? size : 0; - } else { - /* count the whole region in */ - size =3D (block->target_end - block->target_start); - } - total +=3D size; + total +=3D dump_get_memblock_size(block, s->begin, s->length); } =20 return total; --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658828151; cv=none; d=zohomail.com; s=zohoarc; b=WuzG84NLiUIvwHT6oSDLxeWMmJgb4COYyJgwx1u+O1wkl7FAKuagF+8bG2Nu9cmG2PueBUVHCYFH6wPI6u3TI3jBrGgcDeaIOa83Etik/Zrya/IdbUhN/oGgsoKQmt/ljexRXU2NdYehvEoD/0Ep5Z7YPIenk5EP6aSVIMK/iwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658828151; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L9HV+pjCkrESK5CCDEmQhwpnkH0NrI/8xjxugabbCrc=; b=ZXb7q2oI33PQUkJ/nmL9yUv5InBieh4J1Q7O3hgaglFW4kojMh4/95TD3Hy3oUdaL6hD64kxGCCNX9w/nS5LABxGfvvbgEbCByvaqnGymFmj+5E5B8YlNA4vStCoy6fVKZed66qCjFtn7mN2R3IUFJwLD2Pu9sQS51rtfM/J6r0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658828151956784.578314625523; Tue, 26 Jul 2022 02:35:51 -0700 (PDT) Received: from localhost ([::1]:45338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGyk-0001bQ-Rt for importer@patchew.org; Tue, 26 Jul 2022 05:35:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn6-0004FN-1d; Tue, 26 Jul 2022 05:23:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:32464) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn3-0005YX-Un; Tue, 26 Jul 2022 05:23:47 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9LMB7019799; Tue, 26 Jul 2022 09:23:43 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjm81s8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:43 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9MJKE022499; Tue, 26 Jul 2022 09:23:43 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjm81r8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:42 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LU4P017971; Tue, 26 Jul 2022 09:23:41 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3hh6euj8j7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:40 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NcSX19530112 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:38 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0DDCDA405C; Tue, 26 Jul 2022 09:23:38 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D76BAA4054; Tue, 26 Jul 2022 09:23:36 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:36 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=L9HV+pjCkrESK5CCDEmQhwpnkH0NrI/8xjxugabbCrc=; b=fop5baEyUdRTHDynGLgOCY+eX1LSpQ41yZnSAs8UBiW3syQ9ePgTDFXveO/mCSKip0x5 svkewp5320tpwT6AJ3+QLt54UJ41qB0PCi3Q/26V0Z9x+t32M34216XUcVs90T8lRJRr VzkKokbZhUCBwxl7XDf43PBW0WDPwRKgapVAvU9IC3z2zjFVl9a5mFc8QsMgZdZC067/ iNFuf5VnhTLoQGLth0sa99OhhhlruJPxGXXjMBwbU96zEw4MvIBzb+ZPkJIuj1AIZta/ e7vc32WsYglZK3QsEzm5WmRG0T0/im3Jm+959ZWhso5tMTGioWppHGB47/uUCKMJK8YI dw== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 07/17] dump: Allocate header Date: Tue, 26 Jul 2022 09:22:38 +0000 Message-Id: <20220726092248.128336-8-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: NXT6ftgswV01tamob56kgAqZq3wYaKfA X-Proofpoint-ORIG-GUID: jU6ZXkLnOvgnv9fEY3BPYQsV4gWj7PgX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 suspectscore=0 mlxscore=0 malwarescore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 mlxlogscore=999 priorityscore=1501 spamscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658828152774100001 Allocating the header lets us write it at a later time and hence also allows us to change section and segment table offsets until we finally write it. Signed-off-by: Janosch Frank Reviewed-by: Marc-Andr=C3=A9 Lureau --- dump/dump.c | 127 +++++++++++++++++++++--------------------- include/sysemu/dump.h | 1 + 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 57558a4d4b..8a7ce95610 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -98,6 +98,7 @@ static int dump_cleanup(DumpState *s) memory_mapping_list_free(&s->list); close(s->fd); g_free(s->guest_note); + g_free(s->elf_header); s->guest_note =3D NULL; if (s->resume) { if (s->detached) { @@ -126,73 +127,49 @@ static int fd_write_vmcore(const void *buf, size_t si= ze, void *opaque) return 0; } =20 -static void write_elf64_header(DumpState *s, Error **errp) +static void prepare_elf64_header(DumpState *s) { - /* - * phnum in the elf header is 16 bit, if we have more segments we - * set phnum to PN_XNUM and write the real number of segments to a - * special section. - */ - uint16_t phnum =3D MIN(s->phdr_num, PN_XNUM); - Elf64_Ehdr elf_header; - int ret; + uint16_t phnum =3D s->phdr_num >=3D PN_XNUM ? PN_XNUM : s->phdr_num; + Elf64_Ehdr *elf_header =3D s->elf_header; =20 - memset(&elf_header, 0, sizeof(Elf64_Ehdr)); - memcpy(&elf_header, ELFMAG, SELFMAG); - elf_header.e_ident[EI_CLASS] =3D ELFCLASS64; - elf_header.e_ident[EI_DATA] =3D s->dump_info.d_endian; - elf_header.e_ident[EI_VERSION] =3D EV_CURRENT; - elf_header.e_type =3D cpu_to_dump16(s, ET_CORE); - elf_header.e_machine =3D cpu_to_dump16(s, s->dump_info.d_machine); - elf_header.e_version =3D cpu_to_dump32(s, EV_CURRENT); - elf_header.e_ehsize =3D cpu_to_dump16(s, sizeof(elf_header)); - elf_header.e_phoff =3D cpu_to_dump64(s, s->phdr_offset); - elf_header.e_phentsize =3D cpu_to_dump16(s, sizeof(Elf64_Phdr)); - elf_header.e_phnum =3D cpu_to_dump16(s, phnum); + memcpy(elf_header, ELFMAG, SELFMAG); + elf_header->e_ident[EI_CLASS] =3D ELFCLASS64; + elf_header->e_ident[EI_DATA] =3D s->dump_info.d_endian; + elf_header->e_ident[EI_VERSION] =3D EV_CURRENT; + elf_header->e_type =3D cpu_to_dump16(s, ET_CORE); + elf_header->e_machine =3D cpu_to_dump16(s, s->dump_info.d_machine); + elf_header->e_version =3D cpu_to_dump32(s, EV_CURRENT); + elf_header->e_ehsize =3D cpu_to_dump16(s, sizeof(*elf_header)); + elf_header->e_phoff =3D cpu_to_dump64(s, s->phdr_offset); + elf_header->e_phentsize =3D cpu_to_dump16(s, sizeof(Elf64_Phdr)); + elf_header->e_phnum =3D cpu_to_dump16(s, phnum); if (s->shdr_num) { - elf_header.e_shoff =3D cpu_to_dump64(s, s->shdr_offset); - elf_header.e_shentsize =3D cpu_to_dump16(s, sizeof(Elf64_Shdr)); - elf_header.e_shnum =3D cpu_to_dump16(s, s->shdr_num); - } - - ret =3D fd_write_vmcore(&elf_header, sizeof(elf_header), s); - if (ret < 0) { - error_setg_errno(errp, -ret, "dump: failed to write elf header"); + elf_header->e_shoff =3D cpu_to_dump64(s, s->shdr_offset); + elf_header->e_shentsize =3D cpu_to_dump16(s, sizeof(Elf64_Shdr)); + elf_header->e_shnum =3D cpu_to_dump16(s, s->shdr_num); } } =20 -static void write_elf32_header(DumpState *s, Error **errp) +static void prepare_elf32_header(DumpState *s) { - /* - * phnum in the elf header is 16 bit, if we have more segments we - * set phnum to PN_XNUM and write the real number of segments to a - * special section. - */ - uint16_t phnum =3D MIN(s->phdr_num, PN_XNUM); - Elf32_Ehdr elf_header; - int ret; + uint16_t phnum =3D s->phdr_num >=3D PN_XNUM ? PN_XNUM : s->phdr_num; + Elf32_Ehdr *elf_header =3D s->elf_header; =20 - memset(&elf_header, 0, sizeof(Elf32_Ehdr)); - memcpy(&elf_header, ELFMAG, SELFMAG); - elf_header.e_ident[EI_CLASS] =3D ELFCLASS32; - elf_header.e_ident[EI_DATA] =3D s->dump_info.d_endian; - elf_header.e_ident[EI_VERSION] =3D EV_CURRENT; - elf_header.e_type =3D cpu_to_dump16(s, ET_CORE); - elf_header.e_machine =3D cpu_to_dump16(s, s->dump_info.d_machine); - elf_header.e_version =3D cpu_to_dump32(s, EV_CURRENT); - elf_header.e_ehsize =3D cpu_to_dump16(s, sizeof(elf_header)); - elf_header.e_phoff =3D cpu_to_dump32(s, s->phdr_offset); - elf_header.e_phentsize =3D cpu_to_dump16(s, sizeof(Elf32_Phdr)); - elf_header.e_phnum =3D cpu_to_dump16(s, phnum); + memcpy(elf_header, ELFMAG, SELFMAG); + elf_header->e_ident[EI_CLASS] =3D ELFCLASS32; + elf_header->e_ident[EI_DATA] =3D s->dump_info.d_endian; + elf_header->e_ident[EI_VERSION] =3D EV_CURRENT; + elf_header->e_type =3D cpu_to_dump16(s, ET_CORE); + elf_header->e_machine =3D cpu_to_dump16(s, s->dump_info.d_machine); + elf_header->e_version =3D cpu_to_dump32(s, EV_CURRENT); + elf_header->e_ehsize =3D cpu_to_dump16(s, sizeof(*elf_header)); + elf_header->e_phoff =3D cpu_to_dump32(s, s->phdr_offset); + elf_header->e_phentsize =3D cpu_to_dump16(s, sizeof(Elf32_Phdr)); + elf_header->e_phnum =3D cpu_to_dump16(s, phnum); if (s->shdr_num) { - elf_header.e_shoff =3D cpu_to_dump32(s, s->shdr_offset); - elf_header.e_shentsize =3D cpu_to_dump16(s, sizeof(Elf32_Shdr)); - elf_header.e_shnum =3D cpu_to_dump16(s, s->shdr_num); - } - - ret =3D fd_write_vmcore(&elf_header, sizeof(elf_header), s); - if (ret < 0) { - error_setg_errno(errp, -ret, "dump: failed to write elf header"); + elf_header->e_shoff =3D cpu_to_dump32(s, s->shdr_offset); + elf_header->e_shentsize =3D cpu_to_dump16(s, sizeof(Elf32_Shdr)); + elf_header->e_shnum =3D cpu_to_dump16(s, s->shdr_num); } } =20 @@ -528,6 +505,26 @@ static void write_elf_notes(DumpState *s, Error **errp) } } =20 +static void prepare_elf_header(DumpState *s) +{ + if (dump_is_64bit(s)) { + prepare_elf64_header(s); + } else { + prepare_elf32_header(s); + } +} + +static void write_elf_header(DumpState *s, Error **errp) +{ + size_t size =3D dump_is_64bit(s) ? sizeof(Elf64_Ehdr) : sizeof(Elf32_E= hdr); + int ret; + + ret =3D fd_write_vmcore(s->elf_header, size, s); + if (ret < 0) { + error_setg_errno(errp, -ret, "dump: failed to write elf header"); + } +} + /* write elf header, PT_NOTE and elf note to vmcore. */ static void dump_begin(DumpState *s, Error **errp) { @@ -557,12 +554,11 @@ static void dump_begin(DumpState *s, Error **errp) * vmcore. */ =20 - /* write elf header to vmcore */ - if (dump_is_64bit(s)) { - write_elf64_header(s, errp); - } else { - write_elf32_header(s, errp); - } + /* Write elf header to buffer */ + prepare_elf_header(s); + + /* Start to write stuff into file descriptor */ + write_elf_header(s, errp); if (*errp) { return; } @@ -1679,6 +1675,9 @@ static void dump_init(DumpState *s, int fd, bool has_= format, goto cleanup; } =20 + s->elf_header =3D g_malloc0(dump_is_64bit(s) ? + sizeof(Elf64_Ehdr) : sizeof(Elf32_Ehdr)); + /* * The goal of this block is to (a) update the previously guessed * phys_base, (b) copy the guest note out of the guest. diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 24ebb02660..7f9a848573 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -171,6 +171,7 @@ typedef struct DumpState { int64_t begin; /* Start address of the chunk we want to du= mp */ int64_t length; /* Length of the dump we want to dump */ =20 + void *elf_header; uint8_t *note_buf; /* buffer for notes */ size_t note_buf_offset; /* the writing place in note_buf */ uint32_t nr_cpus; /* number of guest's cpu */ --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658828153; cv=none; d=zohomail.com; s=zohoarc; b=Y/UYpcwEyNXysJpHvkmRYcvTK6tJ6vIiTgx3+TLfNZ2koTz6H2VmphiSaxdApao1MMVZAOmEC5OUznBK5Mgv+CMXnWLsuM5c4gRVDbuecIBFuBl/euWfbs+9Wf4n/iv37VV34CIgAOKw9M2dZJsGpBr0ekoFrlt39zAkdj0sUDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658828153; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hz9XyFKRl9dDr+dCDlFnFYfCH+B1ukZv9QKSJPthwWI=; b=SqMrUofIqSO9io6qFuYQ0dBUVl/wWRNFX0RFneUvGV0nV2JVPFtRpZ+2aRb4RCnku4njY9PZ3eXavMHz360US20CIDIRoCQvmqBDYZLanCOJKtWDlihiLUwG6td/uJjr7xNxZ56ZjZmt11AWG5SSHO4ghpbRICO0Gga+FEkpkwg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658828153815330.4808284382275; Tue, 26 Jul 2022 02:35:53 -0700 (PDT) Received: from localhost ([::1]:45462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGym-0001gr-Ph for importer@patchew.org; Tue, 26 Jul 2022 05:35:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn6-0004HO-S9; Tue, 26 Jul 2022 05:23:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50158) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn4-0005Ym-9s; Tue, 26 Jul 2022 05:23:48 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9LY9Q006820; Tue, 26 Jul 2022 09:23:45 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjpr1sj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:44 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9Nidc018753; Tue, 26 Jul 2022 09:23:44 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjpr1rx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:44 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LRSs017962; Tue, 26 Jul 2022 09:23:42 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3hh6euj8j8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:42 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NdOj14549308 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:39 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 544CCA4054; Tue, 26 Jul 2022 09:23:39 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 344AFA405F; Tue, 26 Jul 2022 09:23:38 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:38 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=hz9XyFKRl9dDr+dCDlFnFYfCH+B1ukZv9QKSJPthwWI=; b=Snar8syypPs0iR3salJdh3rHDXC87xMvjyznDwNLPA6hZk87k0i0TIdpfraUVxBua3fy XSTK8tUh8FxMi2BK4RLv1PPAP7t5JkBaA073YxS3wq7qtrVmt0mNeXcyFdaQtf0RZUA8 GgxmQaCNs/72pqP6C93asnAoRcwcAY60WM9VcCz8GjuYU7QbSyM7rXIqr2d/oJPfXPW2 Pkw4DQV688HxHs2XI8kt8Pt2RYSChhpKERf071wmyC2zXVIYDyfQjfS3TenSnDbVBWXh TuietBV+SvsyH2bc874zB/0wDXzObXm/U7mBBRkW/pwInYJhI2W/Qy/nC4qzUzP8uaNq iA== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 08/17] dump: Split write of section headers and data and add a prepare step Date: Tue, 26 Jul 2022 09:22:39 +0000 Message-Id: <20220726092248.128336-9-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: U8MeaioYCGvA4wZjupPEbrWrMj5r0tw8 X-Proofpoint-ORIG-GUID: o-OgckqO_HYLUXZPvTBM9FjpZ1xokI9g X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658828154730100003 Content-Type: text/plain; charset="utf-8" By splitting the writing of the section headers and (future) section data we prepare for the addition of a string table section and architecture sections. At the same time we move the writing of the section to the end of the dump process. This allows the upcoming architecture section code to add data after all of the common dump data has been written. Signed-off-by: Janosch Frank --- dump/dump.c | 112 ++++++++++++++++++++++++++++++++---------- include/sysemu/dump.h | 4 ++ 2 files changed, 90 insertions(+), 26 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 8a7ce95610..a6bb7bfa21 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -342,30 +342,69 @@ static void write_elf_phdr_note(DumpState *s, Error *= *errp) } } =20 -static void write_elf_section(DumpState *s, int type, Error **errp) +static size_t prepare_elf_section_hdr_zero(DumpState *s) { - Elf32_Shdr shdr32; - Elf64_Shdr shdr64; - int shdr_size; - void *shdr; - int ret; + if (dump_is_64bit(s)) { + Elf64_Shdr *shdr64 =3D s->elf_section_hdrs; =20 - if (type =3D=3D 0) { - shdr_size =3D sizeof(Elf32_Shdr); - memset(&shdr32, 0, shdr_size); - shdr32.sh_info =3D cpu_to_dump32(s, s->phdr_num); - shdr =3D &shdr32; + shdr64->sh_info =3D cpu_to_dump32(s, s->phdr_num); } else { - shdr_size =3D sizeof(Elf64_Shdr); - memset(&shdr64, 0, shdr_size); - shdr64.sh_info =3D cpu_to_dump32(s, s->phdr_num); - shdr =3D &shdr64; + Elf32_Shdr *shdr32 =3D s->elf_section_hdrs; + + shdr32->sh_info =3D cpu_to_dump32(s, s->phdr_num); } =20 - ret =3D fd_write_vmcore(shdr, shdr_size, s); + return dump_is_64bit(s) ? sizeof(Elf64_Shdr) : sizeof(Elf32_Shdr); +} + +static void prepare_elf_section_hdrs(DumpState *s) +{ + size_t len, sizeof_shdr; + + /* + * Section ordering: + * - HDR zero (if needed) + */ + sizeof_shdr =3D dump_is_64bit(s) ? sizeof(Elf64_Shdr) : sizeof(Elf32_S= hdr); + len =3D sizeof_shdr * s->shdr_num; + s->elf_section_hdrs =3D g_malloc0(len); + + /* Write special section first */ + if (s->phdr_num =3D=3D PN_XNUM) { + prepare_elf_section_hdr_zero(s); + } +} + +static void prepare_elf_sections(DumpState *s, Error **errp) +{ + if (!s->shdr_num) { + return; + } + + prepare_elf_section_hdrs(s); +} + +static void write_elf_section_headers(DumpState *s, Error **errp) +{ + size_t sizeof_shdr; + int ret; + + sizeof_shdr =3D dump_is_64bit(s) ? sizeof(Elf64_Shdr) : sizeof(Elf32_S= hdr); + + ret =3D fd_write_vmcore(s->elf_section_hdrs, s->shdr_num * sizeof_shdr= , s); if (ret < 0) { - error_setg_errno(errp, -ret, - "dump: failed to write section header table"); + error_setg_errno(errp, -ret, "dump: failed to write section header= s"); + } +} + +static void write_elf_sections(DumpState *s, Error **errp) +{ + int ret; + + /* Write section zero */ + ret =3D fd_write_vmcore(s->elf_section_data, s->elf_section_data_size,= s); + if (ret < 0) { + error_setg_errno(errp, -ret, "dump: failed to write section data"); } } =20 @@ -557,12 +596,22 @@ static void dump_begin(DumpState *s, Error **errp) /* Write elf header to buffer */ prepare_elf_header(s); =20 + prepare_elf_sections(s, errp); + if (*errp) { + return; + } + /* Start to write stuff into file descriptor */ write_elf_header(s, errp); if (*errp) { return; } =20 + write_elf_section_headers(s, errp); + if (*errp) { + return; + } + /* write PT_NOTE to vmcore */ write_elf_phdr_note(s, errp); if (*errp) { @@ -575,14 +624,6 @@ static void dump_begin(DumpState *s, Error **errp) return; } =20 - /* write section to vmcore */ - if (s->shdr_num) { - write_elf_section(s, 1, errp); - if (*errp) { - return; - } - } - /* write notes to vmcore */ write_elf_notes(s, errp); } @@ -647,6 +688,19 @@ static void dump_iterate(DumpState *s, Error **errp) } } =20 +static void dump_end(DumpState *s, Error **errp) +{ + ERRP_GUARD(); + + if (!s->elf_section_data_size) { + return; + } + s->elf_section_data =3D g_malloc0(s->elf_section_data_size); + + /* write sections to vmcore */ + write_elf_sections(s, errp); +} + static void create_vmcore(DumpState *s, Error **errp) { ERRP_GUARD(); @@ -657,6 +711,12 @@ static void create_vmcore(DumpState *s, Error **errp) } =20 dump_iterate(s, errp); + if (*errp) { + return; + } + + /* Write section data after memory has been dumped */ + dump_end(s, errp); } =20 static int write_start_flat_header(int fd) diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 7f9a848573..686555f908 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -172,6 +172,10 @@ typedef struct DumpState { int64_t length; /* Length of the dump we want to dump */ =20 void *elf_header; + void *elf_section_hdrs; + uint64_t elf_section_data_size; + void *elf_section_data; + uint8_t *note_buf; /* buffer for notes */ size_t note_buf_offset; /* the writing place in note_buf */ uint32_t nr_cpus; /* number of guest's cpu */ --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658828170; cv=none; d=zohomail.com; s=zohoarc; b=lPckyAMu25QBlS2oijSlbFBI/fEFYC9HS6b5lJFvKpwN7WNNFpb5LNsJjY/AVTZQwzKMxrI7JhOF96V1fEn90WM881oMgizEluAxqhqJ6w/tXe8/E6EccyTNoCKxc6lYeEAsm4LcWNnhFEcqhNa6Zcqj/NCVCYoEI7GejOZT0oY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658828170; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=trS/a3KAWxcr4CmDh1TkEQrbv2SpbBZQyNfnbu2EFTE=; b=ecFL7IL/1hFn/PkKsgWPCA3RaYw8qoCZ5We9xqNachy2reZqKxWl4I7G1LzWS1u1yjQ5SABKVC1H2TRVQsTcOzgwN5OSulO/Grn/JpJ2W8baS6UyZFW5oB3/l2zPD2qGd8tMqM2KDBvpDGUebew9KmL2p5Niey29qJMOEi6rXrs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658828170413612.5074922405739; Tue, 26 Jul 2022 02:36:10 -0700 (PDT) Received: from localhost ([::1]:45966 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGz2-00021h-OL for importer@patchew.org; Tue, 26 Jul 2022 05:36:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn8-0004Lw-71; Tue, 26 Jul 2022 05:23:50 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:6462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn6-0005ZK-GY; Tue, 26 Jul 2022 05:23:49 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9HusX022681; Tue, 26 Jul 2022 09:23:46 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdgy8313-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:46 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9KcBJ007687; Tue, 26 Jul 2022 09:23:46 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdgy8306-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:45 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9L1Tb017876; Tue, 26 Jul 2022 09:23:43 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 3hh6euj8ja-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:43 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NsuX21496272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:54 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C0C3A405B; Tue, 26 Jul 2022 09:23:40 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A8FDA4054; Tue, 26 Jul 2022 09:23:39 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:39 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=trS/a3KAWxcr4CmDh1TkEQrbv2SpbBZQyNfnbu2EFTE=; b=R/pBL1Ltj7bIlVEQBSBZ/NIgpqP+ia/sfwR4CT1qIzDDyUGlK4Y7HNi4dLb3Gs89n7rZ ez42QzxD2Q41A74aOoQvHi5j2OZ30Og4468goaWG0NBpxHorotIcor9hFovaYI2h8qvH eGmyUtVshnamWG0GiN0PYUyZfdZ11Y1xbe+Ks2JTgwVJxdnywMX79J48CJ0kbfhvKcLS 2ZeeAczxRpYBpJZ7BtW/sdUGzwib1yszOwDff/ELCrzqJP1BssFMwI5fBt4QGZyNIufp DVTW6Qt8y983n8Squ+K+cqIWxnZh7fuOlzNX7i9tQ/wr3mbtQsvqzZxm/GrcaCxM3zKT 6A== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 09/17] dump: Reorder struct DumpState Date: Tue, 26 Jul 2022 09:22:40 +0000 Message-Id: <20220726092248.128336-10-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: KmzEcO7HXM68WBgtauqekSa-whbzDgZq X-Proofpoint-GUID: iM4xBoQOrSmuG2yOABUQsiCHqHOCOkz3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 mlxlogscore=940 spamscore=0 adultscore=0 priorityscore=1501 impostorscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658828172977100001 Let's move ELF related members into one block and guest memory related ones into another to improve readability. Signed-off-by: Janosch Frank Reviewed-by: Richard Henderson Reviewed-by: Marc-Andr=C3=A9 Lureau --- include/sysemu/dump.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 686555f908..3937afe0f9 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -154,15 +154,8 @@ typedef struct DumpState { GuestPhysBlockList guest_phys_blocks; ArchDumpInfo dump_info; MemoryMappingList list; - uint32_t phdr_num; - uint32_t shdr_num; bool resume; bool detached; - ssize_t note_size; - hwaddr shdr_offset; - hwaddr phdr_offset; - hwaddr section_offset; - hwaddr note_offset; hwaddr memory_offset; int fd; =20 @@ -171,6 +164,15 @@ typedef struct DumpState { int64_t begin; /* Start address of the chunk we want to du= mp */ int64_t length; /* Length of the dump we want to dump */ =20 + /* Elf dump related data */ + uint32_t phdr_num; + uint32_t shdr_num; + uint32_t sh_info; + ssize_t note_size; + hwaddr shdr_offset; + hwaddr phdr_offset; + hwaddr note_offset; + void *elf_header; void *elf_section_hdrs; uint64_t elf_section_data_size; --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658828454; cv=none; d=zohomail.com; s=zohoarc; b=MGPMSAjkn4HzzSn1/1cCC7TxI4dZMkSqqYOnCOR9Cc0b/7aBh+ukr8FV1HQaH6DnAvINxecN/Zgb/TPakVGupwZDzC7edDHlTd1xQhKTSSk5qP8iz6RON+lcpp1fKI2ArBUjU5fgM93q83XXN5tNsniVVMSQQW5lKr46LDzoSrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658828454; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1NwRgihiRrIpxJ8jBCRc20a5b2DsmxGeplnbjIIPNf4=; b=JpdF2q/FhohcYXKWaoNB5Q0ZlR4VfmaifyR27AiS1Ha/oTt0r1Ec1sZHk/dVaauDs91orb+/cvLeFuslo6LbI9WOZMguq9xdeFgfbSjP7Ndq1eWwd0v+WrXeOyJjopIgchiDhnErr5ZLjlPIWLH5TrDZRaItj3NzuzE9zDlhKIE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658828454584484.68660962734475; Tue, 26 Jul 2022 02:40:54 -0700 (PDT) Received: from localhost ([::1]:53618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGH3d-0006oS-FZ for importer@patchew.org; Tue, 26 Jul 2022 05:40:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn9-0004RU-B5; Tue, 26 Jul 2022 05:23:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:20634) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn7-0005ZY-HT; Tue, 26 Jul 2022 05:23:51 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q8rQao003152; Tue, 26 Jul 2022 09:23:48 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtme-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:47 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q8t2ev007553; Tue, 26 Jul 2022 09:23:47 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtke-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:47 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9Lsgl008172; Tue, 26 Jul 2022 09:23:44 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06ams.nl.ibm.com with ESMTP id 3hg97tbjff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:44 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9LhUG23920982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:21:43 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E3D7FA405B; Tue, 26 Jul 2022 09:23:41 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C2641A4054; Tue, 26 Jul 2022 09:23:40 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:40 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=1NwRgihiRrIpxJ8jBCRc20a5b2DsmxGeplnbjIIPNf4=; b=A8AjxOUGOzYTX0Ibbt6X4qdHsNezKH/n5LWv6D9DXU9IbdRYFFt6Td9ZzisLcDJza0Ay Dkchxdpjzflewh8gFk7F8EXOo/mjJRPtpBLTDGvjl58TXOilsPkB+hcQpQ6MIIX5pcKx JuaB8SjwB9SqUK7emiohjG8LDqL6a1t2v5SeJ5cY9TmG+kwwRNfRK5ljy0JSA0VE0Q/q ma8/Ct6TTc2s2bF4oD5AXPW5MbXEcBj+OF2rBL0/u+ubwSliBXrda1AsTikxOKkyuHK4 vRd73tCAxKZhPdAvmYMoPuPqEQ33/GUDrG1WEwCvP2uKtzWSKavkcMdjqhekqo88vyi6 Rg== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 10/17] dump: Swap segment and section header locations Date: Tue, 26 Jul 2022 09:22:41 +0000 Message-Id: <20220726092248.128336-11-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: dQZxqR_Anh1f1lOMwg22QNvfe6TJuTMH X-Proofpoint-ORIG-GUID: CraD5GXH0PssiNB3L6FfYiibOjyVOP7W X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658828456514100001 Content-Type: text/plain; charset="utf-8" For the upcoming string table and arch section support we need to modify the elf layout a bit. Instead of the segments, i.e. the guest's memory contents, beeing the last area the section data will live at the end of the file. This will allow us to write the section data after all guest memory has been dumped which is important for the s390 PV dump support. Signed-off-by: Janosch Frank Reviewed-by: Marc-Andr=C3=A9 Lureau --- dump/dump.c | 21 ++++++++++++--------- include/sysemu/dump.h | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index a6bb7bfa21..3cf846d0a0 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -588,6 +588,9 @@ static void dump_begin(DumpState *s, Error **errp) * -------------- * | memory | * -------------- + * | sectn data | + * -------------- + * * we only know where the memory is saved after we write elf note into * vmcore. @@ -1852,18 +1855,18 @@ static void dump_init(DumpState *s, int fd, bool ha= s_format, } } =20 + tmp =3D (s->phdr_num =3D=3D PN_XNUM) ? s->sh_info : s->phdr_num; if (dump_is_64bit(s)) { - s->phdr_offset =3D sizeof(Elf64_Ehdr); - s->shdr_offset =3D s->phdr_offset + sizeof(Elf64_Phdr) * s->phdr_n= um; - s->note_offset =3D s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_n= um; - s->memory_offset =3D s->note_offset + s->note_size; + s->shdr_offset =3D sizeof(Elf64_Ehdr); + s->phdr_offset =3D s->shdr_offset + sizeof(Elf64_Shdr) * s->shdr_n= um; + s->note_offset =3D s->phdr_offset + sizeof(Elf64_Phdr) * tmp; } else { - - s->phdr_offset =3D sizeof(Elf32_Ehdr); - s->shdr_offset =3D s->phdr_offset + sizeof(Elf32_Phdr) * s->phdr_n= um; - s->note_offset =3D s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_n= um; - s->memory_offset =3D s->note_offset + s->note_size; + s->shdr_offset =3D sizeof(Elf32_Ehdr); + s->phdr_offset =3D s->shdr_offset + sizeof(Elf32_Shdr) * s->shdr_n= um; + s->note_offset =3D s->phdr_offset + sizeof(Elf32_Phdr) * tmp; } + s->memory_offset =3D s->note_offset + s->note_size; + s->section_offset =3D s->memory_offset + s->total_size; =20 return; =20 diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 3937afe0f9..696e6c67d6 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -172,6 +172,7 @@ typedef struct DumpState { hwaddr shdr_offset; hwaddr phdr_offset; hwaddr note_offset; + hwaddr section_offset; =20 void *elf_header; void *elf_section_hdrs; --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658828457; cv=none; d=zohomail.com; s=zohoarc; b=U7SGKg54u6JUKToacB/oxUAu8+GWSPG4OoxDZux/00qWjAJi0e3TwuZW8Kgo6y7djEF/FI2DGtQ24s/R9tO0Bqm9Vj9AZZmUuyNSbvNDgc3Odh33sdWj93Vysq/l5LeqZlDWhD8oVTvLNeBh+HHJnFbhSGXKjixNI0DEq3rXw5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658828457; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TWNFPLetfuYq3GnO6Ykr6Rxzu2X2prDjwxYveKUbppU=; b=MNzogl2+/h3x8L0yLP278BmNKPquWC0avxQui4e+Fe4NJajTOvS0LX6ZeH4CLDSBBRSQbs3N60AtKCm5g2QF9Oh/D9iT4q5Txax0XCtLpq//w2QjwfKysOdrFj+esXqN3IUp+e0NNg/E2d5DSx7S9MVVjJ0VJTD4juH+TGUHBL4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165882845747465.16992985953925; Tue, 26 Jul 2022 02:40:57 -0700 (PDT) Received: from localhost ([::1]:53768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGH3f-0006t2-Fd for importer@patchew.org; Tue, 26 Jul 2022 05:40:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn9-0004Td-Tr; Tue, 26 Jul 2022 05:23:51 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:61786) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn8-0005Zl-2j; Tue, 26 Jul 2022 05:23:51 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9LY9S006820; Tue, 26 Jul 2022 09:23:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjpr1ub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:48 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9NVGs018418; Tue, 26 Jul 2022 09:23:48 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdjpr1th-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:48 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LFjr026308; Tue, 26 Jul 2022 09:23:46 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 3hg96wkjtc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:46 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NhP414680358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:43 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 372B9A405C; Tue, 26 Jul 2022 09:23:43 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1652BA4054; Tue, 26 Jul 2022 09:23:42 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:41 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=TWNFPLetfuYq3GnO6Ykr6Rxzu2X2prDjwxYveKUbppU=; b=jDTKvBBv82VlbKrIelXb7ixznDpeiJLmMxncqgqaVAij9moTbeIfLqFe3fckRbgKjrz+ 4VQ9V3o4j68PqNc+tOl5XwQtW5HNqeuwwBABi195iZGYTq6gmqOYUp5DqF9xYCbyOrDB wwRvhQuTrT1pUKysEge2nVlHVpYMOZ71tCGXZcpj9lP32KHVKUmoQLZ4HVs92XWLvH0V Tv7K97izwStgo3TnnSYBmGBqEg8q+OgPtdxI15kPYyqsQDOW+TkGp2gKrB9i9+ZvQSEs DfV8RLb+g4PdOYQXXXzAaB6um7ABSUiNB1w6zG4nCLw3J6DqejPrJ7eN+Ps0nTzKbnBV ag== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 11/17] dump/dump: Add section string table support Date: Tue, 26 Jul 2022 09:22:42 +0000 Message-Id: <20220726092248.128336-12-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sTbdFMMNiC8Bz5D8TZ7i8wSuUE8F4zKA X-Proofpoint-ORIG-GUID: YNY3w9clBnBlX52cFIDYdd_W4SLLMdyl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 adultscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 phishscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658828458461100003 Content-Type: text/plain; charset="utf-8" As sections don't have a type like the notes do we need another way to determine their contents. The string table allows us to assign each section an identification string which architectures can then use to tag their sections with. There will be no string table if the architecture doesn't add custom sections which are introduced in a following patch. Signed-off-by: Janosch Frank --- dump/dump.c | 81 ++++++++++++++++++++++++++++++++++++++++++- include/sysemu/dump.h | 1 + 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/dump/dump.c b/dump/dump.c index 3cf846d0a0..298a1e923f 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -99,6 +99,7 @@ static int dump_cleanup(DumpState *s) close(s->fd); g_free(s->guest_note); g_free(s->elf_header); + g_array_unref(s->string_table_buf); s->guest_note =3D NULL; if (s->resume) { if (s->detached) { @@ -357,21 +358,72 @@ static size_t prepare_elf_section_hdr_zero(DumpState = *s) return dump_is_64bit(s) ? sizeof(Elf64_Shdr) : sizeof(Elf32_Shdr); } =20 +static void write_elf_section_hdr_string(DumpState *s, void *buff) +{ + Elf32_Shdr shdr32; + Elf64_Shdr shdr64; + int shdr_size; + void *shdr =3D buff; + + if (dump_is_64bit(s)) { + shdr_size =3D sizeof(Elf64_Shdr); + memset(&shdr64, 0, shdr_size); + shdr64.sh_type =3D SHT_STRTAB; + shdr64.sh_offset =3D s->section_offset + s->elf_section_data_size; + shdr64.sh_name =3D s->string_table_buf->len; + g_array_append_vals(s->string_table_buf, ".strtab", sizeof(".strta= b")); + shdr64.sh_size =3D s->string_table_buf->len; + shdr =3D &shdr64; + } else { + shdr_size =3D sizeof(Elf32_Shdr); + memset(&shdr32, 0, shdr_size); + shdr32.sh_type =3D SHT_STRTAB; + shdr32.sh_offset =3D s->section_offset + s->elf_section_data_size; + shdr32.sh_name =3D s->string_table_buf->len; + g_array_append_vals(s->string_table_buf, ".strtab", sizeof(".strta= b")); + shdr32.sh_size =3D s->string_table_buf->len; + shdr =3D &shdr32; + } + + memcpy(buff, shdr, shdr_size); +} + static void prepare_elf_section_hdrs(DumpState *s) { size_t len, sizeof_shdr; + Elf64_Ehdr *hdr64 =3D s->elf_header; + Elf32_Ehdr *hdr32 =3D s->elf_header; + void *buff_hdr; =20 /* * Section ordering: * - HDR zero (if needed) + * - String table hdr */ sizeof_shdr =3D dump_is_64bit(s) ? sizeof(Elf64_Shdr) : sizeof(Elf32_S= hdr); len =3D sizeof_shdr * s->shdr_num; s->elf_section_hdrs =3D g_malloc0(len); + buff_hdr =3D s->elf_section_hdrs; =20 /* Write special section first */ if (s->phdr_num =3D=3D PN_XNUM) { prepare_elf_section_hdr_zero(s); + buff_hdr +=3D sizeof_shdr; + } + + if (s->shdr_num < 2) { + return; + } + + /* + * String table needs to be last section since strings are added + * via arch_sections_write_hdr(). + */ + write_elf_section_hdr_string(s, buff_hdr); + if (dump_is_64bit(s)) { + hdr64->e_shstrndx =3D cpu_to_dump16(s, s->shdr_num - 1); + } else { + hdr32->e_shstrndx =3D cpu_to_dump16(s, s->shdr_num - 1); } } =20 @@ -401,11 +453,18 @@ static void write_elf_sections(DumpState *s, Error **= errp) { int ret; =20 - /* Write section zero */ + /* Write section zero and arch sections */ ret =3D fd_write_vmcore(s->elf_section_data, s->elf_section_data_size,= s); if (ret < 0) { error_setg_errno(errp, -ret, "dump: failed to write section data"); } + + /* Write string table data */ + ret =3D fd_write_vmcore(s->string_table_buf->data, + s->string_table_buf->len, s); + if (ret < 0) { + error_setg_errno(errp, -ret, "dump: failed to write string table d= ata"); + } } =20 static void write_data(DumpState *s, void *buf, int length, Error **errp) @@ -713,6 +772,7 @@ static void create_vmcore(DumpState *s, Error **errp) return; } =20 + /* Iterate over memory and dump it to file */ dump_iterate(s, errp); if (*errp) { return; @@ -1695,6 +1755,13 @@ static void dump_init(DumpState *s, int fd, bool has= _format, s->has_filter =3D has_filter; s->begin =3D begin; s->length =3D length; + /* First index is 0, it's the special null name */ + s->string_table_buf =3D g_array_new(FALSE, TRUE, 1); + /* + * Allocate the null name, due to the clearing option set to true + * it will be 0. + */ + g_array_set_size(s->string_table_buf, 1); =20 memory_mapping_list_init(&s->list); =20 @@ -1855,6 +1922,18 @@ static void dump_init(DumpState *s, int fd, bool has= _format, } } =20 + /* + * calculate shdr_num and elf_section_data_size so we know the offsets= and + * sizes of all parts. + * + * If phdr_num overflowed we have at least one section header + * More sections/hdrs can be added by the architectures + */ + if (s->shdr_num > 1) { + /* Reserve the string table */ + s->shdr_num +=3D 1; + } + tmp =3D (s->phdr_num =3D=3D PN_XNUM) ? s->sh_info : s->phdr_num; if (dump_is_64bit(s)) { s->shdr_offset =3D sizeof(Elf64_Ehdr); diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h index 696e6c67d6..299b611180 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -178,6 +178,7 @@ typedef struct DumpState { void *elf_section_hdrs; uint64_t elf_section_data_size; void *elf_section_data; + GArray *string_table_buf; /* String table section */ =20 uint8_t *note_buf; /* buffer for notes */ size_t note_buf_offset; /* the writing place in note_buf */ --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658827925; cv=none; d=zohomail.com; s=zohoarc; b=PQSFz3X7XnK+TcxasXdWr84BHvCkOI66+c+2O9gDv2zAXjXE4jMse3nnrG1Cesyi1bpzGwaOKU1EUWtXVtMId9SRzKNQjpPnv1WaJqVMFtLw1/zCEaBhRhsYCV7iFrSjsY57JsWlmaml/1tZfbaDx7BY2vuireiyzITv8RivKfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658827925; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YroEPA103CzfLnh/CyxoFyuCR9QSgCts5cjw8qccYrg=; b=MXTU9WeiH7RpfYb8TNYzS1KHlMIlZ+vLNn7lYc7YG7SE+0Cii2s6p2jEFfjN96wkN/kBwUpGe4ZP6VyyhCuuhk32QivYcxgVyY11S/s5hQM4iOu/6UhZtGsIqeNt2bDJh4VT+8OIvN5BZhoQFRMW6baqfT0CQfeNaiatVwj0kOo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658827925783651.3285561874324; Tue, 26 Jul 2022 02:32:05 -0700 (PDT) Received: from localhost ([::1]:38160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGGv5-000520-FE for importer@patchew.org; Tue, 26 Jul 2022 05:32:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnA-0004VA-Mq; Tue, 26 Jul 2022 05:23:53 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53354 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGn8-0005Zy-WC; Tue, 26 Jul 2022 05:23:52 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9DxoO030689; Tue, 26 Jul 2022 09:23:50 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdeu084j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:49 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9GgnM008059; Tue, 26 Jul 2022 09:23:49 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdeu0840-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:49 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LCKk017902; Tue, 26 Jul 2022 09:23:47 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma03ams.nl.ibm.com with ESMTP id 3hh6euj8jd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:47 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9Nitu23789950 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:44 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E454A405B; Tue, 26 Jul 2022 09:23:44 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DDA6A4054; Tue, 26 Jul 2022 09:23:43 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:43 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=YroEPA103CzfLnh/CyxoFyuCR9QSgCts5cjw8qccYrg=; b=VWOUu1CAq7u6S7+9wtSYTBEgm89xopBfcQz2QLjFCjOFwygpQ6YZT79wT17C99hRvXvE FAWW+ewTlKjFGquhI1Qn4GFIxZB5BRDz+KlGTf2Zb3lfyw/LkczGZqe7I4nuNfubCfhb Of9hC46YO8E6t7iXqwB9V06ceuZrgPkPc79YyzyX6hihAnHk1GcgnAcX5tbQiTrnY2SC Jr+sjHyKGK3PUktG5X++3PfQceeTw9ZmGeoCIpf5d5QmDtatUln36GKj3mIg4cUI2pMJ qtOgZABJnqvAb2Imw5Teg2ZHkok44kUQabJEW9s20Wpalo28ebDgkzn2NatuY2keCRCn mA== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 12/17] dump/dump: Add arch section support Date: Tue, 26 Jul 2022 09:22:43 +0000 Message-Id: <20220726092248.128336-13-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: NJMV-ZSE3VHVDtCfTwhN96A4YrufR6YA X-Proofpoint-ORIG-GUID: DETu_E2shV-6ze4Tmnr-g0xm72htnQe6 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658827928143100001 Content-Type: text/plain; charset="utf-8" Add hooks which architectures can use to add arbitrary data to custom sections. Signed-off-by: Janosch Frank --- dump/dump.c | 5 +++++ include/sysemu/dump-arch.h | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/dump/dump.c b/dump/dump.c index 298a1e923f..1ec4c3b6c3 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -398,6 +398,7 @@ static void prepare_elf_section_hdrs(DumpState *s) /* * Section ordering: * - HDR zero (if needed) + * - Arch section hdrs * - String table hdr */ sizeof_shdr =3D dump_is_64bit(s) ? sizeof(Elf64_Shdr) : sizeof(Elf32_S= hdr); @@ -415,6 +416,8 @@ static void prepare_elf_section_hdrs(DumpState *s) return; } =20 + buff_hdr +=3D dump_arch_sections_write_hdr(&s->dump_info, s, buff_hdr); + /* * String table needs to be last section since strings are added * via arch_sections_write_hdr(). @@ -758,6 +761,7 @@ static void dump_end(DumpState *s, Error **errp) return; } s->elf_section_data =3D g_malloc0(s->elf_section_data_size); + dump_arch_sections_write(&s->dump_info, s, s->elf_section_data); =20 /* write sections to vmcore */ write_elf_sections(s, errp); @@ -1929,6 +1933,7 @@ static void dump_init(DumpState *s, int fd, bool has_= format, * If phdr_num overflowed we have at least one section header * More sections/hdrs can be added by the architectures */ + dump_arch_sections_add(&s->dump_info, (void *)s); if (s->shdr_num > 1) { /* Reserve the string table */ s->shdr_num +=3D 1; diff --git a/include/sysemu/dump-arch.h b/include/sysemu/dump-arch.h index e25b02e990..de77908424 100644 --- a/include/sysemu/dump-arch.h +++ b/include/sysemu/dump-arch.h @@ -21,6 +21,9 @@ typedef struct ArchDumpInfo { uint32_t page_size; /* The target's page size. If it's variable a= nd * unknown, then this should be the maximum. = */ uint64_t phys_base; /* The target's physmem base. */ + void (*arch_sections_add_fn)(void *opaque); + uint64_t (*arch_sections_write_hdr_fn)(void *opaque, uint8_t *buff); + void (*arch_sections_write_fn)(void *opaque, uint8_t *buff); } ArchDumpInfo; =20 struct GuestPhysBlockList; /* memory_mapping.h */ @@ -28,4 +31,28 @@ int cpu_get_dump_info(ArchDumpInfo *info, const struct GuestPhysBlockList *guest_phys_blocks); ssize_t cpu_get_note_size(int class, int machine, int nr_cpus); =20 +static inline void dump_arch_sections_add(ArchDumpInfo *info, void *opaque) +{ + if (info->arch_sections_add_fn) { + info->arch_sections_add_fn(opaque); + } +} + +static inline uint64_t dump_arch_sections_write_hdr(ArchDumpInfo *info, + void *opaque, uint8_t *buf= f) +{ + if (info->arch_sections_write_hdr_fn) { + return info->arch_sections_write_hdr_fn(opaque, buff); + } + return 0; +} + +static inline void dump_arch_sections_write(ArchDumpInfo *info, void *opaq= ue, + uint8_t *buff) +{ + if (info->arch_sections_write_fn) { + info->arch_sections_write_fn(opaque, buff); + } +} + #endif --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658828764; cv=none; d=zohomail.com; s=zohoarc; b=aAfiOkimpm6lFZ8oz3HFKeaYt+m5auFf7h+RdlXRz1Jcd4WT27wBhmlikxic3Y3t/nHg4KD3e9fTDVdYj6F3GTfGgQDyYt3n0Gs2vjtHSIAFRyNlW/wDvMbFYJKQ/91VeOK0SmA+10aNX3a7BzwsMKd5/5dIGWnpwthIwAqTpnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658828764; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BCKxo5hnXlHgHs8RuTNPsMcXA2toIdRtPsp7HWvCtHE=; b=QLFhsGNqTrWFS53rMpZB7Aw7x+IzP5U/JmJFTTWOfWwMIDH2lXsQ9KeGhb3CiPbrL/7rNQdbMVa/4viuPX+MLiXo+8meCo9TccyqjZXa8YdqxmJXRJ59USru+WtEoND+Vep3LWHWBIOGne4C+bTyeZZMc2Fg/YR7kx6YUjGAjiE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658828764544159.12674922774693; Tue, 26 Jul 2022 02:46:04 -0700 (PDT) Received: from localhost ([::1]:35240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGH8c-0004n6-Ds for importer@patchew.org; Tue, 26 Jul 2022 05:46:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnE-0004cK-Sy; Tue, 26 Jul 2022 05:23:56 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:7070) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnB-0005aR-Pv; Tue, 26 Jul 2022 05:23:55 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q8rYbF003412; Tue, 26 Jul 2022 09:23:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtp7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:51 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q90JdX028958; Tue, 26 Jul 2022 09:23:51 GMT Received: from ppma05fra.de.ibm.com (6c.4a.5195.ip4.static.sl-reverse.com [149.81.74.108]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtnb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:51 +0000 Received: from pps.filterd (ppma05fra.de.ibm.com [127.0.0.1]) by ppma05fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9KBbD005626; Tue, 26 Jul 2022 09:23:49 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma05fra.de.ibm.com with ESMTP id 3hg94eap65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:48 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NjpT19530124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:45 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C545BA405B; Tue, 26 Jul 2022 09:23:45 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4D66A4054; Tue, 26 Jul 2022 09:23:44 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:44 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=BCKxo5hnXlHgHs8RuTNPsMcXA2toIdRtPsp7HWvCtHE=; b=m2kJDLhHOnk7iduBgPNsFBV0ccGuVuV6wggXQp0lkKi/eArOI1mZff71qnwpOQpH0ZcP +PO5PXZU9Ur+jZwT9xsCdCRUoNTTE27RbctLtyiiSnYbP1w+GvX1HPpSdlXOz4+iR1dE KLm3IRQ1SPYDT6kA7IzDIVDWdcEnL0UsN7wNYeGMZ3lUZXW+QPrVFvYryYnsDw2z8GxY Q/RaHc1yKxCqJKyGIHrHSnKAvP38glHiJpPe7m4+3znSflMkgwldeh648jSiPJdHT47a 1nOULXt2YfWZjlzcDGSNqfGpJDhwTK/IuI8ibxmESFHI1zQ9zDWiJzaHZMSkV9rAF/Nx Cw== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 13/17] linux header sync Date: Tue, 26 Jul 2022 09:22:44 +0000 Message-Id: <20220726092248.128336-14-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: aqmL1jaCdAIg8cuRTCFkcz94MuJGoiLG X-Proofpoint-ORIG-GUID: vtuHtRMx_iRp4NEHuNHtLbNN5m_tvKFz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658828766044100001 Content-Type: text/plain; charset="utf-8" Add the uapi data for KVM_CAP_S390_PROTECTED_DUMP which I expect to be added with 5.20. Also add the missing NT_S390_RI_CB and the new NT_S390_PV_CPU_DATA elf note types. Signed-off-by: Janosch Frank --- include/elf.h | 2 ++ linux-headers/linux/kvm.h | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/include/elf.h b/include/elf.h index 3a4bcb646a..94fdcfd8dc 100644 --- a/include/elf.h +++ b/include/elf.h @@ -1649,6 +1649,8 @@ typedef struct elf64_shdr { #define NT_TASKSTRUCT 4 #define NT_AUXV 6 #define NT_PRXFPREG 0x46e62b7f /* copied from gdb5.1/include/elf/= common.h */ +#define NT_S390_PV_CPU_DATA 0x30e /* s390 protvirt cpu dump data */ +#define NT_S390_RI_CB 0x30d /* s390 runtime instrumentation */ #define NT_S390_GS_CB 0x30b /* s390 guarded storage registers = */ #define NT_S390_VXRS_HIGH 0x30a /* s390 vector registers 16-31 */ #define NT_S390_VXRS_LOW 0x309 /* s390 vector registers 0-15 (low= er half) */ diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index f089349149..46133ef36c 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1150,6 +1150,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_DISABLE_QUIRKS2 213 /* #define KVM_CAP_VM_TSC_CONTROL 214 */ #define KVM_CAP_SYSTEM_EVENT_DATA 215 +#define KVM_CAP_S390_PROTECTED_DUMP 217 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 @@ -1651,6 +1652,55 @@ struct kvm_s390_pv_unp { __u64 tweak; }; =20 +enum pv_cmd_info_id { + KVM_PV_INFO_VM, + KVM_PV_INFO_DUMP, +}; + +struct kvm_s390_pv_info_dump { + __u64 dump_cpu_buffer_len; + __u64 dump_config_mem_buffer_per_1m; + __u64 dump_config_finalize_len; +}; + +struct kvm_s390_pv_info_vm { + __u64 inst_calls_list[4]; + __u64 max_cpus; + __u64 max_guests; + __u64 max_guest_addr; + __u64 feature_indication; +}; + +struct kvm_s390_pv_info_header { + __u32 id; + __u32 len_max; + __u32 len_written; + __u32 reserved; +}; + +struct kvm_s390_pv_info { + struct kvm_s390_pv_info_header header; + union { + struct kvm_s390_pv_info_dump dump; + struct kvm_s390_pv_info_vm vm; + }; +}; + +enum pv_cmd_dmp_id { + KVM_PV_DUMP_INIT, + KVM_PV_DUMP_CONFIG_STATE, + KVM_PV_DUMP_COMPLETE, + KVM_PV_DUMP_CPU, +}; + +struct kvm_s390_pv_dmp { + __u64 subcmd; + __u64 buff_addr; + __u64 buff_len; + __u64 gaddr; + __u64 reserved[4]; +}; + enum pv_cmd_id { KVM_PV_ENABLE, KVM_PV_DISABLE, @@ -1659,6 +1709,8 @@ enum pv_cmd_id { KVM_PV_VERIFY, KVM_PV_PREP_RESET, KVM_PV_UNSHARE_ALL, + KVM_PV_INFO, + KVM_PV_DUMP, }; =20 struct kvm_pv_cmd { @@ -2067,4 +2119,6 @@ struct kvm_stats_desc { /* Available with KVM_CAP_XSAVE2 */ #define KVM_GET_XSAVE2 _IOR(KVMIO, 0xcf, struct kvm_xsave) =20 +#define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd) + #endif /* __LINUX_KVM_H */ --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658829094; cv=none; d=zohomail.com; s=zohoarc; b=gd0M7A2Z8Hft7c7lH5rtmKoyvtabLzEjVnt3QVtVCbKJtYfSaCjbLtjFRxoZhdiT6PBO/7aYyFxl8MEwlI7Dve5JW+piTlZIOuwsCIHjGkjrVG6tXeWM30nhtWb1pUwZuZC0F8boBHUqyWyzeSN/of2RQgz4lj8ZA+26yw9sZrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658829094; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R5c3v2RJVn4rfCJmoch98x9HsH4lVw2dJ8P/rzUPYzg=; b=KzqxkNYLZSReeK95ZEfFJYkhFgUQJqKJG64tx9PQz5lXkHs9kOrUtyiWrrzmufncafUf0pU4/OZBe0/MnEF0AuoKtzrKUEMK3zrPT1IXbeu+/zrBZY6xRrbCe+r6bBe8UET6JCksHqcJcjuUg2Y7EQaQm3haTGeVhTIB/gve2Zw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658829094767597.4290985732515; Tue, 26 Jul 2022 02:51:34 -0700 (PDT) Received: from localhost ([::1]:43542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGHDv-00029C-NZ for importer@patchew.org; Tue, 26 Jul 2022 05:51:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnG-0004em-Kl; Tue, 26 Jul 2022 05:23:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45428) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnD-0005ad-9S; Tue, 26 Jul 2022 05:23:57 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q8rWPo003347; Tue, 26 Jul 2022 09:23:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtq3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:53 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q8sKba005465; Tue, 26 Jul 2022 09:23:53 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtnv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:53 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LPYE008707; Tue, 26 Jul 2022 09:23:50 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04fra.de.ibm.com with ESMTP id 3hg945jnx8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:50 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9O01m16515444 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:24:00 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 182EEA405F; Tue, 26 Jul 2022 09:23:47 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EBF1AA4054; Tue, 26 Jul 2022 09:23:45 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=R5c3v2RJVn4rfCJmoch98x9HsH4lVw2dJ8P/rzUPYzg=; b=cRLn3F+z0uVSW9TRcb7oDbv0dxCCBncr/xb4Roy8UKS3e56oFDmV2v/wVhcgBsXoT+C8 0ho8wgYsFUG4jtchpFm4QMVyZMs5Hh8t38aJUf6+w5/oKSks4RInUDGt/9aDehRZK0Z8 M5NVdmu6qWD8sxIxxil1LuFy+x8c1pPP/wvvgODTQoMAfi2ARXQ1W9PDwD4mUDn8fhKo eHj4EtxLTG14v86YMtlX322NmU+PS65//PLkjMciBfyMa2q9BCfLKt6rbyBUtfwLAgnW t5XE5K4b9xFKYuABbs9V4a80Ttfw2aj9MRzsX5cp+v+vfmX8ovfIdoDrZm+ln2tgTnk7 uQ== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 14/17] s390x: Add protected dump cap Date: Tue, 26 Jul 2022 09:22:45 +0000 Message-Id: <20220726092248.128336-15-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ixfleIMDQZbRreSHb8quaMk2G-_ccpHp X-Proofpoint-ORIG-GUID: pF9EzKi8zRiaMnrRIGvhqk7ncBUsFNK_ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=951 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658829095866100003 Content-Type: text/plain; charset="utf-8" Add a protected dump capability for later feature checking. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden --- target/s390x/kvm/kvm.c | 7 +++++++ target/s390x/kvm/kvm_s390x.h | 1 + 2 files changed, 8 insertions(+) diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c index 7bd8db0e7b..cbd8c91424 100644 --- a/target/s390x/kvm/kvm.c +++ b/target/s390x/kvm/kvm.c @@ -157,6 +157,7 @@ static int cap_ri; static int cap_hpage_1m; static int cap_vcpu_resets; static int cap_protected; +static int cap_protected_dump; =20 static bool mem_op_storage_key_support; =20 @@ -362,6 +363,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) cap_s390_irq =3D kvm_check_extension(s, KVM_CAP_S390_INJECT_IRQ); cap_vcpu_resets =3D kvm_check_extension(s, KVM_CAP_S390_VCPU_RESETS); cap_protected =3D kvm_check_extension(s, KVM_CAP_S390_PROTECTED); + cap_protected_dump =3D kvm_check_extension(s, KVM_CAP_S390_PROTECTED_D= UMP); =20 kvm_vm_enable_cap(s, KVM_CAP_S390_USER_SIGP, 0); kvm_vm_enable_cap(s, KVM_CAP_S390_VECTOR_REGISTERS, 0); @@ -2043,6 +2045,11 @@ int kvm_s390_assign_subch_ioeventfd(EventNotifier *n= otifier, uint32_t sch, return kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &kick); } =20 +int kvm_s390_get_protected_dump(void) +{ + return cap_protected_dump; +} + int kvm_s390_get_ri(void) { return cap_ri; diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h index 05a5e1e6f4..31a69f9ce2 100644 --- a/target/s390x/kvm/kvm_s390x.h +++ b/target/s390x/kvm/kvm_s390x.h @@ -26,6 +26,7 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_stat= e); void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu); int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu); int kvm_s390_get_hpage_1m(void); +int kvm_s390_get_protected_dump(void); int kvm_s390_get_ri(void); int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_clock); int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_clock); --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658829091; cv=none; d=zohomail.com; s=zohoarc; b=n/fBXx8eR14eDUjjMt6bYbFCorctVFhu4Pm7zjNhwIMYAbzCPdMN0+wgOC0UxFVkt8dOzeMppQ4IhBmqxDOXqwYQrgFBlc9uN6FhMKMtu90YG/5GeUTFnESvINNq2+RRuFyQBoZE1Jz+hdA6XSw9mk/Zk6sFPmmmd6vfqe2IURA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658829091; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Wdl4zS4hysNj369RRNzLJHqpabTYSi6ScKcIrvvK+es=; b=mcuALhwgm3oLNR7cSQ7yQ8eqzSEyMsL5C7ralYTEsXpObi9zqe7ivTN0N5m7tLYVvWyLsMjFScL86I/qHVapmYS8vmtokDR/A1ZJ4Qy8nl6viyv0HVfqWYwZh9gBH8s/hn6Uo2La8HKyxrHYoIvKF9Hb/l4Z03Fk+Pmps9Z729g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658829091713809.6052944794142; Tue, 26 Jul 2022 02:51:31 -0700 (PDT) Received: from localhost ([::1]:43474 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGHDt-00026a-Fh for importer@patchew.org; Tue, 26 Jul 2022 05:51:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnH-0004fV-IM; Tue, 26 Jul 2022 05:24:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:23226) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnE-0005am-Rt; Tue, 26 Jul 2022 05:23:59 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q8rQar003152; Tue, 26 Jul 2022 09:23:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtqm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:54 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9Awem039096; Tue, 26 Jul 2022 09:23:54 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtp9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:53 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9JrUe023967; Tue, 26 Jul 2022 09:23:51 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03fra.de.ibm.com with ESMTP id 3hg95yanxm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:51 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9LoKm19726664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:21:50 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5FDEFA4054; Tue, 26 Jul 2022 09:23:48 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3ECA2A405B; Tue, 26 Jul 2022 09:23:47 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:47 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Wdl4zS4hysNj369RRNzLJHqpabTYSi6ScKcIrvvK+es=; b=AMh3LhAnUBNPhmBPmTXlAB59Nzjew1g8L6TiuM1vELDICYqGgID5yZMEPXFCrm3+PZrs p3/wd9sth9HcxhQnqfdxEwe41TYgoeuEPBU22KySu7VgS38kqkzXM15AoVjf0APHjEwN 0VzJOhSTFFNm7nrR6lkyrl/rZyahgopIfKQGozS5OlKgWLoYa8OTerEpCnVMDadD5U7i 2DioHy7ubcgXqG5T1W6wto+Yyr2HwCD7ZAz/2IholeKxH1maGP5gw2oxOdvhGBAARq9I m7ieHbPOEGmPllRELLq7tf64WGG2ST/u2eEDgkiozCeCcwkhopaue1OeYLPqEmQNFkP/ Ew== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 15/17] s390x: Introduce PV query interface Date: Tue, 26 Jul 2022 09:22:46 +0000 Message-Id: <20220726092248.128336-16-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: yeF8sS8fUMozVO_VOTvXo8-alQcKTNPf X-Proofpoint-ORIG-GUID: njjEYiwc3M6NUTBRV4grvYxUSQoyYRv8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658829094140100001 Content-Type: text/plain; charset="utf-8" Introduce an interface over which we can get information about UV data. Signed-off-by: Janosch Frank Reviewed-by: Steffen Eiden --- hw/s390x/pv.c | 61 ++++++++++++++++++++++++++++++++++++++ hw/s390x/s390-virtio-ccw.c | 5 ++++ include/hw/s390x/pv.h | 10 +++++++ 3 files changed, 76 insertions(+) diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c index 401b63d6cb..2b892b45e8 100644 --- a/hw/s390x/pv.c +++ b/hw/s390x/pv.c @@ -20,6 +20,11 @@ #include "exec/confidential-guest-support.h" #include "hw/s390x/ipl.h" #include "hw/s390x/pv.h" +#include "target/s390x/kvm/kvm_s390x.h" + +static bool info_valid; +static struct kvm_s390_pv_info_vm info_vm; +static struct kvm_s390_pv_info_dump info_dump; =20 static int __s390_pv_cmd(uint32_t cmd, const char *cmdname, void *data) { @@ -56,6 +61,42 @@ static int __s390_pv_cmd(uint32_t cmd, const char *cmdna= me, void *data) } \ } =20 +int s390_pv_query_info(void) +{ + struct kvm_s390_pv_info info =3D { + .header.id =3D KVM_PV_INFO_VM, + .header.len_max =3D sizeof(info.header) + sizeof(info.vm), + }; + int rc; + + /* Info API's first user is dump so they are bundled */ + if (!kvm_s390_get_protected_dump()) { + return 0; + } + + rc =3D s390_pv_cmd(KVM_PV_INFO, &info); + if (rc) { + error_report("KVM PV INFO cmd %x failed: %s", + info.header.id, strerror(rc)); + return rc; + } + memcpy(&info_vm, &info.vm, sizeof(info.vm)); + + info.header.id =3D KVM_PV_INFO_DUMP; + info.header.len_max =3D sizeof(info.header) + sizeof(info.dump); + rc =3D s390_pv_cmd(KVM_PV_INFO, &info); + if (rc) { + error_report("KVM PV INFO cmd %x failed: %s", + info.header.id, strerror(rc)); + return rc; + } + + memcpy(&info_dump, &info.dump, sizeof(info.dump)); + info_valid =3D true; + + return rc; +} + int s390_pv_vm_enable(void) { return s390_pv_cmd(KVM_PV_ENABLE, NULL); @@ -114,6 +155,26 @@ void s390_pv_inject_reset_error(CPUState *cs) env->regs[r1 + 1] =3D DIAG_308_RC_INVAL_FOR_PV; } =20 +uint64_t kvm_s390_pv_dmp_get_size_cpu(void) +{ + return info_dump.dump_cpu_buffer_len; +} + +uint64_t kvm_s390_pv_dmp_get_size_complete(void) +{ + return info_dump.dump_config_finalize_len; +} + +uint64_t kvm_s390_pv_dmp_get_size_stor_state(void) +{ + return info_dump.dump_config_mem_buffer_per_1m; +} + +bool kvm_s390_pv_info_basic_valid(void) +{ + return info_valid; +} + #define TYPE_S390_PV_GUEST "s390-pv-guest" OBJECT_DECLARE_SIMPLE_TYPE(S390PVGuest, S390_PV_GUEST) =20 diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index cc3097bfee..f9401e392b 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -366,6 +366,11 @@ static int s390_machine_protect(S390CcwMachineState *m= s) =20 ms->pv =3D true; =20 + rc =3D s390_pv_query_info(); + if (rc) { + goto out_err; + } + /* Set SE header and unpack */ rc =3D s390_ipl_prepare_pv_header(); if (rc) { diff --git a/include/hw/s390x/pv.h b/include/hw/s390x/pv.h index 1f1f545bfc..573259cf2b 100644 --- a/include/hw/s390x/pv.h +++ b/include/hw/s390x/pv.h @@ -38,6 +38,7 @@ static inline bool s390_is_pv(void) return ccw->pv; } =20 +int s390_pv_query_info(void); int s390_pv_vm_enable(void); void s390_pv_vm_disable(void); int s390_pv_set_sec_parms(uint64_t origin, uint64_t length); @@ -46,8 +47,13 @@ void s390_pv_prep_reset(void); int s390_pv_verify(void); void s390_pv_unshare(void); void s390_pv_inject_reset_error(CPUState *cs); +uint64_t kvm_s390_pv_dmp_get_size_cpu(void); +uint64_t kvm_s390_pv_dmp_get_size_stor_state(void); +uint64_t kvm_s390_pv_dmp_get_size_complete(void); +bool kvm_s390_pv_info_basic_valid(void); #else /* CONFIG_KVM */ static inline bool s390_is_pv(void) { return false; } +static inline int s390_pv_query_info(void) { return 0; } static inline int s390_pv_vm_enable(void) { return 0; } static inline void s390_pv_vm_disable(void) {} static inline int s390_pv_set_sec_parms(uint64_t origin, uint64_t length) = { return 0; } @@ -56,6 +62,10 @@ static inline void s390_pv_prep_reset(void) {} static inline int s390_pv_verify(void) { return 0; } static inline void s390_pv_unshare(void) {} static inline void s390_pv_inject_reset_error(CPUState *cs) {}; +static inline uint64_t kvm_s390_pv_dmp_get_size_cpu(void) { return 0; } +static inline uint64_t kvm_s390_pv_dmp_get_size_stor_state(void) { return = 0; } +static inline uint64_t kvm_s390_pv_dmp_get_size_complete(void) { return 0;= } +static inline bool kvm_s390_pv_info_basic_valid(void) { return false; } #endif /* CONFIG_KVM */ =20 int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp); --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658828759; cv=none; d=zohomail.com; s=zohoarc; b=ZUcjA8VFVFZSBqGvmQnvoGAGvYBcXDJY85Iq3Y4aofCWAk0d7J7iI8876rnHU1sQ8xms/o0stTgQXEM7qoKWpcmOtSr7M5xmZuUvjB7QsuLki7g7cwGBSqOAdnJX4/gkFy1fuZzvwG/3bsTzweQX3Yqktu4Hcjgvk8RzfIVMJa4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658828759; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9dkoH7yZe5wC+2uqdq25GnS30EFA2vvlokv8l171feU=; b=GlHIRZHvsM4nxLyUYXYp4WzyAyDJWTI5Bi0d1URg89mMnl1+ScPPbHpvDHy/yA88bnLKHODGtWHPqCWa61DxZeb3H55YjXDMEYjP0HtuwA60F6b6kgyzd5FN1G2BZusI32jBNBWTwv7qTmyOi8q5KRT0CFzsQO32hTefcYWfVUM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658828759924771.4756774407391; Tue, 26 Jul 2022 02:45:59 -0700 (PDT) Received: from localhost ([::1]:35162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGH8Y-0004kD-Mz for importer@patchew.org; Tue, 26 Jul 2022 05:45:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnH-0004fY-Sj; Tue, 26 Jul 2022 05:24:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:3530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnG-0005b0-1e; Tue, 26 Jul 2022 05:23:59 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q8rVrC003302; Tue, 26 Jul 2022 09:23:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtr7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:56 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q8rYcj003419; Tue, 26 Jul 2022 09:23:55 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjd59gtq6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:55 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LVHO002961; Tue, 26 Jul 2022 09:23:53 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 3hg946bhyp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:52 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NnSZ18678076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:49 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A67EFA4060; Tue, 26 Jul 2022 09:23:49 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 86191A4054; Tue, 26 Jul 2022 09:23:48 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:48 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=9dkoH7yZe5wC+2uqdq25GnS30EFA2vvlokv8l171feU=; b=sCCtoaXX/NI1jqlqTyJEycmJ86InGdDJroBfnbw60/2YPkZY+8p1ErU9tqD3KmfcS53F HUe1ARjqYq3JpUf3sJTC9DU+X4cQmxotxLPVdagRTMlJObM8J+OSQUFmeHefKb8l0+Jd oPKWZEargj6VM+F7UY3RvD39aztClf7nhz9EvbCPfCgJiGm+i3ArYGgxHPRbbTcR8tjC FG9TpIGSLYTS8D4RVSiK9nBeftqCmQwDe0YBjEGNcgrjukzs0hQgvW8tj7i8WAanvwoQ xqwMO6OKUnOwAu5npoVoG9Do/q6y63USAkhIk0x3KA+XaG/8gLGqIUsts0g7xIfktWof Rw== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 16/17] s390x: Add KVM PV dump interface Date: Tue, 26 Jul 2022 09:22:47 +0000 Message-Id: <20220726092248.128336-17-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: iqZIzvW4VpCqej4b2yQte-bnYqFXgIoU X-Proofpoint-ORIG-GUID: zcYNcKPqYioYkiKYkJrUjYCXgJvSws3p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 lowpriorityscore=0 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658828762184100001 Content-Type: text/plain; charset="utf-8" Let's add a few bits of code which hide the new KVM PV dump API from us via new functions. Signed-off-by: Janosch Frank --- hw/s390x/pv.c | 51 +++++++++++++++++++++++++++++++++++++++++++ include/hw/s390x/pv.h | 8 +++++++ 2 files changed, 59 insertions(+) diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c index 2b892b45e8..ce3b6ad3e9 100644 --- a/hw/s390x/pv.c +++ b/hw/s390x/pv.c @@ -175,6 +175,57 @@ bool kvm_s390_pv_info_basic_valid(void) return info_valid; } =20 +static int s390_pv_dump_cmd(uint64_t subcmd, uint64_t uaddr, uint64_t gadd= r, + uint64_t len) +{ + struct kvm_s390_pv_dmp dmp =3D { + .subcmd =3D subcmd, + .buff_addr =3D uaddr, + .buff_len =3D len, + .gaddr =3D gaddr, + }; + int ret; + + ret =3D s390_pv_cmd(KVM_PV_DUMP, (void *)&dmp); + if (ret) { + error_report("KVM DUMP command %ld failed", subcmd); + } + return ret; +} + +int kvm_s390_dump_cpu(S390CPU *cpu, void *buff) +{ + struct kvm_s390_pv_dmp dmp =3D { + .subcmd =3D KVM_PV_DUMP_CPU, + .buff_addr =3D (uint64_t)buff, + .gaddr =3D 0, + .buff_len =3D info_dump.dump_cpu_buffer_len, + }; + struct kvm_pv_cmd pv =3D { + .cmd =3D KVM_PV_DUMP, + .data =3D (uint64_t)&dmp, + }; + + return kvm_vcpu_ioctl(CPU(cpu), KVM_S390_PV_CPU_COMMAND, &pv); +} + +int kvm_s390_dump_init(void) +{ + return s390_pv_dump_cmd(KVM_PV_DUMP_INIT, 0, 0, 0); +} + +int kvm_s390_dump_mem(uint64_t gaddr, size_t len, void *dest) +{ + return s390_pv_dump_cmd(KVM_PV_DUMP_CONFIG_STATE, (uint64_t)dest, + gaddr, len); +} + +int kvm_s390_dump_complete(void *buff) +{ + return s390_pv_dump_cmd(KVM_PV_DUMP_COMPLETE, (uint64_t)buff, 0, + info_dump.dump_config_finalize_len); +} + #define TYPE_S390_PV_GUEST "s390-pv-guest" OBJECT_DECLARE_SIMPLE_TYPE(S390PVGuest, S390_PV_GUEST) =20 diff --git a/include/hw/s390x/pv.h b/include/hw/s390x/pv.h index 573259cf2b..02a6c06b9f 100644 --- a/include/hw/s390x/pv.h +++ b/include/hw/s390x/pv.h @@ -51,6 +51,10 @@ uint64_t kvm_s390_pv_dmp_get_size_cpu(void); uint64_t kvm_s390_pv_dmp_get_size_stor_state(void); uint64_t kvm_s390_pv_dmp_get_size_complete(void); bool kvm_s390_pv_info_basic_valid(void); +int kvm_s390_dump_init(void); +int kvm_s390_dump_cpu(S390CPU *cpu, void *buff); +int kvm_s390_dump_mem(uint64_t addr, size_t len, void *dest); +int kvm_s390_dump_complete(void *buff); #else /* CONFIG_KVM */ static inline bool s390_is_pv(void) { return false; } static inline int s390_pv_query_info(void) { return 0; } @@ -66,6 +70,10 @@ static inline uint64_t kvm_s390_pv_dmp_get_size_cpu(void= ) { return 0; } static inline uint64_t kvm_s390_pv_dmp_get_size_stor_state(void) { return = 0; } static inline uint64_t kvm_s390_pv_dmp_get_size_complete(void) { return 0;= } static inline bool kvm_s390_pv_info_basic_valid(void) { return false; } +static inline int kvm_s390_dump_init(void) { return 0; } +static inline int kvm_s390_dump_cpu(S390CPU *cpu, void *buff, size_t len) = { return 0; } +static inline int kvm_s390_dump_mem(uint64_t addr, size_t len, void *dest)= { return 0; } +static inline int kvm_s390_dump_complete(void *buff) { return 0; } #endif /* CONFIG_KVM */ =20 int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp); --=20 2.34.1 From nobody Thu May 16 05:03:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1658828580; cv=none; d=zohomail.com; s=zohoarc; b=lLeXAPxfK2DFik3/awJ4yhOAov1E7NWV/OgWOJQZV0jK60Ak+nPjarz3UgouvXsuS448xZ5FOs9I39MzETc1DqKfMrG7L4tushpuGe5A5ved3CJMbqzMi4Um4uXQIhURGJ/iH126yomRp/buVKYobt5j8OvogwgEjzMiZlfiQMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658828580; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q9/DTecg3+DrwqiHnopvPhI4Q2b0eDJx4gVdTvntgO8=; b=NZxTJVc8JUjILRKPBkCtnWAs2EmEvokrzeeM9ahnYVBYZ3dQGeHUZGl7zW/1GZRjZUM8k6oQB35tDpL74F512fbUnRmjIau8nIXfj0Llz8t407TqAijnTdCeLMrZxGfd7opsDWkXukDXdhoLtW4YBHdgNZtqqGOfgr8dQejprYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1658828580563179.38689955134953; Tue, 26 Jul 2022 02:43:00 -0700 (PDT) Received: from localhost ([::1]:59094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGH5f-0001Om-4l for importer@patchew.org; Tue, 26 Jul 2022 05:42:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnJ-0004hR-OP; Tue, 26 Jul 2022 05:24:02 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:29572 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGGnG-0005b7-1s; Tue, 26 Jul 2022 05:24:00 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 26Q9DueW030610; Tue, 26 Jul 2022 09:23:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdeu087g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:56 +0000 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 26Q9F5ZY001691; Tue, 26 Jul 2022 09:23:56 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3hjdeu086x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:55 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 26Q9LbeO026381; Tue, 26 Jul 2022 09:23:54 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04ams.nl.ibm.com with ESMTP id 3hg96wkjtk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 26 Jul 2022 09:23:54 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 26Q9NpZK23789962 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jul 2022 09:23:51 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE527A405B; Tue, 26 Jul 2022 09:23:50 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD1D7A4054; Tue, 26 Jul 2022 09:23:49 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 26 Jul 2022 09:23:49 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Q9/DTecg3+DrwqiHnopvPhI4Q2b0eDJx4gVdTvntgO8=; b=O9PwW1OfqkfvExDLpv/erzUiZTL+h7ZdOgrrV7JcaFHFhRUvP9QNUDkn8fpssqkdJN6S rhaDqfc6P0V/keBTmaqrdb184P3KvR36R5yQIvN1g8AgOxMUT7Z1MsQItG86TmXXiEVU nWppyEVHOct8xFqpemgZiqEqKtWdmQZ3bR8y94AbyTr7uY1gs+DFaiqMxAzZooEbq/+Y wIEQDCzMnIkwqs13w+B65nKjggxvVikFMFHDzBIhcU1WVbqg13aPsHpltxOE3gcsdmzx 25WX2GhhV1JPXJ+t0s0tbkYzHV9wa/SBadbXDFq0GzFNwVf1xLyA4fZ61/zt8sNYTysc iA== From: Janosch Frank To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com, mhartmay@linux.ibm.com, borntraeger@linux.ibm.com, imbrenda@linux.ibm.com, pasic@linux.ibm.com, cohuck@redhat.com, thuth@redhat.com, qemu-s390x@nongnu.org, seiden@linux.ibm.com, scgl@linux.ibm.com Subject: [PATCH v4 17/17] s390x: pv: Add dump support Date: Tue, 26 Jul 2022 09:22:48 +0000 Message-Id: <20220726092248.128336-18-frankja@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220726092248.128336-1-frankja@linux.ibm.com> References: <20220726092248.128336-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: e7E7NnA-rhTjjlNT7XldPWzDsyNBzfqe X-Proofpoint-ORIG-GUID: 775Bb0GY-0ILZ-plH0GJ82wIiVYamCUS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-07-26_02,2022-07-25_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 mlxscore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2206140000 definitions=main-2207260033 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=frankja@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1658828581465100001 Content-Type: text/plain; charset="utf-8" Sometimes dumping a guest from the outside is the only way to get the data that is needed. This can be the case if a dumping mechanism like KDUMP hasn't been configured or data needs to be fetched at a specific point. Dumping a protected guest from the outside without help from fw/hw doesn't yield sufficient data to be useful. Hence we now introduce PV dump support. The PV dump support works by integrating the firmware into the dump process. New Ultravisor calls are used to initiate the dump process, dump cpu data, dump memory state and lastly complete the dump process. The UV calls are exposed by KVM via the new KVM_PV_DUMP command and its subcommands. The guest's data is fully encrypted and can only be decrypted by the entity that owns the customer communication key for the dumped guest. Also dumping needs to be allowed via a flag in the SE header. On the QEMU side of things we store the PV dump data in the newly introduced architecture ELF sections (storage state and completion data) and the cpu notes (for cpu dump data). Users can use the zgetdump tool to convert the encrypted QEMU dump to an unencrypted one. Signed-off-by: Janosch Frank --- target/s390x/arch_dump.c | 248 ++++++++++++++++++++++++++++++++++----- 1 file changed, 218 insertions(+), 30 deletions(-) diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c index 08daf93ae1..8afef4127c 100644 --- a/target/s390x/arch_dump.c +++ b/target/s390x/arch_dump.c @@ -16,7 +16,8 @@ #include "s390x-internal.h" #include "elf.h" #include "sysemu/dump.h" - +#include "hw/s390x/pv.h" +#include "kvm/kvm_s390x.h" =20 struct S390xUserRegsStruct { uint64_t psw[2]; @@ -76,9 +77,16 @@ typedef struct noteStruct { uint64_t todcmp; uint32_t todpreg; uint64_t ctrs[16]; + uint8_t dynamic[1]; /* + * Would be a flexible array member, if + * that was legal inside a union. Real + * size comes from PV info interface. + */ } contents; } QEMU_PACKED Note; =20 +static bool pv_dump_initialized; + static void s390x_write_elf64_prstatus(Note *note, S390CPU *cpu, int id) { int i; @@ -177,52 +185,82 @@ static void s390x_write_elf64_prefix(Note *note, S390= CPU *cpu, int id) note->contents.prefix =3D cpu_to_be32((uint32_t)(cpu->env.psa)); } =20 +static void s390x_write_elf64_pv(Note *note, S390CPU *cpu, int id) +{ + note->hdr.n_type =3D cpu_to_be32(NT_S390_PV_CPU_DATA); + if (!pv_dump_initialized) { + return; + } + kvm_s390_dump_cpu(cpu, ¬e->contents.dynamic); +} =20 typedef struct NoteFuncDescStruct { int contents_size; + uint64_t (*note_size_func)(void); /* NULL for non-dynamic sized conten= ts */ void (*note_contents_func)(Note *note, S390CPU *cpu, int id); + bool pvonly; } NoteFuncDesc; =20 static const NoteFuncDesc note_core[] =3D { - {sizeof_field(Note, contents.prstatus), s390x_write_elf64_prstatus}, - {sizeof_field(Note, contents.fpregset), s390x_write_elf64_fpregset}, - { 0, NULL} + {sizeof_field(Note, contents.prstatus), NULL, s390x_write_elf64_prstat= us, false}, + {sizeof_field(Note, contents.fpregset), NULL, s390x_write_elf64_fpregs= et, false}, + { 0, NULL, NULL} }; =20 static const NoteFuncDesc note_linux[] =3D { - {sizeof_field(Note, contents.prefix), s390x_write_elf64_prefix}, - {sizeof_field(Note, contents.ctrs), s390x_write_elf64_ctrs}, - {sizeof_field(Note, contents.timer), s390x_write_elf64_timer}, - {sizeof_field(Note, contents.todcmp), s390x_write_elf64_todcmp}, - {sizeof_field(Note, contents.todpreg), s390x_write_elf64_todpreg}, - {sizeof_field(Note, contents.vregslo), s390x_write_elf64_vregslo}, - {sizeof_field(Note, contents.vregshi), s390x_write_elf64_vregshi}, - {sizeof_field(Note, contents.gscb), s390x_write_elf64_gscb}, - { 0, NULL} + {sizeof_field(Note, contents.prefix), NULL, s390x_write_elf64_prefix= , false}, + {sizeof_field(Note, contents.ctrs), NULL, s390x_write_elf64_ctrs, = false}, + {sizeof_field(Note, contents.timer), NULL, s390x_write_elf64_timer,= false}, + {sizeof_field(Note, contents.todcmp), NULL, s390x_write_elf64_todcmp= , false}, + {sizeof_field(Note, contents.todpreg), NULL, s390x_write_elf64_todpre= g, false}, + {sizeof_field(Note, contents.vregslo), NULL, s390x_write_elf64_vregsl= o, false}, + {sizeof_field(Note, contents.vregshi), NULL, s390x_write_elf64_vregsh= i, false}, + {sizeof_field(Note, contents.gscb), NULL, s390x_write_elf64_gscb, = false}, + {0, kvm_s390_pv_dmp_get_size_cpu, s390x_write_elf64_pv, true}, + { 0, NULL, NULL} }; =20 static int s390x_write_elf64_notes(const char *note_name, - WriteCoreDumpFunction f, - S390CPU *cpu, int id, - void *opaque, - const NoteFuncDesc *funcs) + WriteCoreDumpFunction f, + S390CPU *cpu, int id, + void *opaque, + const NoteFuncDesc *funcs) { - Note note; + Note note, *notep; const NoteFuncDesc *nf; - int note_size; + int note_size, content_size; int ret =3D -1; =20 assert(strlen(note_name) < sizeof(note.name)); =20 for (nf =3D funcs; nf->note_contents_func; nf++) { - memset(¬e, 0, sizeof(note)); - note.hdr.n_namesz =3D cpu_to_be32(strlen(note_name) + 1); - note.hdr.n_descsz =3D cpu_to_be32(nf->contents_size); - g_strlcpy(note.name, note_name, sizeof(note.name)); - (*nf->note_contents_func)(¬e, cpu, id); + notep =3D ¬e; + if (nf->pvonly && !s390_is_pv()) { + continue; + } =20 - note_size =3D sizeof(note) - sizeof(note.contents) + nf->contents_= size; - ret =3D f(¬e, note_size, opaque); + content_size =3D nf->contents_size ? nf->contents_size : nf->note_= size_func(); + note_size =3D sizeof(note) - sizeof(notep->contents) + content_siz= e; + + /* Notes with dynamic sizes need to allocate a note */ + if (nf->note_size_func) { + notep =3D g_malloc0(note_size); + } + + memset(notep, 0, sizeof(note)); + + /* Setup note header data */ + notep->hdr.n_descsz =3D cpu_to_be32(content_size); + notep->hdr.n_namesz =3D cpu_to_be32(strlen(note_name) + 1); + g_strlcpy(notep->name, note_name, sizeof(notep->name)); + + /* Get contents and write them out */ + (*nf->note_contents_func)(notep, cpu, id); + ret =3D f(notep, note_size, opaque); + + if (nf->note_size_func) { + g_free(notep); + } =20 if (ret < 0) { return -1; @@ -247,12 +285,159 @@ int s390_cpu_write_elf64_note(WriteCoreDumpFunction = f, CPUState *cs, return s390x_write_elf64_notes("LINUX", f, cpu, cpuid, opaque, note_li= nux); } =20 +/* PV dump section size functions */ +static uint64_t get_dump_stor_state_size_from_len(uint64_t len) +{ + return (len / (1 << 20)) * kvm_s390_pv_dmp_get_size_stor_state(); +} + +static uint64_t get_size_stor_state(DumpState *s) +{ + return get_dump_stor_state_size_from_len(s->total_size); +} + +static uint64_t get_size_complete(DumpState *s) +{ + return kvm_s390_pv_dmp_get_size_complete(); +} + +/* PV dump section data functions*/ +static int get_data_complete(DumpState *s, uint8_t *buff) +{ + int rc; + + if (!pv_dump_initialized) { + return 0; + } + rc =3D kvm_s390_dump_complete(buff); + if (!rc) { + pv_dump_initialized =3D false; + } + return rc; +} + +static int dump_mem(DumpState *s, uint64_t gaddr, uint8_t *buff, uint64_t = buff_len) +{ + /* We need the gaddr + len and something to write to */ + if (!pv_dump_initialized) { + return 0; + } + return kvm_s390_dump_mem(gaddr, buff_len, buff); +} + +static int get_data_mem(DumpState *s, uint8_t *buff) +{ + int64_t memblock_size, memblock_start; + GuestPhysBlock *block; + uint64_t off; + + QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) { + memblock_start =3D dump_get_memblock_start(block, s->begin, s->len= gth); + if (memblock_start =3D=3D -1) { + continue; + } + + memblock_size =3D dump_get_memblock_size(block, s->begin, s->lengt= h); + + off =3D get_dump_stor_state_size_from_len(block->target_start); + dump_mem(s, block->target_start, buff + off, + get_dump_stor_state_size_from_len(memblock_size)); + } + + return 0; +} + +struct sections { + uint64_t (*sections_size_func)(DumpState *s); + int (*sections_contents_func)(DumpState *s, uint8_t *buff); + char sctn_str[12]; +} sections[] =3D { + { get_size_stor_state, get_data_mem, "pv_mem_meta"}, + { get_size_complete, get_data_complete, "pv_compl"}, + {NULL , NULL, ""} +}; + +static uint64_t arch_sections_write_hdr(void *opaque, uint8_t *buff) +{ + DumpState *s =3D opaque; + Elf64_Shdr *shdr =3D (void *)buff; + struct sections *sctn =3D sections; + uint64_t off =3D s->section_offset; + + if (!s390_is_pv()) { + return 0; + } + + for (; sctn->sections_size_func; off +=3D shdr->sh_size, sctn++, shdr+= +) { + memset(shdr, 0, sizeof(*shdr)); + shdr->sh_type =3D SHT_PROGBITS; + shdr->sh_offset =3D off; + shdr->sh_size =3D sctn->sections_size_func(s); + shdr->sh_name =3D s->string_table_buf->len; + g_array_append_vals(s->string_table_buf, sctn->sctn_str, sizeof(sc= tn->sctn_str)); + } + + return (uintptr_t)shdr - (uintptr_t)buff; +} + + +/* Add arch specific number of sections and their respective sizes */ +static void arch_sections_add(void *opaque) +{ + DumpState *s =3D opaque; + struct sections *sctn =3D sections; + + /* + * We only do a PV dump if we are running a PV guest, KVM supports + * the dump API and we got valid dump length information. + */ + if (!s390_is_pv() || !kvm_s390_get_protected_dump() || + !kvm_s390_pv_info_basic_valid()) { + return; + } + + /* + * Start the UV dump process by doing the initialize dump call via + * KVM as the proxy. + */ + if (!kvm_s390_dump_init()) { + pv_dump_initialized =3D true; + } + + for (; sctn->sections_size_func; sctn++) { + s->shdr_num +=3D 1; + s->elf_section_data_size +=3D sctn->sections_size_func(s); + } +} + +/* + * After the PV dump has been initialized, the CPU data has been + * fetched and memory has been dumped, we need to grab the tweak data + * and the completion data. + */ +static void arch_sections_write(void *opaque, uint8_t *buff) +{ + DumpState *s =3D opaque; + struct sections *sctn =3D sections; + + /* shdr_num should only have been set > 1 if we are protected */ + assert(s390_is_pv()); + + for (; sctn->sections_size_func; sctn++) { + sctn->sections_contents_func(s, buff); + buff +=3D sctn->sections_size_func(s); + } +} + int cpu_get_dump_info(ArchDumpInfo *info, const struct GuestPhysBlockList *guest_phys_blocks) { info->d_machine =3D EM_S390; info->d_endian =3D ELFDATA2MSB; info->d_class =3D ELFCLASS64; + info->arch_sections_add_fn =3D *arch_sections_add; + info->arch_sections_write_hdr_fn =3D *arch_sections_write_hdr; + info->arch_sections_write_fn =3D *arch_sections_write; =20 return 0; } @@ -261,7 +446,7 @@ ssize_t cpu_get_note_size(int class, int machine, int n= r_cpus) { int name_size =3D 8; /* "LINUX" or "CORE" + pad */ size_t elf_note_size =3D 0; - int note_head_size; + int note_head_size, content_size; const NoteFuncDesc *nf; =20 assert(class =3D=3D ELFCLASS64); @@ -270,12 +455,15 @@ ssize_t cpu_get_note_size(int class, int machine, int= nr_cpus) note_head_size =3D sizeof(Elf64_Nhdr); =20 for (nf =3D note_core; nf->note_contents_func; nf++) { - elf_note_size =3D elf_note_size + note_head_size + name_size + - nf->contents_size; + elf_note_size =3D elf_note_size + note_head_size + name_size + nf-= >contents_size; } for (nf =3D note_linux; nf->note_contents_func; nf++) { + if (nf->pvonly && !s390_is_pv()) { + continue; + } + content_size =3D nf->contents_size ? nf->contents_size : nf->note_= size_func(); elf_note_size =3D elf_note_size + note_head_size + name_size + - nf->contents_size; + content_size; } =20 return (elf_note_size) * nr_cpus; --=20 2.34.1