From nobody Sun Apr 28 09:30:29 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 ARC-Seal: i=1; a=rsa-sha256; t=1599730702; cv=none; d=zohomail.com; s=zohoarc; b=n/voLIyr0QSO66e4Y21S2ZSqPkpj5gGYqby1k+kcfuQeT8QBwWV/ej7beVkECmv0gus7z1lt4IW/hLcyowP947LaR/GXi64MCJZI8DuCepofJmSpT4gwEaS+w4sgjRP5V7e34bpEJVkIDN8jWhGbN/duJediwf55A7/SHKiMNW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599730702; 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=s3UdhajvrPAmsDLb+7RgLwyerWtlM1eOhwUZzh7OpUI=; b=gTZzy02eVg4eruTITRuDnJLGml5puVDpTxHEXZ423AFB2k6Ts5L2kyaGjXacFA1cMLjUZKZRXJ0TIRO1yKSGP42zVsei40P6Moeshhysmcbgm5/0q1KYxWv2V52f467vtEPZC5hXPIgtPsoitTsHV8qFowGZjUE540slpTTaeik= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599730702317378.0028828288455; Thu, 10 Sep 2020 02:38:22 -0700 (PDT) Received: from localhost ([::1]:42012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGJ24-0003hr-LM for importer@patchew.org; Thu, 10 Sep 2020 05:38:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ13-00022W-CW; Thu, 10 Sep 2020 05:37:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:15570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ11-0003Qq-3S; Thu, 10 Sep 2020 05:37:17 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08A9Zu7K106608; Thu, 10 Sep 2020 05:37:12 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fhgx84au-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:12 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08A9bCtM109606; Thu, 10 Sep 2020 05:37:12 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fhgx84af-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:12 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08A9bAWX004235; Thu, 10 Sep 2020 09:37:11 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma03wdc.us.ibm.com with ESMTP id 33cebv2m86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 09:37:11 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08A9bAMY31260946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 09:37:10 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 920DE112066; Thu, 10 Sep 2020 09:37:10 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EE5A112065; Thu, 10 Sep 2020 09:37:10 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.156.134]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 10 Sep 2020 09:37:10 +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=s3UdhajvrPAmsDLb+7RgLwyerWtlM1eOhwUZzh7OpUI=; b=jUDYdGALvrRpR4TBjIZiTrKUTciRtR6GNu8uIiCHNxbZEF4OsoucXLnIkqZ/Qu82NRAk az/C2Y13LRMbXUARI0Oje2dKjNToFL8If/+qq6WTLhTRUISTnAWU6/KGgC13LF8XZxSw 4N+/mmEItoJqroUpGRs5bYKIqYLixvOZqpqak/qoEWvHMCyaymqT/Nd6mZvJdz6IA/zq 4uiShyLOvh8VkyqEkmrZbKbshkKdYa59l0vbBvW/P2YzzyhPwQ7Uq5C+MknnELpRkQVz mlYsi5a96ymDwaNs69On04JVEUvicJtbTDTHmnXGoufqRQ3Mgxo2FJC6yPYtEo38ox0/ Xg== From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 1/8] s390/sclp: get machine once during read scp/cpu info Date: Thu, 10 Sep 2020 05:36:48 -0400 Message-Id: <20200910093655.255774-2-walling@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910093655.255774-1-walling@linux.ibm.com> References: <20200910093655.255774-1-walling@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-10_01:2020-09-10, 2020-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 malwarescore=0 impostorscore=0 spamscore=0 clxscore=1015 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100085 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=walling@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 05:37:13 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, sumanthk@linux.ibm.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Functions within read scp/cpu info will need access to the machine state. Let's make a call to retrieve the machine state once and pass the appropriate data to the respective functions. Signed-off-by: Collin Walling Reviewed-by: David Hildenbrand Reviewed-by: Thomas Huth Reviewed-by: Janosch Frank Reviewed-by: Cornelia Huck --- hw/s390x/sclp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index a0ce444b4b..28b973de8f 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -49,9 +49,8 @@ static inline bool sclp_command_code_valid(uint32_t code) return false; } =20 -static void prepare_cpu_entries(SCLPDevice *sclp, CPUEntry *entry, int *co= unt) +static void prepare_cpu_entries(MachineState *ms, CPUEntry *entry, int *co= unt) { - MachineState *ms =3D MACHINE(qdev_get_machine()); uint8_t features[SCCB_CPU_FEATURE_LEN] =3D { 0 }; int i; =20 @@ -77,7 +76,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) IplParameterBlock *ipib =3D s390_ipl_get_iplb(); =20 /* CPU information */ - prepare_cpu_entries(sclp, read_info->entries, &cpu_count); + prepare_cpu_entries(machine, read_info->entries, &cpu_count); read_info->entries_cpu =3D cpu_to_be16(cpu_count); read_info->offset_cpu =3D cpu_to_be16(offsetof(ReadInfo, entries)); read_info->highest_cpu =3D cpu_to_be16(machine->smp.max_cpus - 1); @@ -132,10 +131,11 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *scc= b) /* Provide information about the CPU */ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *sccb) { + MachineState *machine =3D MACHINE(qdev_get_machine()); ReadCpuInfo *cpu_info =3D (ReadCpuInfo *) sccb; int cpu_count; =20 - prepare_cpu_entries(sclp, cpu_info->entries, &cpu_count); + prepare_cpu_entries(machine, cpu_info->entries, &cpu_count); cpu_info->nr_configured =3D cpu_to_be16(cpu_count); cpu_info->offset_configured =3D cpu_to_be16(offsetof(ReadCpuInfo, entr= ies)); cpu_info->nr_standby =3D cpu_to_be16(0); --=20 2.26.2 From nobody Sun Apr 28 09:30:29 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 ARC-Seal: i=1; a=rsa-sha256; t=1599730704; cv=none; d=zohomail.com; s=zohoarc; b=WeY/jYQ0n6+yOnfDg4GvIFuucE9Yzxeb3HW5+vru1YYLlSHowJaXinIM+4v8I7oc5/hkHTnhFZsEcWLuS0G+OB7AE7qNFMWJTry/XfULZjxuej3QleMyBOX63ij8qdO7I8RPLQCPoEAziWqtFqHtSjb030RfJogT1n+udKhuhQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599730704; 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=0mV/AZK/BmNAaOHlJLrTxbCKSR4rbSoMfQGazJoTM00=; b=Hn1tzc9uClIM6xqJVhx2dnc1Q6+Oob85JVX0s7ViDYK2ITpAHY86GNjwO1rX+izuuGse/Hl0ecN871hCFEVBQLRFrFqaQfQkBopHYz8eNgq70edhM29QyB9uSpV8te/hzEJdZAlW5Fy1woy9yJ+bZNF11VU/ca6JHJcV2MSzipI= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599730704479856.1748860344578; Thu, 10 Sep 2020 02:38:24 -0700 (PDT) Received: from localhost ([::1]:42256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGJ26-0003oq-Tr for importer@patchew.org; Thu, 10 Sep 2020 05:38:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35142) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ16-000246-DP; Thu, 10 Sep 2020 05:37:20 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49156) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ11-0003RH-Pq; Thu, 10 Sep 2020 05:37:20 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08A9Xd0V114686; Thu, 10 Sep 2020 05:37:14 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fhgkr8b5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:14 -0400 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08A9Y2KY115180; Thu, 10 Sep 2020 05:37:13 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fhgkr895-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:13 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08A9VXoL020663; Thu, 10 Sep 2020 09:37:11 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma02wdc.us.ibm.com with ESMTP id 33c2a9e84q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 09:37:11 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08A9bBNt48824812 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 09:37:11 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E9433112062; Thu, 10 Sep 2020 09:37:10 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C8EF112069; Thu, 10 Sep 2020 09:37:10 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.156.134]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 10 Sep 2020 09:37:10 +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=0mV/AZK/BmNAaOHlJLrTxbCKSR4rbSoMfQGazJoTM00=; b=eP3tl01rvVujbwZbX2/Dcb4vrWGR98MqWo/8yH0VfOyc5BWvV0asIg47uoCWLv0QuS+4 fC6qZJrXbKySPpq/eBmrooisDLk7BIqP+DyQ+djudJY4B2wCWFLtQSs8ahfJfJg/rlZ0 pW8u/cbD3CnejkyVlgNaYNbZW/9Jwqi9FM/qPwLZXWNhzEaa4jcSdz0kdfaQ0d8E2/3w qKF5HniJ1nIfZxsz2MyWPnThFdTpB2U5jOrsaoDbU79/lUBmX7qQKspe5dLiu4ncrWvb B8nDC6XxKChS3oK6sEglpBw4XHYIh0GrtI81aTnuUtZP7qpZh6EklOnRFyEp+DFTyPBY jw== From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 2/8] s390/sclp: rework sclp boundary checks Date: Thu, 10 Sep 2020 05:36:49 -0400 Message-Id: <20200910093655.255774-3-walling@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910093655.255774-1-walling@linux.ibm.com> References: <20200910093655.255774-1-walling@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-10_01:2020-09-10, 2020-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 adultscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100088 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=walling@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 05:37:14 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, sumanthk@linux.ibm.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Rework the SCLP boundary check to account for different SCLP commands (eventually) allowing different boundary sizes. Signed-off-by: Collin Walling Acked-by: Janosch Frank Reviewed-by: Cornelia Huck --- hw/s390x/sclp.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 28b973de8f..69a8724dc7 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -49,6 +49,18 @@ static inline bool sclp_command_code_valid(uint32_t code) return false; } =20 +static bool sccb_verify_boundary(uint64_t sccb_addr, uint16_t len) +{ + uint64_t sccb_max_addr =3D sccb_addr + be16_to_cpu(len) - 1; + uint64_t sccb_boundary =3D (sccb_addr & PAGE_MASK) + PAGE_SIZE; + + if (sccb_max_addr < sccb_boundary) { + return true; + } + + return false; +} + static void prepare_cpu_entries(MachineState *ms, CPUEntry *entry, int *co= unt) { uint8_t features[SCCB_CPU_FEATURE_LEN] =3D { 0 }; @@ -229,6 +241,11 @@ int sclp_service_call_protected(CPUS390XState *env, ui= nt64_t sccb, goto out_write; } =20 + if (!sccb_verify_boundary(sccb, work_sccb.h.length)) { + work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_VI= OLATION); + goto out_write; + } + sclp_c->execute(sclp, &work_sccb, code); out_write: s390_cpu_pv_mem_write(env_archcpu(env), 0, &work_sccb, @@ -274,7 +291,7 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb= , uint32_t code) goto out_write; } =20 - if ((sccb + be16_to_cpu(work_sccb.h.length)) > ((sccb & PAGE_MASK) + P= AGE_SIZE)) { + if (!sccb_verify_boundary(sccb, work_sccb.h.length)) { work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_VI= OLATION); goto out_write; } --=20 2.26.2 From nobody Sun Apr 28 09:30:29 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 ARC-Seal: i=1; a=rsa-sha256; t=1599730780; cv=none; d=zohomail.com; s=zohoarc; b=aQgco1GrTmtdvYcWLkbmRairKIiLT/eS/eX9+eMHG7EbGYOViMYnx+pprtA+WLNv9NgEjGZAYFPNfGo6Q1HunAZLBcuEDal4XA0oQZmnLgT5CgO8BkzZoBctQnsgRlUpHygufjoAJ95sTp+VcyB92ZCsqfV5mJbzEA23v8Xlhbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599730780; 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=uebDz0qw0RBpt8SJgjy03PUZZR3hKTMdMn+QgrdEyoE=; b=gWGv9ZWOLPlV35YeevYFuaYZW65I2p4kB19mT3dMYWayzY04fYtArRn7uJe+eTwtyJNvxtVwYVOddrjd1uFMwrkIO0YTU3jEqE1ORsuc5xtpUlS1Bn0nOB1R8E4N+4g8HaWEVfi3d3j2+A0LZbzAVvbDiI0FoRzv8TiLVPeVsH4= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599730780640939.7812059560245; Thu, 10 Sep 2020 02:39:40 -0700 (PDT) Received: from localhost ([::1]:49542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGJ3L-0006ij-8e for importer@patchew.org; Thu, 10 Sep 2020 05:39:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35144) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ16-00024U-IL; Thu, 10 Sep 2020 05:37:20 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:61976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ11-0003Qt-71; Thu, 10 Sep 2020 05:37:20 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08A9XaWE098940; Thu, 10 Sep 2020 05:37:13 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fh2hh6dd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:13 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08A9XobE100196; Thu, 10 Sep 2020 05:37:13 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fh2hh6cp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:12 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08A9WKfQ020288; Thu, 10 Sep 2020 09:37:12 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma03dal.us.ibm.com with ESMTP id 33c2a9fww4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 09:37:12 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08A9bBe437552422 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 09:37:11 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4108C112062; Thu, 10 Sep 2020 09:37:11 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF15F112064; Thu, 10 Sep 2020 09:37:10 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.156.134]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 10 Sep 2020 09:37:10 +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=uebDz0qw0RBpt8SJgjy03PUZZR3hKTMdMn+QgrdEyoE=; b=DmAX8Ci3VhCqOZXl68vTFYBFwdB+YmY83MehN8iNvfn//0Af56eq3n7OIsfi+NzA9oih rR4eCkze/enDptagvCgjwVU1k8Bc86FFLfTPa8dnrkx1zhMNs3Mkx9h+pw+rAKoQk77q Zutm1XfaXWhUG9OciHdXKrohvOzFSlOzSxs9uoRA+SPOT4P43zp/VJpXhKu049UP93JP eeNXmT2+pzEq5XrJou/BDca5XMoKxs0wmpCrtwHg6PB0VRdEu983UMOki8Z75pj5YHIx iA+1qrkLH0JBh7wetMowZWpE1cRkMINA+hJEWcwurIE5i4Sc5sfidgmldHvwwWOUJgKe Eg== From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 3/8] s390/sclp: read sccb from mem based on provided length Date: Thu, 10 Sep 2020 05:36:50 -0400 Message-Id: <20200910093655.255774-4-walling@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910093655.255774-1-walling@linux.ibm.com> References: <20200910093655.255774-1-walling@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-10_01:2020-09-10, 2020-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=2 bulkscore=0 adultscore=0 lowpriorityscore=0 phishscore=0 clxscore=1015 malwarescore=0 spamscore=0 mlxlogscore=754 mlxscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100088 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=walling@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 05:37:13 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, sumanthk@linux.ibm.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The header contained within the SCCB passed to the SCLP service call contains the actual length of the SCCB. Instead of allocating a static 4K size for the work sccb, let's allow for a variable size determined by the value in the header. The proper checks are already in place to ensure the SCCB length is sufficent to store a full response and that the length does not cross any explicitly-set boundaries. Signed-off-by: Collin Walling --- hw/s390x/event-facility.c | 2 +- hw/s390x/sclp.c | 58 ++++++++++++++++++++++----------------- include/hw/s390x/sclp.h | 2 +- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 645b4080c5..ed92ce510d 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -213,7 +213,7 @@ static uint16_t handle_sccb_read_events(SCLPEventFacili= ty *ef, SCCB *sccb, =20 event_buf =3D &red->ebh; event_buf->length =3D 0; - slen =3D sizeof(sccb->data); + slen =3D sccb_data_len(sccb); =20 rc =3D SCLP_RC_NO_EVENT_BUFFERS_STORED; =20 diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 69a8724dc7..cb8e2e8ec3 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -231,25 +231,30 @@ int sclp_service_call_protected(CPUS390XState *env, u= int64_t sccb, { SCLPDevice *sclp =3D get_sclp_device(); SCLPDeviceClass *sclp_c =3D SCLP_GET_CLASS(sclp); - SCCB work_sccb; - hwaddr sccb_len =3D sizeof(SCCB); + SCCBHeader header; + SCCB *work_sccb; =20 - s390_cpu_pv_mem_read(env_archcpu(env), 0, &work_sccb, sccb_len); + s390_cpu_pv_mem_read(env_archcpu(env), 0, &header, sizeof(SCCBHeader)); + + work_sccb =3D g_malloc0(header.length); + s390_cpu_pv_mem_read(env_archcpu(env), 0, work_sccb, + be16_to_cpu(header.length)); =20 if (!sclp_command_code_valid(code)) { - work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_INVALID_SCLP_COM= MAND); + work_sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INVALID_SCLP_CO= MMAND); goto out_write; } =20 - if (!sccb_verify_boundary(sccb, work_sccb.h.length)) { - work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_VI= OLATION); + if (!sccb_verify_boundary(sccb, work_sccb->h.length)) { + work_sccb->h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_V= IOLATION); goto out_write; } =20 - sclp_c->execute(sclp, &work_sccb, code); + sclp_c->execute(sclp, work_sccb, code); out_write: - s390_cpu_pv_mem_write(env_archcpu(env), 0, &work_sccb, - be16_to_cpu(work_sccb.h.length)); + s390_cpu_pv_mem_write(env_archcpu(env), 0, work_sccb, + be16_to_cpu(work_sccb->h.length)); + g_free(work_sccb); sclp_c->service_interrupt(sclp, SCLP_PV_DUMMY_ADDR); return 0; } @@ -258,9 +263,8 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb= , uint32_t code) { SCLPDevice *sclp =3D get_sclp_device(); SCLPDeviceClass *sclp_c =3D SCLP_GET_CLASS(sclp); - SCCB work_sccb; - - hwaddr sccb_len =3D sizeof(SCCB); + SCCBHeader header; + SCCB *work_sccb; =20 /* first some basic checks on program checks */ if (env->psw.mask & PSW_MASK_PSTATE) { @@ -274,33 +278,37 @@ int sclp_service_call(CPUS390XState *env, uint64_t sc= cb, uint32_t code) return -PGM_SPECIFICATION; } =20 + /* the header contains the actual length of the sccb */ + cpu_physical_memory_read(sccb, &header, sizeof(SCCBHeader)); + + /* Valid sccb sizes */ + if (be16_to_cpu(header.length) < sizeof(SCCBHeader)) { + return -PGM_SPECIFICATION; + } + /* * we want to work on a private copy of the sccb, to prevent guests * from playing dirty tricks by modifying the memory content after * the host has checked the values */ - cpu_physical_memory_read(sccb, &work_sccb, sccb_len); - - /* Valid sccb sizes */ - if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader)) { - return -PGM_SPECIFICATION; - } + work_sccb =3D g_malloc0(header.length); + cpu_physical_memory_read(sccb, work_sccb, be16_to_cpu(header.length)); =20 if (!sclp_command_code_valid(code)) { - work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_INVALID_SCLP_COM= MAND); + work_sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INVALID_SCLP_CO= MMAND); goto out_write; } =20 - if (!sccb_verify_boundary(sccb, work_sccb.h.length)) { - work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_VI= OLATION); + if (!sccb_verify_boundary(sccb, work_sccb->h.length)) { + work_sccb->h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_V= IOLATION); goto out_write; } =20 - sclp_c->execute(sclp, &work_sccb, code); + sclp_c->execute(sclp, work_sccb, code); out_write: - cpu_physical_memory_write(sccb, &work_sccb, - be16_to_cpu(work_sccb.h.length)); - + cpu_physical_memory_write(sccb, work_sccb, + be16_to_cpu(work_sccb->h.length)); + g_free(work_sccb); sclp_c->service_interrupt(sclp, sccb); =20 return 0; diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index a87ed2a0ab..98c4727984 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -177,7 +177,7 @@ typedef struct IoaCfgSccb { =20 typedef struct SCCB { SCCBHeader h; - char data[SCCB_DATA_LEN]; + char data[]; } QEMU_PACKED SCCB; =20 #define TYPE_SCLP "sclp" --=20 2.26.2 From nobody Sun Apr 28 09:30:29 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 ARC-Seal: i=1; a=rsa-sha256; t=1599730780; cv=none; d=zohomail.com; s=zohoarc; b=B3LNohyaOa2vs1+DsrqIN7W9ou34QAnGH8ltjiykimCg0kiq/597g4J6wSpe5AbUbOPjpoow2yGszkA2R4h9vvc1F7Qp24kad3q2925UAPtO+WOvDXnyEViZIB74u5ZJRd29mXM7D2FGUJISnnehak70H/ws4OPt/EiVfCQAkCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599730780; 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=VDuWfDOZso54m32MolqOBd2q9K6iRzQY2j+wLjWy9U8=; b=i5nAIuBSr+CIji4+IIfeaURXnu8y/u2tJwXnMxVf7MVErm76zu4MImWsRMMykAsjzRSQTz7JqBYPlOiustXnRt91WP9DXzxq1x2YuAs5DEoKJF9jIlkX6McYixxStAfVMVz+/VlgR+JSpNxECd8KFsnUPCsBH55ZFf6sKKrgGFE= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599730780747844.5516843528738; Thu, 10 Sep 2020 02:39:40 -0700 (PDT) Received: from localhost ([::1]:49616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGJ3L-0006kR-CE for importer@patchew.org; Thu, 10 Sep 2020 05:39:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ16-00023M-0Z; Thu, 10 Sep 2020 05:37:20 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:1846) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ11-0003Qy-Dl; Thu, 10 Sep 2020 05:37:19 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08A9XscI085927; Thu, 10 Sep 2020 05:37:13 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgmn1rdq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:13 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08A9XvBD086045; Thu, 10 Sep 2020 05:37:13 -0400 Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgmn1rd2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:13 -0400 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08A9VXUY020660; Thu, 10 Sep 2020 09:37:12 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma02wdc.us.ibm.com with ESMTP id 33c2a9e84v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 09:37:12 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08A9bBks37552430 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 09:37:11 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 91780112066; Thu, 10 Sep 2020 09:37:11 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52134112064; Thu, 10 Sep 2020 09:37:11 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.156.134]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 10 Sep 2020 09:37:11 +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=VDuWfDOZso54m32MolqOBd2q9K6iRzQY2j+wLjWy9U8=; b=jOddsDeKzUbd4YCPbJY5L6GkTjd4BTycdLDg/lcuhC7RRWnRR2mklCzyC9q6FUsrFPd7 etP0vDZTehrl5GoxwFlWanOiaBrYGSygmMKjgn2y9yP15UBw7k1ivYzCSKiGRrgyMMrd CFzDrHTNeFoEdmM+HuNZ9u7hEsUGrLjpi/AyL3HFLsq2NGH9+w5++HcmrWFuYVhBcVYu ETszP6RCAWZX9bqX8orfCMaB7UMzXb2HR/T48fKwK4DRTzUpTORnoMvh4tQluLsWSXY+ AvDTiOjYd29UmhuPdLJUtUJHBvCWCuDDaEBuQb/WojLHbpGfr0CMAsLPePHfrUo1WzuI AA== From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 4/8] s390/sclp: check sccb len before filling in data Date: Thu, 10 Sep 2020 05:36:51 -0400 Message-Id: <20200910093655.255774-5-walling@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910093655.255774-1-walling@linux.ibm.com> References: <20200910093655.255774-1-walling@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-10_01:2020-09-10, 2020-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100088 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=walling@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 05:37:13 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, sumanthk@linux.ibm.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The SCCB must be checked for a sufficient length before it is filled with any data. If the length is insufficient, then the SCLP command is suppressed and the proper response code is set in the SCCB header. While we're at it, let's cleanup the length check by placing the calculation inside a macro. Fixes: 832be0d8a3bb ("s390x: sclp: Report insufficient SCCB length") Signed-off-by: Collin Walling Reviewed-by: Janosch Frank Reviewed-by: David Hildenbrand Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth --- hw/s390x/sclp.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index cb8e2e8ec3..12829bdd05 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -78,6 +78,8 @@ static void prepare_cpu_entries(MachineState *ms, CPUEntr= y *entry, int *count) } } =20 +#define SCCB_REQ_LEN(s, max_cpus) (sizeof(s) + max_cpus * sizeof(CPUEntry)) + /* Provide information about the configuration, CPUs and storage */ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) { @@ -86,6 +88,12 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) int cpu_count; int rnsize, rnmax; IplParameterBlock *ipib =3D s390_ipl_get_iplb(); + int required_len =3D SCCB_REQ_LEN(ReadInfo, machine->possible_cpus->le= n); + + if (be16_to_cpu(sccb->h.length) < required_len) { + sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); + return; + } =20 /* CPU information */ prepare_cpu_entries(machine, read_info->entries, &cpu_count); @@ -95,12 +103,6 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) =20 read_info->ibc_val =3D cpu_to_be32(s390_get_ibc_val()); =20 - if (be16_to_cpu(sccb->h.length) < - (sizeof(ReadInfo) + cpu_count * sizeof(CPUEntry))) { - sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); - return; - } - /* Configuration Characteristic (Extension) */ s390_get_feat_block(S390_FEAT_TYPE_SCLP_CONF_CHAR, read_info->conf_char); @@ -146,18 +148,18 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB= *sccb) MachineState *machine =3D MACHINE(qdev_get_machine()); ReadCpuInfo *cpu_info =3D (ReadCpuInfo *) sccb; int cpu_count; + int required_len =3D SCCB_REQ_LEN(ReadCpuInfo, machine->possible_cpus-= >len); + + if (be16_to_cpu(sccb->h.length) < required_len) { + sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); + return; + } =20 prepare_cpu_entries(machine, cpu_info->entries, &cpu_count); cpu_info->nr_configured =3D cpu_to_be16(cpu_count); cpu_info->offset_configured =3D cpu_to_be16(offsetof(ReadCpuInfo, entr= ies)); cpu_info->nr_standby =3D cpu_to_be16(0); =20 - if (be16_to_cpu(sccb->h.length) < - (sizeof(ReadCpuInfo) + cpu_count * sizeof(CPUEntry))) { - sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); - return; - } - /* The standby offset is 16-byte for each CPU */ cpu_info->offset_standby =3D cpu_to_be16(cpu_info->offset_configured + cpu_info->nr_configured*sizeof(CPUEntry)); --=20 2.26.2 From nobody Sun Apr 28 09:30:29 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 ARC-Seal: i=1; a=rsa-sha256; t=1599730703; cv=none; d=zohomail.com; s=zohoarc; b=axHtxbrQX02+Fz970v+jBO0hNoTzSLPYF3KZfKLT4OWap0zB3K6j0ULYQvFWFQRb7nHgybl06f2e1/fqi2nptORwJeRPT9Z0ZCdW8Rc/slZrFddfpMGNPIdsVmxAKE7AuG3WQVbgVrO50unbN10dEltUprs+PMvhV2DFZTXJdnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599730703; 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=PDHf8dCkmXG13DovvmhG2LBp1crj/INyJtQw6/J2Kqw=; b=IpeTRNhmVy1chItxG48awsNBcgb6xaRNYyrVWvecYchj0WTTJ2oakOgcE3dySVKX69zkHy9cNcrFKlHfGJ/2MaS0QCj5zmsKCJC9Jr8BYmVYZ3Ko/xjtzMn8vCkAeBvwCwV1Ue3Dooh8KDDrRs1C0ffzGSZ6Qo6IXMayaVLNvjg= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599730703240942.7589320616598; Thu, 10 Sep 2020 02:38:23 -0700 (PDT) Received: from localhost ([::1]:42180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGJ25-0003m3-S3 for importer@patchew.org; Thu, 10 Sep 2020 05:38:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35120) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ15-00023D-Od; Thu, 10 Sep 2020 05:37:19 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:65144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ11-0003R2-MK; Thu, 10 Sep 2020 05:37:19 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08A9WDVM037772; Thu, 10 Sep 2020 05:37:14 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgkfacd0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:14 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08A9Wa3M039085; Thu, 10 Sep 2020 05:37:13 -0400 Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgkfacc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:13 -0400 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08A9XWwO027528; Thu, 10 Sep 2020 09:37:12 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma05wdc.us.ibm.com with ESMTP id 33c2a9eahp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 09:37:12 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08A9bC4n16253780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 09:37:12 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 02584112062; Thu, 10 Sep 2020 09:37:12 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A3A6C112063; Thu, 10 Sep 2020 09:37:11 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.156.134]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 10 Sep 2020 09:37:11 +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=PDHf8dCkmXG13DovvmhG2LBp1crj/INyJtQw6/J2Kqw=; b=M3vEPbvz9S3efDdykMmLDPQ2SZpVIwYX120+y3DyOK5HkCMZVZaGlB5tyizIuf1MFyl6 nZ5Tl8ZEr7e7+yCjDDuMe3n79NxbnEKh4xm46ygBYu0lRMTuz+BNMzxN+Si7HpVFgEEg iPKqOrbijw7dOxTlVipOxb9f+KqsCpRfj/v1o9N8XiL+jnjssHNJVAUfMUCUbT75FqA5 W4eu+qDmzpKToGUYSmXmUIkdQ+tGQ3BT9r0UZrGnbqPsz/Iz5ZE4pt9GbzcuzWobadJq akZZfcJwbZEa1oMzNiFKCdhGE5Ffkd4m2El5zurdFDWFCYuZ4av7D44nNr1yIUJyIxYt ng== From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 5/8] s390/sclp: use cpu offset to locate cpu entries Date: Thu, 10 Sep 2020 05:36:52 -0400 Message-Id: <20200910093655.255774-6-walling@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910093655.255774-1-walling@linux.ibm.com> References: <20200910093655.255774-1-walling@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-10_01:2020-09-10, 2020-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100085 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=walling@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 05:37:13 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, sumanthk@linux.ibm.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The start of the CPU entry region in the Read SCP Info response data is denoted by the offset_cpu field. As such, QEMU needs to begin creating entries at this address. This is in preparation for when Read SCP Info inevitably introduces new bytes that push the start of the CPUEntry field further away. Read CPU Info is unlikely to ever change, so let's not bother accounting for the offset there. Signed-off-by: Collin Walling Reviewed-by: Cornelia Huck Reviewed-by: Thomas Huth --- hw/s390x/sclp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 12829bdd05..803fdd5ed4 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -89,6 +89,8 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) int rnsize, rnmax; IplParameterBlock *ipib =3D s390_ipl_get_iplb(); int required_len =3D SCCB_REQ_LEN(ReadInfo, machine->possible_cpus->le= n); + int offset_cpu =3D offsetof(ReadInfo, entries); + CPUEntry *entries_start =3D (void *)sccb + offset_cpu; =20 if (be16_to_cpu(sccb->h.length) < required_len) { sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); @@ -96,9 +98,9 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) } =20 /* CPU information */ - prepare_cpu_entries(machine, read_info->entries, &cpu_count); + prepare_cpu_entries(machine, entries_start, &cpu_count); read_info->entries_cpu =3D cpu_to_be16(cpu_count); - read_info->offset_cpu =3D cpu_to_be16(offsetof(ReadInfo, entries)); + read_info->offset_cpu =3D cpu_to_be16(offset_cpu); read_info->highest_cpu =3D cpu_to_be16(machine->smp.max_cpus - 1); =20 read_info->ibc_val =3D cpu_to_be32(s390_get_ibc_val()); --=20 2.26.2 From nobody Sun Apr 28 09:30:29 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 ARC-Seal: i=1; a=rsa-sha256; t=1599730890; cv=none; d=zohomail.com; s=zohoarc; b=dlycEzxgReUGIJFWaqsIjQyMsEpwhwsUq9CQ5WyS1Ik7mQwdnzyJArVdxD5ojdk7UuD4HbdynFdm5QFoC7dbjbOwZReUU2ee8FF/dhZbhiNKWazjK4exPGrJaRs5QAwEDIdgpLhKT3O4+qvPy3cQUW7GJXHcn8zoidH8BB2M/8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599730890; 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=S6SzECKH5JU2Foafyqoxbj8o4JcCBBC9/OlmJtTNwPo=; b=hynbu7pda1D1tk7rX4JxpLz7mKCMOgTVz1gTfC8pgPUSnwUJjh0waBHAJgZbx41B5YbPF0NUNG7wrqv/l2e/n1No/zqSlxdowAd4+s933DL1M56ejDbYxkXDhxagwvmlfOQGkY8V5f8hD+5fI3vJ+eifNg8dnTum4bpv2UK2rNI= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599730890516112.83160071583438; Thu, 10 Sep 2020 02:41:30 -0700 (PDT) Received: from localhost ([::1]:57738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGJ57-0001gz-2e for importer@patchew.org; Thu, 10 Sep 2020 05:41:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ17-000268-3J; Thu, 10 Sep 2020 05:37:21 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:21740) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ12-0003RB-2D; Thu, 10 Sep 2020 05:37:20 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08A9WE0M037848; Thu, 10 Sep 2020 05:37:14 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgkfacd6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:14 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08A9Wijh039457; Thu, 10 Sep 2020 05:37:14 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgkfaccr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:14 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08A9WKOo020313; Thu, 10 Sep 2020 09:37:13 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma03dal.us.ibm.com with ESMTP id 33c2a9fww7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 09:37:13 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08A9bCaG16057088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 09:37:12 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 675F1112062; Thu, 10 Sep 2020 09:37:12 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 140C6112063; Thu, 10 Sep 2020 09:37:12 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.156.134]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 10 Sep 2020 09:37:11 +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=S6SzECKH5JU2Foafyqoxbj8o4JcCBBC9/OlmJtTNwPo=; b=ltHJSp0cUL/bzx59RAUDqao1/Me7BUG1c9Z3VmE1sijg0rkZU/iEGO+PqIiA2yUk+DDx Wa/+gKM4nyy1ap9suoJsjvQuiFXSikC7ETkHTERo0y4RinLQ7hjEy29b+Edq/wVt48Ar DJ9CCgBv21L9P006tFKmgUjnDfdLk7WV4CtDUdQMPfRqFlAETTr1gIIwlDJ9esZdWKM0 QqqycMm+PTzGEl8OJzzjsk7/AkW7ovx8tkfrlfVivvZCg3B15cpJt17NsX4DBdx/MK/l nbiDZbQyxC/yJtgZC2FqhAK3Yz4W9KTcZdBoYxt9EZApPmxj6QaSblpvwi854RV/BU8x 2A== From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 6/8] s390/sclp: add extended-length sccb support for kvm guest Date: Thu, 10 Sep 2020 05:36:53 -0400 Message-Id: <20200910093655.255774-7-walling@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910093655.255774-1-walling@linux.ibm.com> References: <20200910093655.255774-1-walling@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-10_01:2020-09-10, 2020-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 phishscore=0 lowpriorityscore=0 clxscore=1015 spamscore=0 mlxscore=0 bulkscore=0 suspectscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100085 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=walling@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 05:37:13 X-ACL-Warn: Detected OS = Linux 3.x [generic] [fuzzy] X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, sumanthk@linux.ibm.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As more features and facilities are added to the Read SCP Info (RSCPI) response, more space is required to store them. The space used to store these new features intrudes on the space originally used to store CPU entries. This means as more features and facilities are added to the RSCPI response, less space can be used to store CPU entries. With the Extended-Length SCCB (ELS) facility, a KVM guest can execute the RSCPI command and determine if the SCCB is large enough to store a complete reponse. If it is not large enough, then the required length will be set in the SCCB header. The caller of the SCLP command is responsible for creating a large-enough SCCB to store a complete response. Proper checking should be in place, and the caller should execute the command once-more with the large-enough SCCB. This facility also enables an extended SCCB for the Read CPU Info (RCPUI) command. When this facility is enabled, the boundary violation response cannot be a result from the RSCPI, RSCPI Forced, or RCPUI commands. In order to tolerate kernels that do not yet have full support for this feature, a "fixed" offset to the start of the CPU Entries within the Read SCP Info struct is set to allow for the original 248 max entries when this feature is disabled. Additionally, this is introduced as a CPU feature to protect the guest from migrating to a machine that does not support storing an extended SCCB. This could otherwise hinder the VM from being able to read all available CPU entries after migration (such as during re-ipl). Signed-off-by: Collin Walling Acked-by: Cornelia Huck Reviewed-by: Thomas Huth --- hw/s390x/sclp.c | 43 +++++++++++++++++++++++++---- include/hw/s390x/sclp.h | 1 + target/s390x/cpu_features_def.h.inc | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 8 ++++++ 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 803fdd5ed4..87d468087b 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -49,13 +49,30 @@ static inline bool sclp_command_code_valid(uint32_t cod= e) return false; } =20 -static bool sccb_verify_boundary(uint64_t sccb_addr, uint16_t len) +static bool sccb_verify_boundary(uint64_t sccb_addr, uint16_t len, + uint32_t code) { uint64_t sccb_max_addr =3D sccb_addr + be16_to_cpu(len) - 1; uint64_t sccb_boundary =3D (sccb_addr & PAGE_MASK) + PAGE_SIZE; =20 - if (sccb_max_addr < sccb_boundary) { - return true; + switch (code & SCLP_CMD_CODE_MASK) { + case SCLP_CMDW_READ_SCP_INFO: + case SCLP_CMDW_READ_SCP_INFO_FORCED: + case SCLP_CMDW_READ_CPU_INFO: + /* + * An extended-length SCCB is only allowed for Read SCP/CPU Info a= nd + * is allowed to exceed the 4k boundary. The respective commands w= ill + * set the length field to the required length if an insufficient + * SCCB length is provided. + */ + if (s390_has_feat(S390_FEAT_EXTENDED_LENGTH_SCCB)) { + return true; + } + /* fallthrough */ + default: + if (sccb_max_addr < sccb_boundary) { + return true; + } } =20 return false; @@ -80,6 +97,12 @@ static void prepare_cpu_entries(MachineState *ms, CPUEnt= ry *entry, int *count) =20 #define SCCB_REQ_LEN(s, max_cpus) (sizeof(s) + max_cpus * sizeof(CPUEntry)) =20 +static inline bool ext_len_sccb_supported(SCCBHeader header) +{ + return s390_has_feat(S390_FEAT_EXTENDED_LENGTH_SCCB) && + header.control_mask[2] & SCLP_VARIABLE_LENGTH_RESPONSE; +} + /* Provide information about the configuration, CPUs and storage */ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) { @@ -89,10 +112,15 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) int rnsize, rnmax; IplParameterBlock *ipib =3D s390_ipl_get_iplb(); int required_len =3D SCCB_REQ_LEN(ReadInfo, machine->possible_cpus->le= n); - int offset_cpu =3D offsetof(ReadInfo, entries); + int offset_cpu =3D s390_has_feat(S390_FEAT_EXTENDED_LENGTH_SCCB) ? + offsetof(ReadInfo, entries) : + SCLP_READ_SCP_INFO_FIXED_CPU_OFFSET; CPUEntry *entries_start =3D (void *)sccb + offset_cpu; =20 if (be16_to_cpu(sccb->h.length) < required_len) { + if (ext_len_sccb_supported(sccb->h)) { + sccb->h.length =3D cpu_to_be16(required_len); + } sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); return; } @@ -153,6 +181,9 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *= sccb) int required_len =3D SCCB_REQ_LEN(ReadCpuInfo, machine->possible_cpus-= >len); =20 if (be16_to_cpu(sccb->h.length) < required_len) { + if (ext_len_sccb_supported(sccb->h)) { + sccb->h.length =3D cpu_to_be16(required_len); + } sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); return; } @@ -249,7 +280,7 @@ int sclp_service_call_protected(CPUS390XState *env, uin= t64_t sccb, goto out_write; } =20 - if (!sccb_verify_boundary(sccb, work_sccb->h.length)) { + if (!sccb_verify_boundary(sccb, work_sccb->h.length, code)) { work_sccb->h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_V= IOLATION); goto out_write; } @@ -303,7 +334,7 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb= , uint32_t code) goto out_write; } =20 - if (!sccb_verify_boundary(sccb, work_sccb->h.length)) { + if (!sccb_verify_boundary(sccb, work_sccb->h.length, code)) { work_sccb->h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_V= IOLATION); goto out_write; } diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index 98c4727984..141e57f765 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -110,6 +110,7 @@ typedef struct CPUEntry { uint8_t reserved1; } QEMU_PACKED CPUEntry; =20 +#define SCLP_READ_SCP_INFO_FIXED_CPU_OFFSET 128 typedef struct ReadInfo { SCCBHeader h; uint16_t rnmax; diff --git a/target/s390x/cpu_features_def.h.inc b/target/s390x/cpu_feature= s_def.h.inc index 5942f81f16..1c04cc18f4 100644 --- a/target/s390x/cpu_features_def.h.inc +++ b/target/s390x/cpu_features_def.h.inc @@ -97,6 +97,7 @@ DEF_FEAT(GUARDED_STORAGE, "gs", STFL, 133, "Guarded-stora= ge facility") DEF_FEAT(VECTOR_PACKED_DECIMAL, "vxpd", STFL, 134, "Vector packed decimal = facility") DEF_FEAT(VECTOR_ENH, "vxeh", STFL, 135, "Vector enhancements facility") DEF_FEAT(MULTIPLE_EPOCH, "mepoch", STFL, 139, "Multiple-epoch facility") +DEF_FEAT(EXTENDED_LENGTH_SCCB, "els", STFL, 140, "Extended-length SCCB fac= ility") DEF_FEAT(TEST_PENDING_EXT_INTERRUPTION, "tpei", STFL, 144, "Test-pending-e= xternal-interruption facility") DEF_FEAT(INSERT_REFERENCE_BITS_MULT, "irbm", STFL, 145, "Insert-reference-= bits-multiple facility") DEF_FEAT(MSA_EXT_8, "msa8-base", STFL, 146, "Message-security-assist-exten= sion-8 facility (excluding subfunctions)") diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index 8ddeebc544..6857f657fb 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -522,6 +522,7 @@ static uint16_t full_GEN12_GA1[] =3D { S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL, S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP, + S390_FEAT_EXTENDED_LENGTH_SCCB, }; =20 static uint16_t full_GEN12_GA2[] =3D { diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index f2f75d2a57..a2d5ad78f6 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2456,6 +2456,14 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model= , Error **errp) KVM_S390_VM_CRYPTO_ENABLE_APIE)) { set_bit(S390_FEAT_AP, model->features); } + + /* + * Extended-Length SCCB is handled entirely within QEMU. + * For PV guests this is completely fenced by the Ultravisor, as Servi= ce + * Call error checking and STFLE interpretation are handled via SIE. + */ + set_bit(S390_FEAT_EXTENDED_LENGTH_SCCB, model->features); + /* strip of features that are not part of the maximum model */ bitmap_and(model->features, model->features, model->def->full_feat, S390_FEAT_MAX); --=20 2.26.2 From nobody Sun Apr 28 09:30:29 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 ARC-Seal: i=1; a=rsa-sha256; t=1599730786; cv=none; d=zohomail.com; s=zohoarc; b=m59/NOipK5wbTGfiT8mzFstxwukqBoa2S7TR3mMO9ox9L8A81ckOgNJ00UVutJ3n7Q6H2y721n0nWi5bojzzncCkaTQ/xl1v+sEJRc/vui30aKzcFQSINEbBv+4DgSyAjAbIbLHtCkdTcU46pL/zraI065bKZ82rDmhEmto9oxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599730786; 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=FcGuP/jUD8lNTSAOuOJChyl2Ny2cXN6+D51sFQfrki0=; b=depnxaEmT13kfvBz6H2vCih/OrYRF77OeD8XN8yrYtONtWaPwAm0dfUTx5fOqfmRLKDKJPkz28AnQdtRLycXVclROxKjbOFA8hOPypX7QAzQVpue4RIV30qjCjmBigWtBtSz1ikpEuZhjrUHT3MMqsBzrOTLdBpwtwUjtDLiabE= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599730786580587.9736053173195; Thu, 10 Sep 2020 02:39:46 -0700 (PDT) Received: from localhost ([::1]:50102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGJ3R-0006wq-9q for importer@patchew.org; Thu, 10 Sep 2020 05:39:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ1B-0002Ji-Kg; Thu, 10 Sep 2020 05:37:25 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57210) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ18-0003Sk-Ha; Thu, 10 Sep 2020 05:37:25 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08A9Xt5B085973; Thu, 10 Sep 2020 05:37:21 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgmn1rhn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:20 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08A9XvSJ086038; Thu, 10 Sep 2020 05:37:18 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgmn1rdj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:18 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08A9Vbc4005703; Thu, 10 Sep 2020 09:37:13 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma04wdc.us.ibm.com with ESMTP id 33c2a968u6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 09:37:13 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08A9bC0k16057096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 09:37:12 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B5BC5112066; Thu, 10 Sep 2020 09:37:12 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D0AF112064; Thu, 10 Sep 2020 09:37:12 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.156.134]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 10 Sep 2020 09:37:12 +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=FcGuP/jUD8lNTSAOuOJChyl2Ny2cXN6+D51sFQfrki0=; b=h21AW+JGHKSLv33Cr2MuZLn5WeB0zMiUHjHOHDuE7Quv8+OWO9noayfxzw7iJnSglZ13 7NjaKeMTIWjGKY8hWq3TC3dtoPPNXUUVaZJAH3WOooxphblyNtZhXwj/TEPc24aYzW0q YhQHDTljrJM07t+8V4P72ev3pZvobyoOc1fI32WXsNJoXEM9Ailrf0fFh5MlOK6jY00p vF0FXBJHJ1obTM2gqt/2SC8UXbQPGivj4N3N9j8tE7LG86CTp0xkm0jmbeG+x59uWRY2 MxVHDNmJ2I2OS4Fl+p9HiYn+KqPfGX/qP5bn4CGYuiNNEFil/uC3H53qRPYswT0D8kZT ow== From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 7/8] s390/kvm: header sync for diag318 Date: Thu, 10 Sep 2020 05:36:54 -0400 Message-Id: <20200910093655.255774-8-walling@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910093655.255774-1-walling@linux.ibm.com> References: <20200910093655.255774-1-walling@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-10_01:2020-09-10, 2020-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100088 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=walling@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 05:37:13 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, sumanthk@linux.ibm.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Collin Walling --- linux-headers/asm-s390/kvm.h | 7 +++++-- linux-headers/linux/kvm.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h index 0138ccb0d8..f053b8304a 100644 --- a/linux-headers/asm-s390/kvm.h +++ b/linux-headers/asm-s390/kvm.h @@ -231,11 +231,13 @@ struct kvm_guest_debug_arch { #define KVM_SYNC_GSCB (1UL << 9) #define KVM_SYNC_BPBC (1UL << 10) #define KVM_SYNC_ETOKEN (1UL << 11) +#define KVM_SYNC_DIAG318 (1UL << 12) =20 #define KVM_SYNC_S390_VALID_FIELDS \ (KVM_SYNC_PREFIX | KVM_SYNC_GPRS | KVM_SYNC_ACRS | KVM_SYNC_CRS | \ KVM_SYNC_ARCH0 | KVM_SYNC_PFAULT | KVM_SYNC_VRS | KVM_SYNC_RICCB | \ - KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN) + KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN | \ + KVM_SYNC_DIAG318) =20 /* length and alignment of the sdnx as a power of two */ #define SDNXC 8 @@ -264,7 +266,8 @@ struct kvm_sync_regs { __u8 reserved2 : 7; __u8 padding1[51]; /* riccb needs to be 64byte aligned */ __u8 riccb[64]; /* runtime instrumentation controls block */ - __u8 padding2[192]; /* sdnx needs to be 256byte aligned */ + __u64 diag318; /* diagnose 0x318 info */ + __u8 padding2[184]; /* sdnx needs to be 256byte aligned */ union { __u8 sdnx[SDNXL]; /* state description annex */ struct { diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index a28c366737..a789bfb5a2 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -1031,6 +1031,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_PPC_SECURE_GUEST 181 #define KVM_CAP_HALT_POLL 182 #define KVM_CAP_ASYNC_PF_INT 183 +#define KVM_CAP_S390_DIAG318 184 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 --=20 2.26.2 From nobody Sun Apr 28 09:30:29 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 ARC-Seal: i=1; a=rsa-sha256; t=1599730888; cv=none; d=zohomail.com; s=zohoarc; b=lSFAX+2llkkfTWktBLP7N0SxgsAYY4eZC3vn3ZtbejdeAIC6uN9AUdNTXnRZO9DR/4ux5kjBXYNTeFdOMx0cxZUchT03qYV9rDrvjAjsprtarR55RNcTCDIyD87aeIdc2xDJKduSmmP0GWSeR4ZMl/sIwAiQtRsWlOt3Qv1g4E0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599730888; 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=3D8h/T+aekqUKDrgN19lU+G7gdYjyKQ+sMeH9Y0cAGA=; b=M1NspRVG6Ub8ROktyFMLVl4kILlctdUAI41wBC6U0n1Yh2GfdQTnLQT+D1AtXkXbPj0vxUxyW8wnNMa6of+BA5QldqUjvSow5Gp+H1DvWqFBYQBFMgEMsFbtwYCh806Hv8st2txQwzsQNDiWjLITO7KWQOF69gcxlgudmGpwavQ= ARC-Authentication-Results: i=1; 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 header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599730888896129.07429037015913; Thu, 10 Sep 2020 02:41:28 -0700 (PDT) Received: from localhost ([::1]:57630 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGJ55-0001eR-Jn for importer@patchew.org; Thu, 10 Sep 2020 05:41:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ1A-0002G5-G2; Thu, 10 Sep 2020 05:37:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGJ18-0003Sa-32; Thu, 10 Sep 2020 05:37:24 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08A9XscS085927; Thu, 10 Sep 2020 05:37:20 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgmn1rhb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:20 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08A9XvSH086038; Thu, 10 Sep 2020 05:37:18 -0400 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 33fgmn1rdv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 05:37:18 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08A9bAWY004235; Thu, 10 Sep 2020 09:37:13 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma03wdc.us.ibm.com with ESMTP id 33cebv2m89-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 10 Sep 2020 09:37:13 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08A9bD2349938846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 10 Sep 2020 09:37:13 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 19B6C112064; Thu, 10 Sep 2020 09:37:13 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC0DE112067; Thu, 10 Sep 2020 09:37:12 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.156.134]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 10 Sep 2020 09:37:12 +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=3D8h/T+aekqUKDrgN19lU+G7gdYjyKQ+sMeH9Y0cAGA=; b=mJbiLjcMUzl2MRDyebS9sS58a9YGaxM11crinYy/Rvyl2I/q8HHYRnHCfEi1H5jWJ/cV qRhNKr+WIS7ALra+LJt7UVArWyZ0b35fK6tdZTSR1Pb6NzfBnUTZCD+3oY1zKrFDJl71 Vty3PnH6bkdrPKyTZ1bmbglzmmUgbN5+3nRJvBddPg0I5hk0AS83I6JTYWuM5y7Ym14e H4gqg+a6jF3GbP1hpHxfJeqLWPwwItDYYektaMA03XyvRk+z7dJk5GxlrJ5GwSPM6hS9 503xLDPbCECFbr7NMW2MUaXQ8BVDa0olKMqGrF5PnkoTSuhdBTvV71NmxSvuSq/1aMcz BQ== From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v5 8/8] s390: guest support for diagnose 0x318 Date: Thu, 10 Sep 2020 05:36:55 -0400 Message-Id: <20200910093655.255774-9-walling@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200910093655.255774-1-walling@linux.ibm.com> References: <20200910093655.255774-1-walling@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.687 definitions=2020-09-10_01:2020-09-10, 2020-09-10 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009100088 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=walling@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/10 05:37:13 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, pbonzini@redhat.com, sumanthk@linux.ibm.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" DIAGNOSE 0x318 (diag318) is an s390 instruction that allows the storage of diagnostic information that is collected by the firmware in the case of hardware/firmware service events. QEMU handles the instruction by storing the info in the CPU state. A subsequent register sync will communicate the data to the hypervisor. QEMU handles the migration via a VM State Description. This feature depends on the Extended-Length SCCB (els) feature. If els is not present, then a warning will be printed and the SCLP bit that allows the Linux kernel to execute the instruction will not be set. Availability of this instruction is determined by byte 134 (aka fac134) bit 0 of the SCLP Read Info block. This coincidentally expands into the space used for CPU entries, which means VMs running with the diag318 capability may not be able to read information regarding all CPUs unless the guest kernel supports an extended-length SCCB. This feature is not supported in protected virtualization mode. Signed-off-by: Collin Walling Acked-by: Janosch Frank --- hw/s390x/sclp.c | 5 +++++ include/hw/s390x/sclp.h | 3 +++ target/s390x/cpu.h | 2 ++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.h.inc | 3 +++ target/s390x/cpu_models.c | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 31 +++++++++++++++++++++++++++++ target/s390x/machine.c | 17 ++++++++++++++++ 9 files changed, 64 insertions(+) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 87d468087b..ad5d70e14d 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -139,6 +139,11 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) s390_get_feat_block(S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, read_info->conf_char_ext); =20 + if (s390_has_feat(S390_FEAT_EXTENDED_LENGTH_SCCB)) { + s390_get_feat_block(S390_FEAT_TYPE_SCLP_FAC134, + &read_info->fac134); + } + read_info->facilities =3D cpu_to_be64(SCLP_HAS_CPU_INFO | SCLP_HAS_IOA_RECONFIG); =20 diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index 141e57f765..516f949109 100644 --- a/include/hw/s390x/sclp.h +++ b/include/hw/s390x/sclp.h @@ -133,6 +133,9 @@ typedef struct ReadInfo { uint16_t highest_cpu; uint8_t _reserved5[124 - 122]; /* 122-123 */ uint32_t hmfai; + uint8_t _reserved7[134 - 128]; /* 128-133 */ + uint8_t fac134; + uint8_t _reserved8[144 - 135]; /* 135-143 */ struct CPUEntry entries[]; } QEMU_PACKED ReadInfo; =20 diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 035427521c..f875ebf0f4 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -112,6 +112,8 @@ struct CPUS390XState { uint16_t external_call_addr; DECLARE_BITMAP(emergency_signals, S390_MAX_CPUS); =20 + uint64_t diag318_info; + /* Fields up to this point are cleared by a CPU reset */ struct {} end_reset_fields; =20 diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h index 2a29475493..ef52ffce83 100644 --- a/target/s390x/cpu_features.h +++ b/target/s390x/cpu_features.h @@ -23,6 +23,7 @@ typedef enum { S390_FEAT_TYPE_STFL, S390_FEAT_TYPE_SCLP_CONF_CHAR, S390_FEAT_TYPE_SCLP_CONF_CHAR_EXT, + S390_FEAT_TYPE_SCLP_FAC134, S390_FEAT_TYPE_SCLP_CPU, S390_FEAT_TYPE_MISC, S390_FEAT_TYPE_PLO, diff --git a/target/s390x/cpu_features_def.h.inc b/target/s390x/cpu_feature= s_def.h.inc index 1c04cc18f4..f82b4b5ec1 100644 --- a/target/s390x/cpu_features_def.h.inc +++ b/target/s390x/cpu_features_def.h.inc @@ -122,6 +122,9 @@ DEF_FEAT(SIE_CMMA, "cmma", SCLP_CONF_CHAR_EXT, 1, "SIE:= Collaborative-memory-man DEF_FEAT(SIE_PFMFI, "pfmfi", SCLP_CONF_CHAR_EXT, 9, "SIE: PFMF interpretat= ion facility") DEF_FEAT(SIE_IBS, "ibs", SCLP_CONF_CHAR_EXT, 10, "SIE: Interlock-and-broad= cast-suppression facility") =20 +/* Features exposed via SCLP SCCB Facilities byte 134 (bit numbers relativ= e to byte-134) */ +DEF_FEAT(DIAG_318, "diag318", SCLP_FAC134, 0, "Control program name and ve= rsion codes") + /* Features exposed via SCLP CPU info. */ DEF_FEAT(SIE_F2, "sief2", SCLP_CPU, 4, "SIE: interception format 2 (Virtua= l SIE)") DEF_FEAT(SIE_SKEY, "skey", SCLP_CPU, 5, "SIE: Storage-key facility") diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index c2af226174..9d615f13e7 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -824,6 +824,7 @@ static void check_consistency(const S390CPUModel *model) { S390_FEAT_PTFF_STOE, S390_FEAT_MULTIPLE_EPOCH }, { S390_FEAT_PTFF_STOUE, S390_FEAT_MULTIPLE_EPOCH }, { S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL, S390_FEAT_AP }, + { S390_FEAT_DIAG_318, S390_FEAT_EXTENDED_LENGTH_SCCB }, }; int i; =20 diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index 6857f657fb..a1f0a6f3c6 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -523,6 +523,7 @@ static uint16_t full_GEN12_GA1[] =3D { S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP, S390_FEAT_EXTENDED_LENGTH_SCCB, + S390_FEAT_DIAG_318, }; =20 static uint16_t full_GEN12_GA2[] =3D { diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index a2d5ad78f6..b79feeba9f 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -105,6 +105,7 @@ =20 #define DIAG_TIMEREVENT 0x288 #define DIAG_IPL 0x308 +#define DIAG_SET_CONTROL_PROGRAM_CODES 0x318 #define DIAG_KVM_HYPERCALL 0x500 #define DIAG_KVM_BREAKPOINT 0x501 =20 @@ -602,6 +603,11 @@ int kvm_arch_put_registers(CPUState *cs, int level) cs->kvm_run->kvm_dirty_regs |=3D KVM_SYNC_ETOKEN; } =20 + if (can_sync_regs(cs, KVM_SYNC_DIAG318)) { + cs->kvm_run->s.regs.diag318 =3D env->diag318_info; + cs->kvm_run->kvm_dirty_regs |=3D KVM_SYNC_DIAG318; + } + /* Finally the prefix */ if (can_sync_regs(cs, KVM_SYNC_PREFIX)) { cs->kvm_run->s.regs.prefix =3D env->psa; @@ -741,6 +747,10 @@ int kvm_arch_get_registers(CPUState *cs) } } =20 + if (can_sync_regs(cs, KVM_SYNC_DIAG318)) { + env->diag318_info =3D cs->kvm_run->s.regs.diag318; + } + return 0; } =20 @@ -1601,6 +1611,19 @@ static int handle_sw_breakpoint(S390CPU *cpu, struct= kvm_run *run) return -ENOENT; } =20 +static void handle_diag_318(S390CPU *cpu, struct kvm_run *run) +{ + uint64_t reg =3D (run->s390_sieic.ipa & 0x00f0) >> 4; + uint64_t diag318_info =3D run->s.regs.gprs[reg]; + + cpu->env.diag318_info =3D diag318_info; + + if (can_sync_regs(CPU(cpu), KVM_SYNC_DIAG318)) { + run->s.regs.diag318 =3D diag318_info; + run->kvm_dirty_regs |=3D KVM_SYNC_DIAG318; + } +} + #define DIAG_KVM_CODE_MASK 0x000000000000ffff =20 static int handle_diag(S390CPU *cpu, struct kvm_run *run, uint32_t ipb) @@ -1620,6 +1643,9 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *= run, uint32_t ipb) case DIAG_IPL: kvm_handle_diag_308(cpu, run); break; + case DIAG_SET_CONTROL_PROGRAM_CODES: + handle_diag_318(cpu, run); + break; case DIAG_KVM_HYPERCALL: r =3D handle_hypercall(cpu, run); break; @@ -2464,6 +2490,11 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model= , Error **errp) */ set_bit(S390_FEAT_EXTENDED_LENGTH_SCCB, model->features); =20 + /* DIAGNOSE 0x318 is not supported under protected virtualization */ + if (!s390_is_pv() && kvm_check_extension(kvm_state, KVM_CAP_S390_DIAG3= 18)) { + set_bit(S390_FEAT_DIAG_318, model->features); + } + /* strip of features that are not part of the maximum model */ bitmap_and(model->features, model->features, model->def->full_feat, S390_FEAT_MAX); diff --git a/target/s390x/machine.c b/target/s390x/machine.c index 549bb6c280..5b4e82f1ab 100644 --- a/target/s390x/machine.c +++ b/target/s390x/machine.c @@ -234,6 +234,22 @@ const VMStateDescription vmstate_etoken =3D { } }; =20 +static bool diag318_needed(void *opaque) +{ + return s390_has_feat(S390_FEAT_DIAG_318); +} + +const VMStateDescription vmstate_diag318 =3D { + .name =3D "cpu/diag318", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D diag318_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(env.diag318_info, S390CPU), + VMSTATE_END_OF_LIST() + } +}; + const VMStateDescription vmstate_s390_cpu =3D { .name =3D "cpu", .post_load =3D cpu_post_load, @@ -270,6 +286,7 @@ const VMStateDescription vmstate_s390_cpu =3D { &vmstate_gscb, &vmstate_bpbc, &vmstate_etoken, + &vmstate_diag318, NULL }, }; --=20 2.26.2