From nobody Sun May 19 00:17:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646912304129282.2173739708635; Thu, 10 Mar 2022 03:38:24 -0800 (PST) Received: from localhost ([::1]:46266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSH7f-0008T4-3D for importer@patchew.org; Thu, 10 Mar 2022 06:38:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49896) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGw3-0003xx-2S; Thu, 10 Mar 2022 06:26:23 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:64268) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGw1-0007cr-B0; Thu, 10 Mar 2022 06:26:22 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22ABEksD021615; Thu, 10 Mar 2022 11:26:19 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eqg9rr5fx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:19 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22ABFV2V022793; Thu, 10 Mar 2022 11:26:19 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eqg9rr5fa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:19 +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 22ABDNxM009176; Thu, 10 Mar 2022 11:26:17 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06ams.nl.ibm.com with ESMTP id 3eky4j4jbt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:17 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22ABQEUd46661952 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Mar 2022 11:26:14 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1ABD44204B; Thu, 10 Mar 2022 11:26:14 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E7C742049; Thu, 10 Mar 2022 11:26:13 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Mar 2022 11:26:13 +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=Mrudc/AntKHdjuFzdp+MsGh3CrDi7NUy0fLalgKT0Vo=; b=SJ3miQWUnJZcy9W2EIAgYyZLL2eQsP7Vd9pvZrcgm/nfDZRnveTa4fAUTdhcaS6e5TxV xQEF02gzcxFxBDuroRPJ7kBgrYG0wbBMMbcmcd49R8r2Ke9JFRu/k0mdbXUYJtjAZ6ag oEIKL8GqEj3Ynq5zFGYQ/M2bQFw1rYCLVz8MorscSKlyFcFw/V6+d8L42pUx6dPcacU3 mxfP1iVSyZR6CiRsndUAp99x8wP3mcKPrEpE4vbOv9HnYPBo8I4Bz7deU6X+aKf+4ko3 ht4TRF51zXeuYxM5ttunI5UAz6n+Gh9qACazkc4C3rZCjHtUI3t0JWVS6lDh0/3c/abn cw== From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 1/5] linux header sync Date: Thu, 10 Mar 2022 11:25:43 +0000 Message-Id: <20220310112547.3823-2-frankja@linux.ibm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220310112547.3823-1-frankja@linux.ibm.com> References: <20220310112547.3823-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Evw_js3DK-6cWYmxNln6CYNSCeMIEMyx X-Proofpoint-ORIG-GUID: SSo7TzzfRY7zcjlEpEyP_JqVR0UUqmoI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-10_03,2022-03-09_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 mlxlogscore=999 bulkscore=0 spamscore=0 clxscore=1011 impostorscore=0 suspectscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203100059 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_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: thuth@redhat.com, borntraeger@linux.ibm.com, cohuck@redhat.com, pasic@linux.ibm.com, qemu-s390x@nongnu.org, mhartmay@linux.ibm.com, pbonzini@redhat.com, marcandre.lureau@redhat.com, imbrenda@linux.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646912306308100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Janosch Frank --- linux-headers/linux/kvm.h | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 00af3bc333..ead1d51cb5 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1133,6 +1133,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_VM_MOVE_ENC_CONTEXT_FROM 206 #define KVM_CAP_VM_GPA_BITS 207 #define KVM_CAP_XSAVE2 208 +#define KVM_CAP_S390_PROTECTED_DUMP 212 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 @@ -1637,6 +1638,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, @@ -1645,6 +1695,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 { @@ -1719,6 +1771,7 @@ struct kvm_xen_vcpu_attr { #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4 #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5 =20 + /* Secure Encrypted Virtualization command */ enum sev_cmd_id { /* Guest initialization commands */ @@ -2047,4 +2100,6 @@ struct kvm_stats_desc { =20 #define KVM_GET_STATS_FD _IO(KVMIO, 0xce) =20 +#define KVM_S390_PV_CPU_COMMAND _IOWR(KVMIO, 0xd0, struct kvm_pv_cmd) + #endif /* __LINUX_KVM_H */ --=20 2.32.0 From nobody Sun May 19 00:17:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646912059194641.3284979635017; Thu, 10 Mar 2022 03:34:19 -0800 (PST) Received: from localhost ([::1]:40700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSH3h-0004XA-Ku for importer@patchew.org; Thu, 10 Mar 2022 06:34:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGw4-00040F-Dc; Thu, 10 Mar 2022 06:26:24 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:7114 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 1nSGw1-0007d8-UY; Thu, 10 Mar 2022 06:26:24 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22AAb6Im019916; Thu, 10 Mar 2022 11:26:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3ep0hgt3cb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:20 +0000 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22AAvKT6025375; Thu, 10 Mar 2022 11:26:20 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 3ep0hgt3bu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:20 +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 22ABF7h2018840; Thu, 10 Mar 2022 11:26:18 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma03ams.nl.ibm.com with ESMTP id 3ekyg94e91-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:18 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22ABQFE143122972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Mar 2022 11:26:15 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3CC6342049; Thu, 10 Mar 2022 11:26:15 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4116542042; Thu, 10 Mar 2022 11:26:14 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Mar 2022 11:26:14 +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=/2hVPZVQu1mbE5zYoGL2dej9x5bR9p7DXreKlOAgNKY=; b=C6xIKIFVqoaXrKcqJjybUcC4pGDpL6JQaLzyTOdTL8KBseAOe2kQb54T0fmF3Wp7KgUq IuIsJG+w0PXkH2rJjBPa0s2iYAdHAZLbVZB0I8myiUZYWht44ZEhFe8epzv3Mv+pjy7x vVGZJuqBa54bSRYisQuq7hjbxULS8ZTz89n5D+o/hKf3HTi0f+sb5GdyKCH+zt/N7cF5 vvycvJK74pnhkMpWsp4eTiPgD6VTROZNGu9Oi+VrpxJ5ogJseB+PZI6FUwTMmp2ti14T BmHuTroekF1YUTnlvhYzeaAAnbSTMsFRWWp5o8NIB8hljNl8zsPbFC2COtXAdftfh8Yr 7Q== From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 2/5] s390x: Add protected dump cap Date: Thu, 10 Mar 2022 11:25:44 +0000 Message-Id: <20220310112547.3823-3-frankja@linux.ibm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220310112547.3823-1-frankja@linux.ibm.com> References: <20220310112547.3823-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _fX-4gQmY4F6iYUOrvW8bJBv6yf9gTCn X-Proofpoint-ORIG-GUID: JivJQ2XwvIuVQ97Cdj75GWzxcf5Ez3HQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-10_03,2022-03-09_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 clxscore=1015 impostorscore=0 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 mlxlogscore=853 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203100059 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_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: thuth@redhat.com, borntraeger@linux.ibm.com, cohuck@redhat.com, pasic@linux.ibm.com, qemu-s390x@nongnu.org, mhartmay@linux.ibm.com, pbonzini@redhat.com, marcandre.lureau@redhat.com, imbrenda@linux.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646912059942100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Janosch Frank --- 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 6acf14d5ec..56ca5408db 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 int active_cmma; =20 @@ -358,6 +359,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); @@ -2035,6 +2037,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.32.0 From nobody Sun May 19 00:17:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646912505304780.779650893933; Thu, 10 Mar 2022 03:41:45 -0800 (PST) Received: from localhost ([::1]:54986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHAv-0005uc-4j for importer@patchew.org; Thu, 10 Mar 2022 06:41:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGw6-00043y-Je; Thu, 10 Mar 2022 06:26:26 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:20406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGw4-0007dZ-Jv; Thu, 10 Mar 2022 06:26:26 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22AA2f8u011779; Thu, 10 Mar 2022 11:26:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eqctrcneq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:22 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22ABLUxm009445; Thu, 10 Mar 2022 11:26:22 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eqctrcne1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:21 +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 22ABC1cM024037; Thu, 10 Mar 2022 11:26:19 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3enqgnq2kx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:19 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22ABQGbE21627236 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Mar 2022 11:26:16 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F0E642049; Thu, 10 Mar 2022 11:26:16 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 637DF42041; Thu, 10 Mar 2022 11:26:15 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Mar 2022 11:26:15 +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=tSSKVu/XjzXvz6Mb7DTwxwOn0iUuY88l8THC2mJUq60=; b=dx9zl6W6iKSdPbF+S0Qli3UAXlSaobGBQyIPrFTR/jxiG8cXLUnCoAj9pHk6vLHxSFz0 G3MYNDNWmPKqwcLKQfKTL8Cbmcolu2O7Twm7ff8SQLj4dlSBDlnXRdGWNwbhlqEOsGF/ eIBZWWUYS1ka2yMIoYBQsfJKEHzLIf6I3XQtSTbND3GTSc/TRvtTkiEMdH+igJz1bEaJ Q9g7jahcXQ/ks3HaocrwH8Thj+GhNeDSAOPCq1Z0YAfuVREVL6l0lWk6dpcbq1ChQuc1 kxFne3hElQWFsECiW2JveeYfj9ffryHjye0NWJK2TgkRy+mn6mPHXb1FkKr10xGZpgVt ug== From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 3/5] s390x: Introduce PV query interface Date: Thu, 10 Mar 2022 11:25:45 +0000 Message-Id: <20220310112547.3823-4-frankja@linux.ibm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220310112547.3823-1-frankja@linux.ibm.com> References: <20220310112547.3823-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: brn2MYQvC03iozF1OTHKT7sx60fQDCn6 X-Proofpoint-ORIG-GUID: qIYZKjBB_Yz5Z-tR0w3O7FXbyjv-6juN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-10_03,2022-03-09_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 clxscore=1015 priorityscore=1501 phishscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 impostorscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203100059 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_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: thuth@redhat.com, borntraeger@linux.ibm.com, cohuck@redhat.com, pasic@linux.ibm.com, qemu-s390x@nongnu.org, mhartmay@linux.ibm.com, pbonzini@redhat.com, marcandre.lureau@redhat.com, imbrenda@linux.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646912511434100001 Content-Type: text/plain; charset="utf-8" Introduce an interface over which we can get information about UV data. Signed-off-by: Janosch Frank --- 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..a5af4ddf46 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_mem(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 84e3e63c43..abb165031e 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -365,6 +365,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..6fa55bf70e 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_mem(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_mem(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.32.0 From nobody Sun May 19 00:17:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646912684626818.6910315178937; Thu, 10 Mar 2022 03:44:44 -0800 (PST) Received: from localhost ([::1]:35520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHDn-0003JB-FH for importer@patchew.org; Thu, 10 Mar 2022 06:44:43 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGw8-00047k-66; Thu, 10 Mar 2022 06:26:28 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:18444) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGw5-0007e1-Ai; Thu, 10 Mar 2022 06:26:27 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22A9rUPh020375; Thu, 10 Mar 2022 11:26:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eqf3n1r5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:23 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22AAYRJZ015092; Thu, 10 Mar 2022 11:26:23 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eqf3n1r4w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:23 +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 22ABDQig009190; Thu, 10 Mar 2022 11:26:20 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06ams.nl.ibm.com with ESMTP id 3eky4j4jc3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:20 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22ABQHZt47907180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Mar 2022 11:26:17 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 81FDF42049; Thu, 10 Mar 2022 11:26:17 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 85B154203F; Thu, 10 Mar 2022 11:26:16 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Mar 2022 11:26:16 +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=5L7chknyGsJC8KJbi6eRkcjnG3uPCY30/xmnW2hFyf0=; b=iZ8Ue9mK8fraW5kWI2UTM03SS76S4sk6uzw0KTF3JzVSOKDy4IvGWqcgBtmRtCCMDJ7A kc3JT50dzyu4d5wR/Ls1/Xak8iKIYakvg4IR8KvpTrRe5BVn+hU3zwimjbA5M/xWqMpx PdK0pS//H9RoIxlcj+3+W2k1JYcY2NSeTlAzwQXi2lrXRBPGKLSKdRL4q5iZCdYuE9ZJ mNhBpNxKGZekymCEl0ggNBRKHBu/NbSxhH+jZaz48CYtKS9diqMzRyre74HDTSGHWgA0 FFpAzhn6js117xe26AXYVn95mQjkdPIUPACW9I3zltJRfMPp84cIuVJLlCKT6Ps3HzAg lw== From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 4/5] s390x: Add KVM PV dump interface Date: Thu, 10 Mar 2022 11:25:46 +0000 Message-Id: <20220310112547.3823-5-frankja@linux.ibm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220310112547.3823-1-frankja@linux.ibm.com> References: <20220310112547.3823-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: rj1-QWYWwwYATgZC907sV2ekBPpmy7sy X-Proofpoint-GUID: MB6R0SzZ8dcQblTck1MhNrnae2SomjTT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-10_03,2022-03-09_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 priorityscore=1501 impostorscore=0 phishscore=0 clxscore=1015 spamscore=0 mlxscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203100059 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_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: thuth@redhat.com, borntraeger@linux.ibm.com, cohuck@redhat.com, pasic@linux.ibm.com, qemu-s390x@nongnu.org, mhartmay@linux.ibm.com, pbonzini@redhat.com, marcandre.lureau@redhat.com, imbrenda@linux.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646912685180100001 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 | 52 +++++++++++++++++++++++++++++++++++++++++++ include/hw/s390x/pv.h | 8 +++++++ 2 files changed, 60 insertions(+) diff --git a/hw/s390x/pv.c b/hw/s390x/pv.c index a5af4ddf46..d6625fa374 100644 --- a/hw/s390x/pv.c +++ b/hw/s390x/pv.c @@ -175,6 +175,58 @@ 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_finish(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 6fa55bf70e..f37021e189 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_mem(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_finish(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_mem(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_finish(void *buff) { return 0; } #endif /* CONFIG_KVM */ =20 int s390_pv_kvm_init(ConfidentialGuestSupport *cgs, Error **errp); --=20 2.32.0 From nobody Sun May 19 00:17:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1646912392085860.5066725342651; Thu, 10 Mar 2022 03:39:52 -0800 (PST) Received: from localhost ([::1]:49440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSH94-00029l-S6 for importer@patchew.org; Thu, 10 Mar 2022 06:39:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGwC-0004J5-S9; Thu, 10 Mar 2022 06:26:32 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:61642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSGwA-0007fe-1Q; Thu, 10 Mar 2022 06:26:32 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22AAoqe0021676; Thu, 10 Mar 2022 11:26:28 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eqfxfrnkf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:28 +0000 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 22ABPD2c026373; Thu, 10 Mar 2022 11:26:27 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 3eqfxfrnj0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:27 +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 22ABDSOH009196; Thu, 10 Mar 2022 11:26:22 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma06ams.nl.ibm.com with ESMTP id 3eky4j4jc7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Mar 2022 11:26:21 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 22ABQJkp34079206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Mar 2022 11:26:19 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AF64C42041; Thu, 10 Mar 2022 11:26:18 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8D0D42047; Thu, 10 Mar 2022 11:26:17 +0000 (GMT) Received: from linux6.. (unknown [9.114.12.104]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 10 Mar 2022 11:26:17 +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=IMry9aev+NZYRR6SZW21FqFeVaiZQ5OTAhHnepcL8cY=; b=HYhZTAlV6ia2rst0TbfUDjUYw7b6GGK+dpVjf2kI7rBsOevwCdXSm/+SIna0sBpsAs11 Fh8xGnomLPniGXwpssz1pM3/KIJwzmxzrzjUBQvmVrd75sQkBneW0UCyGKXCvb2CAwis JFOV83dBd2tDb09/eKjnISMgmF78Xqc/X14/BdIX0yNCLXY/UwVl8YGJuLuDunfxWoMi SqZyB6OALPxoLs+hQ4hwnramSmJjxbati8b3sDaVd7MCGMTUf8mfzKE/mKzxWsYigNm8 tKy3zuoZV2+mQ2tvZWPMuqzV50tgwWB2QmhGLxhCcFRtVmvKYkg7udlMnZFegzovqpZI wA== From: Janosch Frank To: qemu-devel@nongnu.org Subject: [PATCH 5/5] s390x: pv: Add dump support Date: Thu, 10 Mar 2022 11:25:47 +0000 Message-Id: <20220310112547.3823-6-frankja@linux.ibm.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220310112547.3823-1-frankja@linux.ibm.com> References: <20220310112547.3823-1-frankja@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: BhnXwyvOZ_Iayqepxb9WEEBlCquU3dZ2 X-Proofpoint-ORIG-GUID: -bzDQV-um-O1iaB4f2w9A7kx3IzL296- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.64.514 definitions=2022-03-10_03,2022-03-09_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 lowpriorityscore=0 suspectscore=0 bulkscore=0 clxscore=1015 adultscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2203100059 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_H5=0.001, RCVD_IN_MSPIKE_WL=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: , Cc: thuth@redhat.com, borntraeger@linux.ibm.com, cohuck@redhat.com, pasic@linux.ibm.com, qemu-s390x@nongnu.org, mhartmay@linux.ibm.com, pbonzini@redhat.com, marcandre.lureau@redhat.com, imbrenda@linux.ibm.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1646912393182100001 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 a tool to convert the encrypted QEMU dump to an unencrypted one. Signed-off-by: Janosch Frank --- dump/dump.c | 27 ----- include/elf.h | 1 + include/sysemu/dump.h | 27 +++++ target/s390x/arch_dump.c | 247 ++++++++++++++++++++++++++++++++++----- 4 files changed, 244 insertions(+), 58 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index a9d9ea514d..4b7d333866 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -708,33 +708,6 @@ static void dump_begin(DumpState *s, Error **errp) write_elf_notes(s, errp); } =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) { diff --git a/include/elf.h b/include/elf.h index 3a4bcb646a..58f76fd5b4 100644 --- a/include/elf.h +++ b/include/elf.h @@ -1649,6 +1649,7 @@ 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_DATA 0x30e /* s390 protvirt cpu dump data */ #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/include/sysemu/dump.h b/include/sysemu/dump.h index 9a000e7483..6106e0de78 100644 --- a/include/sysemu/dump.h +++ b/include/sysemu/dump.h @@ -213,4 +213,31 @@ 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); + +static inline 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; + } +} #endif diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c index 08daf93ae1..e8e8cfbc9f 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,12 @@ typedef struct noteStruct { uint64_t todcmp; uint32_t todpreg; uint64_t ctrs[16]; + uint8_t dynamic; /* 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 +181,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_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; @@ -233,7 +267,6 @@ static int s390x_write_elf64_notes(const char *note_nam= e, return 0; } =20 - int s390_cpu_write_elf64_note(WriteCoreDumpFunction f, CPUState *cs, int cpuid, void *opaque) { @@ -247,12 +280,161 @@ 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_mem_size_from_len(uint64_t len) +{ + return (len / (1 << 20)) * kvm_s390_pv_dmp_get_size_mem(); +} + +static uint64_t get_size_mem(DumpState *s) +{ + return get_dump_mem_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_finish(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) +{ + GuestPhysBlock *block; + uint64_t off; + int64_t size; + + 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); + } + } + off =3D get_dump_mem_size_from_len(block->target_start); + dump_mem(s, block->target_start, buff + off, + get_dump_mem_size_from_len(size)); + } while (!get_next_block(s, block)); + + 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_mem, 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 +443,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 +452,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.32.0