From nobody Mon Apr 29 06:31:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1588979433; cv=none; d=zohomail.com; s=zohoarc; b=JtJap/k9YygGfhA8yeR5V6u9y0VmTGSelOVwmh/I8+S6XOgrfrEKIS39TrnrIX7Ly6wqPU8WpIxC+f1bi+53v2NAi39f8Yp8iI/O5Fpb3SO5SaS/QZMNoldwwqdYt0hYP9VAeTjPOXxlHp64KvSfa72INkFhZUT0ZaIcoIWMjn4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588979433; 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=TJM9Zv0Qnl4rwJxbwKpCrOCNctk048NIdOauDp9cEX8=; b=hRCi6+mMTSt0u6dq9lBiupzlHrg6suAykIgDL7jYyLSBjWo7UQRoNZbNT0BQ6fVdcbmWRmR68F3QPxWtG9qU80cuA2Okp+tYMt5AbgAKSrugsTF1OGYCyzgWKs0PCRiNdvRLXPuDnxQ6mEC9khRreziySbcHEDcZzh7SOvYE5zw= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1588979433284731.0185673945464; Fri, 8 May 2020 16:10:33 -0700 (PDT) Received: from localhost ([::1]:34784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXC8W-0005Xq-09 for importer@patchew.org; Fri, 08 May 2020 19:10:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53348) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6z-0003Qj-HB; Fri, 08 May 2020 19:08:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6r-0005o4-5F; Fri, 08 May 2020 19:08:57 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 048N2Vvu112253; Fri, 8 May 2020 19:08:45 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtsrjpb6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:45 -0400 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 048N4Udv122032; Fri, 8 May 2020 19:08:45 -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 30vtsrjpat-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:45 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 048N0PVm021720; Fri, 8 May 2020 23:08:44 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 30s0g7nk5a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 23:08:44 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 048N8hDg52691278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 May 2020 23:08:43 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E705AC05F; Fri, 8 May 2020 23:08:43 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4D615AC060; Fri, 8 May 2020 23:08:43 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.189.36]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 8 May 2020 23:08:43 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v1 1/8] s390/sclp: remove SCLPDevice param from prepare_cpu_entries Date: Fri, 8 May 2020 19:08:16 -0400 Message-Id: <20200508230823.22956-2-walling@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200508230823.22956-1-walling@linux.ibm.com> References: <20200508230823.22956-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.216, 18.0.676 definitions=2020-05-08_19:2020-05-08, 2020-05-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 mlxscore=0 malwarescore=0 clxscore=1015 adultscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080190 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/05/08 19:08:46 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, svens@linux.ibm.com, pbonzini@redhat.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" It was never used in this function, so let's remove it. Signed-off-by: Collin Walling Acked-by: Janosch Frank Reviewed-by: David Hildenbrand --- hw/s390x/sclp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index ede056b3ef..156ffe3223 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -49,7 +49,7 @@ 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(CPUEntry *entry, int *count) { MachineState *ms =3D MACHINE(qdev_get_machine()); uint8_t features[SCCB_CPU_FEATURE_LEN] =3D { 0 }; @@ -77,7 +77,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(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); @@ -135,7 +135,7 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *= sccb) ReadCpuInfo *cpu_info =3D (ReadCpuInfo *) sccb; int cpu_count; =20 - prepare_cpu_entries(sclp, cpu_info->entries, &cpu_count); + prepare_cpu_entries(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.21.1 From nobody Mon Apr 29 06:31:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1588979559; cv=none; d=zohomail.com; s=zohoarc; b=nMomys43FfzvZBAaHgQ3ywTl55C0qdpNhUy0RB7/AYFe8phFkuIy00qJXIQlKyAdS4wF0ZPpAbd1s9ur3PSpM1CADOl46hTTHO/Nc/7ots//9HWqMHlHm9YhnmSWAgEx40zEUcqmsJajxk0XU3GMhf9YDaFRm79phlQOoo/JXPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588979559; 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=PLJuNfZ7Bzg12dIWBDBvfBsIagFnsyfhfblMtTIxXcY=; b=UlbLQOia0oLPe/NZLG38CsU9DwusrKnPMQCpMzWHKoN7JMddo1gS4MCJtGtMsguAd/CvLbfhQko0l7j2n5HK1BOxpBttUxVPUfRkQsVk/hFo3g1DtKFRCvMUwsOlPJwIBf0R4OFqpnpidN/fmCq0l3ugwVQa+RKKTRzUorEqlas= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1588979559866504.10128517772546; Fri, 8 May 2020 16:12:39 -0700 (PDT) Received: from localhost ([::1]:43210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXCAY-0001AR-JK for importer@patchew.org; Fri, 08 May 2020 19:12:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6t-0003Ps-7H; Fri, 08 May 2020 19:08:52 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:19376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6q-0005oJ-92; Fri, 08 May 2020 19:08:50 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 048N26X4037918; Fri, 8 May 2020 19:08:46 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtsk2r2u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:46 -0400 Received: from m0098393.ppops.net (m0098393.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 048N3woE042413; Fri, 8 May 2020 19:08:45 -0400 Received: from ppma01wdc.us.ibm.com (fd.55.37a9.ip4.static.sl-reverse.com [169.55.85.253]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtsk2r2f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:45 -0400 Received: from pps.filterd (ppma01wdc.us.ibm.com [127.0.0.1]) by ppma01wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 048N0QXw005153; Fri, 8 May 2020 23:08:44 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma01wdc.us.ibm.com with ESMTP id 30s0g75gd7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 23:08:44 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 048N8hGm39584124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 May 2020 23:08:43 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BEEEEAC05E; Fri, 8 May 2020 23:08:43 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 861A4AC062; Fri, 8 May 2020 23:08:43 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.189.36]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 8 May 2020 23:08:43 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v1 2/8] s390/sclp: check sccb len before filling in data Date: Fri, 8 May 2020 19:08:17 -0400 Message-Id: <20200508230823.22956-3-walling@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200508230823.22956-1-walling@linux.ibm.com> References: <20200508230823.22956-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.216, 18.0.676 definitions=2020-05-08_19:2020-05-08, 2020-05-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 adultscore=0 bulkscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 phishscore=0 spamscore=0 clxscore=1015 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080190 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/05/08 19:08:46 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, svens@linux.ibm.com, pbonzini@redhat.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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. Signed-off-by: Collin Walling Reviewed-by: Janosch Frank --- hw/s390x/sclp.c | 22 ++++++++++------------ smp.max_cpus | 0 2 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 smp.max_cpus diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 156ffe3223..d08a291e40 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -76,6 +76,11 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) int rnsize, rnmax; IplParameterBlock *ipib =3D s390_ipl_get_iplb(); =20 + if (be16_to_cpu(sccb->h.length) < (sizeof(ReadInfo) + cpu_count * size= of(CPUEntry))) { + sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); + return; + } + /* CPU information */ prepare_cpu_entries(read_info->entries, &cpu_count); read_info->entries_cpu =3D cpu_to_be16(cpu_count); @@ -84,12 +89,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); @@ -135,17 +134,16 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB= *sccb) ReadCpuInfo *cpu_info =3D (ReadCpuInfo *) sccb; int cpu_count; =20 + if (be16_to_cpu(sccb->h.length) < (sizeof(ReadCpuInfo) + cpu_count * s= izeof(CPUEntry))) { + sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); + return; + } + prepare_cpu_entries(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)); diff --git a/smp.max_cpus b/smp.max_cpus new file mode 100644 index 0000000000..e69de29bb2 --=20 2.21.1 From nobody Mon Apr 29 06:31:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1588979621; cv=none; d=zohomail.com; s=zohoarc; b=QLVn3L72VE+N7uGtom/ltX68U8yL/SbAVesxUcpAnH6uaMme+RsbHog6mdUT39LjETFhecHOE+RjoPO4LJUxkYyPcodIRpSrChyNbCqzisv0oKpQiXTQRimibLcLFsO/VR12JFABa8o9X26nY/aHkU7qaKGQgMYZPwLl5vOnV+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588979621; 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=fY8x0NjNQ10fzTDKTYmL1h+d1wI7M4jAHjR8QaTXM7g=; b=KEZ7NtOYbaBSWRjJA7Sr2DK0sh2/VJt7+IikIeP5avcwEypwP+wAkW7fLzg05Xt4B2x34+jSDYDjWLtBTHyd+3pgtVyYvHRqA4WY9xNEMztglJlFDdZZBVoBN50dbudcwqM3bkJufRRMB11wUZnCVDru6BLdD+/RmHvbrchHX9A= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1588979621046394.13861453368804; Fri, 8 May 2020 16:13:41 -0700 (PDT) Received: from localhost ([::1]:48820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXCBX-0003SG-Pe for importer@patchew.org; Fri, 08 May 2020 19:13:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53386) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC71-0003SG-0k; Fri, 08 May 2020 19:08:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52758) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6r-0005op-AI; Fri, 08 May 2020 19:08:58 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 048N1hgK004417; Fri, 8 May 2020 19:08:46 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtsf32ad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:46 -0400 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 048N2Esn008302; Fri, 8 May 2020 19:08:45 -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 30vtsf32a2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:45 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 048N1phw001097; Fri, 8 May 2020 23:08:44 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 30s0g8ay0w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 23:08:44 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 048N8i7g15533042 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 May 2020 23:08:44 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D087AC05E; Fri, 8 May 2020 23:08:44 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C54F0AC05F; Fri, 8 May 2020 23:08:43 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.189.36]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 8 May 2020 23:08:43 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v1 3/8] s390/sclp: rework sclp boundary and length checks Date: Fri, 8 May 2020 19:08:18 -0400 Message-Id: <20200508230823.22956-4-walling@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200508230823.22956-1-walling@linux.ibm.com> References: <20200508230823.22956-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.216, 18.0.676 definitions=2020-05-08_19:2020-05-08, 2020-05-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 bulkscore=0 impostorscore=0 malwarescore=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 spamscore=0 mlxlogscore=999 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080190 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/05/08 19:08:46 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, svens@linux.ibm.com, pbonzini@redhat.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Let's factor out the SCLP boundary and length checks into separate functions. Signed-off-by: Collin Walling --- hw/s390x/sclp.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index d08a291e40..470d5da7a2 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -49,6 +49,34 @@ static inline bool sclp_command_code_valid(uint32_t code) return false; } =20 +static bool check_sccb_boundary_valid(uint64_t sccb_addr, uint32_t code, + SCCB *sccb) +{ + uint64_t current_len =3D sccb_addr + be16_to_cpu(sccb->h.length); + uint64_t allowed_len =3D (sccb_addr & PAGE_MASK) + PAGE_SIZE; + + switch (code & SCLP_CMD_CODE_MASK) { + default: + if (current_len <=3D allowed_len) { + return true; + } + } + sccb->h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_VIOLATION); + return false; +} + +static bool check_sufficient_sccb_len(SCCB *sccb, int size) +{ + MachineState *ms =3D MACHINE(qdev_get_machine()); + int required_len =3D size + ms->possible_cpus->len * sizeof(CPUEntry); + + if (be16_to_cpu(sccb->h.length) < required_len) { + sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); + return false; + } + return true; +} + static void prepare_cpu_entries(CPUEntry *entry, int *count) { MachineState *ms =3D MACHINE(qdev_get_machine()); @@ -76,8 +104,7 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *sccb) int rnsize, rnmax; IplParameterBlock *ipib =3D s390_ipl_get_iplb(); =20 - if (be16_to_cpu(sccb->h.length) < (sizeof(ReadInfo) + cpu_count * size= of(CPUEntry))) { - sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); + if (!check_sufficient_sccb_len(sccb, sizeof(ReadInfo))) { return; } =20 @@ -134,8 +161,7 @@ static void sclp_read_cpu_info(SCLPDevice *sclp, SCCB *= sccb) ReadCpuInfo *cpu_info =3D (ReadCpuInfo *) sccb; int cpu_count; =20 - if (be16_to_cpu(sccb->h.length) < (sizeof(ReadCpuInfo) + cpu_count * s= izeof(CPUEntry))) { - sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); + if (!check_sufficient_sccb_len(sccb, sizeof(ReadCpuInfo))) { return; } =20 @@ -227,6 +253,10 @@ int sclp_service_call_protected(CPUS390XState *env, ui= nt64_t sccb, goto out_write; } =20 + if (!check_sccb_boundary_valid(sccb, code, &work_sccb)) { + goto out_write; + } + sclp_c->execute(sclp, &work_sccb, code); out_write: s390_cpu_pv_mem_write(env_archcpu(env), 0, &work_sccb, @@ -272,8 +302,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)) { - work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_SCCB_BOUNDARY_VI= OLATION); + if (!check_sccb_boundary_valid(sccb, code, &work_sccb)) { goto out_write; } =20 --=20 2.21.1 From nobody Mon Apr 29 06:31:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1588979431; cv=none; d=zohomail.com; s=zohoarc; b=hnknfuvYSN+eKlvTzbc+7TtFsz7sj/owDE86efM2bXQYi+sO8wlp9QDfsbcPFCzjX+ZWWPLhNxnPt+hyWSnExR8mXk3pCIiWALhIcBWrblShmfSyAnQut9VyiV1w5ElAfpiRqOF+k3ELo9Si+n+dVnPQT4qSi8nTLl+UgiQN7B8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588979431; 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=nWrERTf2kklqqvO8VJxWP6nHOtfrRbIgpuaYGtRMnAY=; b=Ic0I7glsiumt1837CwYqIMN6F+FyiwUZ+YS7IKNc32dI/I2IQDi1doFIcA6DFxFRnAc/1oCce9hAkDzv1hIIu2f5tuLLnr3sWEEHR6Uv9X8DWKs6r1M3jcoqp2xwidelXbJhrMQqE20muKNRkbD8wVt5UmxWcQ2twO0IBGF5Whs= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1588979431322145.48183426516323; Fri, 8 May 2020 16:10:31 -0700 (PDT) Received: from localhost ([::1]:34564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXC8T-0005QR-LN for importer@patchew.org; Fri, 08 May 2020 19:10:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6s-0003Oc-An; Fri, 08 May 2020 19:08:50 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6q-0005p3-92; Fri, 08 May 2020 19:08:49 -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 048N3KHG107408; Fri, 8 May 2020 19:08:46 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30wa872bg1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:46 -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 048N4J0t110074; Fri, 8 May 2020 19:08:46 -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 30wa872bfh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:45 -0400 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 048N0P2D021732; Fri, 8 May 2020 23:08:44 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma03wdc.us.ibm.com with ESMTP id 30s0g7nk5e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 23:08:44 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 048N8i7E14418456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 May 2020 23:08:44 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C44CAC059; Fri, 8 May 2020 23:08:44 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 14C03AC060; Fri, 8 May 2020 23:08:44 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.189.36]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 8 May 2020 23:08:44 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v1 4/8] s390/sclp: read sccb from mem based on sccb length Date: Fri, 8 May 2020 19:08:19 -0400 Message-Id: <20200508230823.22956-5-walling@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200508230823.22956-1-walling@linux.ibm.com> References: <20200508230823.22956-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.216, 18.0.676 definitions=2020-05-08_20:2020-05-08, 2020-05-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 priorityscore=1501 suspectscore=0 adultscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080193 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/05/08 19:08:46 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, svens@linux.ibm.com, pbonzini@redhat.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The header of the SCCB contains the actual length of the SCCB. Instead of using a static 4K size, let's allow for a variable size determined by the value set 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/sclp.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index 470d5da7a2..748d04a0e2 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -244,15 +244,16 @@ 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); =20 - s390_cpu_pv_mem_read(env_archcpu(env), 0, &work_sccb, sccb_len); + s390_cpu_pv_mem_read(env_archcpu(env), 0, &work_sccb, sizeof(SCCBHeade= r)); =20 if (!sclp_command_code_valid(code)) { work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_INVALID_SCLP_COM= MAND); goto out_write; } =20 + s390_cpu_pv_mem_read(env_archcpu(env), 0, &work_sccb, work_sccb.h.leng= th); + if (!check_sccb_boundary_valid(sccb, code, &work_sccb)) { goto out_write; } @@ -271,8 +272,6 @@ int sclp_service_call(CPUS390XState *env, uint64_t sccb= , uint32_t code) SCLPDeviceClass *sclp_c =3D SCLP_GET_CLASS(sclp); SCCB work_sccb; =20 - hwaddr sccb_len =3D sizeof(SCCB); - /* first some basic checks on program checks */ if (env->psw.mask & PSW_MASK_PSTATE) { return -PGM_PRIVILEGED; @@ -290,13 +289,16 @@ int sclp_service_call(CPUS390XState *env, uint64_t sc= cb, uint32_t code) * 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); + cpu_physical_memory_read(sccb, &work_sccb, sizeof(SCCBHeader)); =20 /* Valid sccb sizes */ if (be16_to_cpu(work_sccb.h.length) < sizeof(SCCBHeader)) { return -PGM_SPECIFICATION; } =20 + /* the header contains the actual length of the sccb */ + cpu_physical_memory_read(sccb, &work_sccb, work_sccb.h.length); + if (!sclp_command_code_valid(code)) { work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_INVALID_SCLP_COM= MAND); goto out_write; --=20 2.21.1 From nobody Mon Apr 29 06:31:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1588979558; cv=none; d=zohomail.com; s=zohoarc; b=hPhak+NwCLrgExjJrRRbTGfD5ZvF/GtSBCepDTYc6BMQLArsASHnoXwBwPbtwG3p1AWf3ElFu/+/dvvnrfi+W+1ohL14x5L9nP60kjXE0AqKXzAqNEhK+Fr8oemkFPlpuxqMb7DdTx0iViTgJ0wymj4eg5/KZ1e+aJf3A5TGgkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588979558; 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=rPDsA14m0fGKAtg+X0Fe7fVyFier2OSMInfDPkXcIkc=; b=kvC3EBs+Nf9G4SjN9ypB7e2Zv3SkQEZSi1YzDk/CxYW4ZqMmg7R0NCoAYU/dR/n97haWDHJ5xENgtdT3uQwAZ4IxKiVYuwjoKUfpMRGqsspY/rrG0QgytIYgLZw2ZMLDY1AZnCw+TsSYSEh1z5tptGyUDasFCxPmRjdyiumHiw0= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1588979558668681.7825036627131; Fri, 8 May 2020 16:12:38 -0700 (PDT) Received: from localhost ([::1]:43232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXCAX-0001B5-Ca for importer@patchew.org; Fri, 08 May 2020 19:12:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6v-0003QU-3A; Fri, 08 May 2020 19:08:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6q-0005pG-E0; Fri, 08 May 2020 19:08:52 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 048N2VrW112229; Fri, 8 May 2020 19:08:46 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtsrjpbe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:46 -0400 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 048N4pph123946; Fri, 8 May 2020 19:08:46 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtsrjpb8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:46 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 048N3LHF023437; Fri, 8 May 2020 23:08:45 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma04dal.us.ibm.com with ESMTP id 30s0g7txwv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 23:08:45 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 048N8iIm14680906 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 May 2020 23:08:44 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7497EAC062; Fri, 8 May 2020 23:08:44 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51B08AC05E; Fri, 8 May 2020 23:08:44 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.189.36]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 8 May 2020 23:08:44 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v1 5/8] s390/sclp: use cpu offset to locate cpu entries Date: Fri, 8 May 2020 19:08:20 -0400 Message-Id: <20200508230823.22956-6-walling@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200508230823.22956-1-walling@linux.ibm.com> References: <20200508230823.22956-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.216, 18.0.676 definitions=2020-05-08_19:2020-05-08, 2020-05-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 mlxscore=0 malwarescore=0 clxscore=1015 adultscore=0 phishscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080190 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/05/08 19:08:46 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, svens@linux.ibm.com, pbonzini@redhat.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 its 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 --- 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 748d04a0e2..c47bd3b5ab 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -103,15 +103,17 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *scc= b) int cpu_count; int rnsize, rnmax; IplParameterBlock *ipib =3D s390_ipl_get_iplb(); + int offset_cpu =3D offsetof(ReadInfo, entries); + CPUEntry *entries_start =3D (void *)sccb + offset_cpu; =20 if (!check_sufficient_sccb_len(sccb, sizeof(ReadInfo))) { return; } =20 /* CPU information */ - prepare_cpu_entries(read_info->entries, &cpu_count); + prepare_cpu_entries(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.21.1 From nobody Mon Apr 29 06:31:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1588979513; cv=none; d=zohomail.com; s=zohoarc; b=oMCUOoxB17XxRR3P7EbOYAHtLfYBvckOxXEvxmZKBFW5ahLOxNvt70APIwdg66RBfezts8R+Iqf8hyj6cPZeXpp+BCAAheq9GeLACT/ITKthd5ZLZWwTxca7MyRUWLMQdj5tYoDje17+BUwQLJSMIdIx+jIpE1jOS67UKWmuh6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588979513; 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=QW1AQvo4Ts556HB4zJT3XtwjpDnP5bA48OADDkjjgX8=; b=nBjSpoazpYFpWBG73KqncEE7Ot+0prcEl1N2O5enyxvrJoEmhgzFaTRchJy6uFMRDHjvFIgWr+OAd0PEowxEatOhLxLpoPsjQBT/2xNcLvi0ioYVBFfEaFs+I/M+GojaE80IBikaIBQQSGFdTV17NDg4xIYYID8yywXUHAlxbLc= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1588979513638919.6237902425005; Fri, 8 May 2020 16:11:53 -0700 (PDT) Received: from localhost ([::1]:40060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXC9o-0008JS-Da for importer@patchew.org; Fri, 08 May 2020 19:11:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53368) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC70-0003RK-5N; Fri, 08 May 2020 19:08:58 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:16838 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 1jXC6q-0005p8-JW; Fri, 08 May 2020 19:08:57 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 048N2j82015569; Fri, 8 May 2020 19:08:46 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 30vtwd3486-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:46 -0400 Received: from m0098413.ppops.net (m0098413.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 048N4HJg020734; Fri, 8 May 2020 19:08:46 -0400 Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0b-001b2d01.pphosted.com with ESMTP id 30vtwd3480-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:46 -0400 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 048N65js026464; Fri, 8 May 2020 23:08:45 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma02dal.us.ibm.com with ESMTP id 30s0g7jxmk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 23:08:45 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 048N8itL9634080 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 May 2020 23:08:44 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE049AC05E; Fri, 8 May 2020 23:08:44 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 89BA4AC060; Fri, 8 May 2020 23:08:44 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.189.36]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 8 May 2020 23:08:44 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v1 6/8] s390/sclp: add extended-length sccb support for kvm guest Date: Fri, 8 May 2020 19:08:21 -0400 Message-Id: <20200508230823.22956-7-walling@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200508230823.22956-1-walling@linux.ibm.com> References: <20200508230823.22956-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.216, 18.0.676 definitions=2020-05-08_19:2020-05-08, 2020-05-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 impostorscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=0 phishscore=0 clxscore=1015 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080190 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=mx0a-001b2d01.pphosted.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/08 19:08:45 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, svens@linux.ibm.com, pbonzini@redhat.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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. 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. Signed-off-by: Collin Walling --- hw/s390x/sclp.c | 23 +++++++++++++++++++++-- include/hw/s390x/sclp.h | 1 + target/s390x/cpu_features_def.inc.h | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm.c | 4 ++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index c47bd3b5ab..b5c89760e7 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -56,6 +56,18 @@ static bool check_sccb_boundary_valid(uint64_t sccb_addr= , uint32_t code, uint64_t allowed_len =3D (sccb_addr & PAGE_MASK) + PAGE_SIZE; =20 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 RSCPI and RSCPU and= is + * allowed to exceed the 4k boundary. The respective commands will + * 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; + } default: if (current_len <=3D allowed_len) { return true; @@ -72,6 +84,10 @@ static bool check_sufficient_sccb_len(SCCB *sccb, int si= ze) =20 if (be16_to_cpu(sccb->h.length) < required_len) { sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INSUFFICIENT_SCCB_LE= NGTH); + if (s390_has_feat(S390_FEAT_EXTENDED_LENGTH_SCCB) && + sccb->h.control_mask[2] & SCLP_VARIABLE_LENGTH_RESPONSE) { + sccb->h.length =3D required_len; + } return false; } return true; @@ -103,10 +119,13 @@ static void read_SCP_info(SCLPDevice *sclp, SCCB *scc= b) int cpu_count; int rnsize, rnmax; IplParameterBlock *ipib =3D s390_ipl_get_iplb(); - 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 (!check_sufficient_sccb_len(sccb, sizeof(ReadInfo))) { + if (!check_sufficient_sccb_len(sccb, offset_cpu)) { + warn_report("insufficient sccb size to store full read scp info re= sponse"); return; } =20 diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index 822eff4396..ef2d63eae9 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.inc.h b/target/s390x/cpu_feature= s_def.inc.h index 60db28351d..3548d65a69 100644 --- a/target/s390x/cpu_features_def.inc.h +++ b/target/s390x/cpu_features_def.inc.h @@ -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 69881a0da0..380fb81822 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2456,6 +2456,10 @@ 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 */ + 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.21.1 From nobody Mon Apr 29 06:31:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1588979650; cv=none; d=zohomail.com; s=zohoarc; b=MZM8rl+WmThLIvHAHmOXwjxI56Nmr6V290CXEmZcZID7GDqkCKsFPYrxURYl16vs4AQpUQJdS4rskPfxuq2bUslM8FlRFraIRbZSCLIPHfu9FmmRmrl8G4aL1v8j0aNOLGZ5II5l/7aNVYH3yn6EY8pocCx2UqkwD34KLd9jKzM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588979650; 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=ROD56t3+aScKQpM/nscFMigQ+mS99G4bxW2/SswxuGA=; b=QBJw18QfSx845qOia7rph6p2ZYZx5HaRDEgj/U9pGaHs9MQ3OcNULK3C/OTtJIY+MYQh11354LSxtiTuJz/niAOt2cq0ozr/JtLJMPjXNHN0YiDdK6gZHdxOC7spwHKeEHY9Ok0Ec+qvP3t2hsfWdOcAQI9N4sVobeHxV7KG1os= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1588979650337828.5527579245762; Fri, 8 May 2020 16:14:10 -0700 (PDT) Received: from localhost ([::1]:50450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXCC1-0004Nn-1F for importer@patchew.org; Fri, 08 May 2020 19:14:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC71-0003U4-Tq; Fri, 08 May 2020 19:08:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6q-0005sL-UF; Fri, 08 May 2020 19:08:59 -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 048N1vvS040968; Fri, 8 May 2020 19:08:47 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtsh2y1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:47 -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 048N7XhY053108; Fri, 8 May 2020 19:08:46 -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 30vtsh2y1k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:46 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 048N7Eb6025964; Fri, 8 May 2020 23:08:45 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma04wdc.us.ibm.com with ESMTP id 30s0g7ng90-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 23:08:45 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 048N8jH347841740 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 May 2020 23:08:45 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D84AAC05B; Fri, 8 May 2020 23:08:45 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C9257AC064; Fri, 8 May 2020 23:08:44 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.189.36]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 8 May 2020 23:08:44 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v1 7/8] s390/kvm: header sync for diag318 Date: Fri, 8 May 2020 19:08:22 -0400 Message-Id: <20200508230823.22956-8-walling@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200508230823.22956-1-walling@linux.ibm.com> References: <20200508230823.22956-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.216, 18.0.676 definitions=2020-05-08_19:2020-05-08, 2020-05-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080190 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/05/08 19:08:46 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, svens@linux.ibm.com, pbonzini@redhat.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Collin Walling --- linux-headers/asm-s390/kvm.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h index 0138ccb0d8..b661feafdc 100644 --- a/linux-headers/asm-s390/kvm.h +++ b/linux-headers/asm-s390/kvm.h @@ -74,6 +74,7 @@ struct kvm_s390_io_adapter_req { #define KVM_S390_VM_CRYPTO 2 #define KVM_S390_VM_CPU_MODEL 3 #define KVM_S390_VM_MIGRATION 4 +#define KVM_S390_VM_MISC 5 =20 /* kvm attributes for mem_ctrl */ #define KVM_S390_VM_MEM_ENABLE_CMMA 0 @@ -171,6 +172,10 @@ struct kvm_s390_vm_cpu_subfunc { #define KVM_S390_VM_MIGRATION_START 1 #define KVM_S390_VM_MIGRATION_STATUS 2 =20 +/* kvm attributes for KVM_S390_VM_MISC */ +#define KVM_S390_VM_MISC_ENABLE_DIAG318 0 +#define KVM_S390_VM_MISC_DIAG318 1 + /* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs { /* general purpose regs for s390 */ --=20 2.21.1 From nobody Mon Apr 29 06:31:10 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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=1588979563; cv=none; d=zohomail.com; s=zohoarc; b=aBGEeUl42DBcUpqcpE5lwIMfdtCQCcL1U461MeP0YoFWcjMQpmqVVy1DSSReeaSqjFBZv1jeFW6MvM3k1NSlyTdSkSPnHdRVRxQT9LwxBOC682c6DNhJVU6q6LYJU/IIhjglx/pmzi9UjqiguNqgxEf0buDhl8r9MF09eLCIqXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1588979563; 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=mpx0RSAb/npMPwKJqALT//J5sUNspDXu01inuEdVxR8=; b=MIqxCnnuqHePGyriNf4A6Wud78j5QxNsAtKVH1av+m9NZsQvmSmwp37EszB0QcGmltoe5l8c5imZRAySphYcNPC2zJXa5SDtERJP/XDHhw3O/hIEgbrqTnRUlOwUEyjRlw1ulSHN94kPRTA8z2gQhExju71DQYUVqhW6bCQyHxI= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 1588979563762206.88467954426335; Fri, 8 May 2020 16:12:43 -0700 (PDT) Received: from localhost ([::1]:43618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXCAc-0001Ke-C0 for importer@patchew.org; Fri, 08 May 2020 19:12:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC71-0003Sw-Cz; Fri, 08 May 2020 19:08:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59214) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXC6r-0005tI-6w; Fri, 08 May 2020 19:08:59 -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 048N3cXO181546; Fri, 8 May 2020 19:08:47 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtt4b4xv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:47 -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 048N3pWE182106; Fri, 8 May 2020 19:08:47 -0400 Received: from ppma04dal.us.ibm.com (7a.29.35a9.ip4.static.sl-reverse.com [169.53.41.122]) by mx0a-001b2d01.pphosted.com with ESMTP id 30vtt4b4xn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 19:08:47 -0400 Received: from pps.filterd (ppma04dal.us.ibm.com [127.0.0.1]) by ppma04dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 048N0PMH019040; Fri, 8 May 2020 23:08:46 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma04dal.us.ibm.com with ESMTP id 30s0g7txx1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 May 2020 23:08:46 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 048N8jUB47841746 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 May 2020 23:08:45 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70E86AC05F; Fri, 8 May 2020 23:08:45 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 242C3AC05E; Fri, 8 May 2020 23:08:45 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.189.36]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 8 May 2020 23:08:45 +0000 (GMT) From: Collin Walling To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v1 8/8] s390: diagnose 318 info reset and migration support Date: Fri, 8 May 2020 19:08:23 -0400 Message-Id: <20200508230823.22956-9-walling@linux.ibm.com> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200508230823.22956-1-walling@linux.ibm.com> References: <20200508230823.22956-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.216, 18.0.676 definitions=2020-05-08_20:2020-05-08, 2020-05-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 spamscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005080193 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/05/08 19:08:46 X-ACL-Warn: Detected OS = Linux 3.x [generic] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, KHOP_DYNAMIC=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN 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: frankja@linux.ibm.com, david@redhat.com, cohuck@redhat.com, pasic@linux.ibm.com, borntraeger@de.ibm.com, mst@redhat.com, svens@linux.ibm.com, pbonzini@redhat.com, mihajlov@linux.ibm.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The DIAGNOSE 318 (diag318) instruction allows the guest to store diagnostic data that is collected by the firmware in the case of hardware/firmware service events. The instruction is invoked in the Linux kernel and intercepted in KVM. QEMU needs to collect this data for migration so that it is consistent on the destination machine. Availability of this instruction is determined by byte 134, 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 will not be able to read information regarding all CPUs. This feature depends on the Extended-Length SCCB (els) feature. Diag318 is set to 0 during modified clear and load normal resets. This feature is not supported in protected virtualization mode. Signed-off-by: Collin Walling --- hw/s390x/s390-virtio-ccw.c | 45 +++++++++++++++++++++++++++ hw/s390x/sclp.c | 5 +++ include/hw/s390x/s390-virtio-ccw.h | 1 + include/hw/s390x/sclp.h | 3 ++ target/s390x/cpu.c | 19 ++++++++++++ target/s390x/cpu.h | 4 +++ target/s390x/cpu_features.h | 1 + target/s390x/cpu_features_def.inc.h | 3 ++ target/s390x/cpu_models.c | 1 + target/s390x/gen-features.c | 1 + target/s390x/kvm-stub.c | 10 ++++++ target/s390x/kvm.c | 48 +++++++++++++++++++++++++++++ target/s390x/kvm_s390x.h | 3 ++ 13 files changed, 144 insertions(+) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 45292fb5a8..dc4eb20ec8 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -242,6 +242,40 @@ static void s390_create_sclpconsole(const char *type, = Chardev *chardev) qdev_init_nofail(dev); } =20 +static int diag318_post_load(void *opaque, int version_id) +{ + S390CcwMachineState *d =3D opaque; + + s390_set_diag318_info(d->diag318_info); + return 0; +} + +static int diag318_pre_save(void *opaque) +{ + S390CcwMachineState *d =3D opaque; + + s390_get_diag318_info(&d->diag318_info); + return 0; +} + +static bool diag318_needed(void *opaque) +{ + return s390_diag318_is_allowed(); +} + +const VMStateDescription vmstate_diag318 =3D { + .name =3D "vmstate_diag318", + .post_load =3D diag318_post_load, + .pre_save =3D diag318_pre_save, + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D diag318_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT64(diag318_info, S390CcwMachineState), + VMSTATE_END_OF_LIST() + } +}; + static void ccw_init(MachineState *machine) { int ret; @@ -299,6 +333,8 @@ static void ccw_init(MachineState *machine) =20 /* init the TOD clock */ s390_init_tod(); + + vmstate_register(NULL, 0, &vmstate_diag318, machine); } =20 static void s390_cpu_plug(HotplugHandler *hotplug_dev, @@ -404,6 +440,13 @@ static void s390_pv_prepare_reset(S390CcwMachineState = *ms) s390_pv_perf_clear_reset(); } =20 +static void s390_diag318_reset(void) +{ + if (s390_diag318_is_allowed()) { + s390_set_diag318_info(0); + } +} + static void s390_machine_reset(MachineState *machine) { S390CcwMachineState *ms =3D S390_CCW_MACHINE(machine); @@ -440,6 +483,7 @@ static void s390_machine_reset(MachineState *machine) subsystem_reset(); s390_crypto_reset(); s390_pv_prepare_reset(ms); + s390_diag318_reset(); CPU_FOREACH(t) { run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL); } @@ -452,6 +496,7 @@ static void s390_machine_reset(MachineState *machine) */ subsystem_reset(); s390_pv_prepare_reset(ms); + s390_diag318_reset(); CPU_FOREACH(t) { if (t =3D=3D cs) { continue; diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index b5c89760e7..ae3de14e63 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -143,6 +143,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_BYTE_134, + &read_info->byte_134); + } + read_info->facilities =3D cpu_to_be64(SCLP_HAS_CPU_INFO | SCLP_HAS_IOA_RECONFIG); =20 diff --git a/include/hw/s390x/s390-virtio-ccw.h b/include/hw/s390x/s390-vir= tio-ccw.h index cd1dccc6e3..1134da4d75 100644 --- a/include/hw/s390x/s390-virtio-ccw.h +++ b/include/hw/s390x/s390-virtio-ccw.h @@ -30,6 +30,7 @@ typedef struct S390CcwMachineState { bool dea_key_wrap; bool pv; uint8_t loadparm[8]; + uint64_t diag318_info; } S390CcwMachineState; =20 typedef struct S390CcwMachineClass { diff --git a/include/hw/s390x/sclp.h b/include/hw/s390x/sclp.h index ef2d63eae9..b42a6b6f5a 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 byte_134; + uint8_t _reserved8[144 - 135]; /* 135-143 */ struct CPUEntry entries[]; } QEMU_PACKED ReadInfo; =20 diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index f2ccf0a06a..47284a4a62 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -446,6 +446,25 @@ void s390_enable_css_support(S390CPU *cpu) kvm_s390_enable_css_support(cpu); } } + +void s390_get_diag318_info(uint64_t *info) +{ + if (kvm_enabled()) { + kvm_s390_get_diag318_info(info); + } +} + +void s390_set_diag318_info(uint64_t info) +{ + if (kvm_enabled()) { + kvm_s390_set_diag318_info(info); + } +} + +bool s390_diag318_is_allowed(void) +{ + return kvm_enabled() && kvm_s390_diag318_is_allowed(); +} #endif =20 static gchar *s390_gdb_arch_name(CPUState *cs) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 035427521c..db80c1f89f 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -769,6 +769,10 @@ void s390_cmma_reset(void); void s390_enable_css_support(S390CPU *cpu); int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id, int vq, bool assign); +void s390_get_diag318_info(uint64_t *info); +void s390_set_diag318_info(uint64_t info); +bool s390_diag318_is_allowed(void); + #ifndef CONFIG_USER_ONLY unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu); #else diff --git a/target/s390x/cpu_features.h b/target/s390x/cpu_features.h index da695a8346..954544eed7 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_BYTE_134, S390_FEAT_TYPE_SCLP_CPU, S390_FEAT_TYPE_MISC, S390_FEAT_TYPE_PLO, diff --git a/target/s390x/cpu_features_def.inc.h b/target/s390x/cpu_feature= s_def.inc.h index 3548d65a69..01b877d180 100644 --- a/target/s390x/cpu_features_def.inc.h +++ b/target/s390x/cpu_features_def.inc.h @@ -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 Byte 134 (bit numbers relative to byte-1= 34) */ +DEF_FEAT(DIAG318, "diag318", SCLP_BYTE_134, 0, "Control program name and v= ersion 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 7c32180269..c445aa08ee 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -827,6 +827,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_DIAG318, S390_FEAT_EXTENDED_LENGTH_SCCB }, }; int i; =20 diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index 6857f657fb..df90f5a7e8 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_DIAG318, }; =20 static uint16_t full_GEN12_GA2[] =3D { diff --git a/target/s390x/kvm-stub.c b/target/s390x/kvm-stub.c index aa185017a2..669dcbc80b 100644 --- a/target/s390x/kvm-stub.c +++ b/target/s390x/kvm-stub.c @@ -120,3 +120,13 @@ void kvm_s390_stop_interrupt(S390CPU *cpu) void kvm_s390_restart_interrupt(S390CPU *cpu) { } + +int kvm_s390_get_diag318_info(uint64_t *info) +{ + return 0; +} + +int kvm_s390_set_diag318_info(uint64_t info) +{ + return 0; +} diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 380fb81822..839564e83c 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -814,6 +814,44 @@ int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t = tod_low) return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); } =20 +int kvm_s390_get_diag318_info(uint64_t *info) +{ + struct kvm_device_attr attr =3D { + .group =3D KVM_S390_VM_MISC, + .attr =3D KVM_S390_VM_MISC_DIAG318, + .addr =3D (uint64_t)info, + }; + + return kvm_vm_ioctl(kvm_state, KVM_GET_DEVICE_ATTR, &attr); +} + +int kvm_s390_set_diag318_info(uint64_t info) +{ + struct kvm_device_attr attr =3D { + .group =3D KVM_S390_VM_MISC, + .attr =3D KVM_S390_VM_MISC_DIAG318, + .addr =3D (uint64_t)&info, + }; + + return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); +} + +bool kvm_s390_diag318_is_allowed(void) +{ + return s390_has_feat(S390_FEAT_DIAG318) && + s390_has_feat(S390_FEAT_EXTENDED_LENGTH_SCCB); +} + +static int kvm_s390_enable_diag318(void) +{ + struct kvm_device_attr attr =3D { + .group =3D KVM_S390_VM_MISC, + .attr =3D KVM_S390_VM_MISC_ENABLE_DIAG318, + }; + + return kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); +} + /** * kvm_s390_mem_op: * @addr: the logical start address in guest memory @@ -2460,6 +2498,12 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model= , Error **errp) /* Extended-Length SCCB is handled entirely within QEMU */ set_bit(S390_FEAT_EXTENDED_LENGTH_SCCB, model->features); =20 + /* Allow diag318 iff KVM supported and not in PV mode */ + if (!s390_is_pv() && kvm_vm_check_attr(kvm_state, + KVM_S390_VM_MISC, KVM_S390_VM_MISC_DIAG318)) { + set_bit(S390_FEAT_DIAG318, 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); @@ -2528,6 +2572,10 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *mo= del, Error **errp) if (test_bit(S390_FEAT_AP, model->features)) { kvm_s390_configure_apie(true); } + + if (kvm_s390_diag318_is_allowed()) { + kvm_s390_enable_diag318(); + } } =20 void kvm_s390_restart_interrupt(S390CPU *cpu) diff --git a/target/s390x/kvm_s390x.h b/target/s390x/kvm_s390x.h index 6ab17c81b7..d7666fbd55 100644 --- a/target/s390x/kvm_s390x.h +++ b/target/s390x/kvm_s390x.h @@ -32,6 +32,9 @@ int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_c= lock); int kvm_s390_get_clock_ext(uint8_t *tod_high, uint64_t *tod_clock); int kvm_s390_set_clock(uint8_t tod_high, uint64_t tod_clock); int kvm_s390_set_clock_ext(uint8_t tod_high, uint64_t tod_clock); +int kvm_s390_get_diag318_info(uint64_t *info); +int kvm_s390_set_diag318_info(uint64_t info); +bool kvm_s390_diag318_is_allowed(void); void kvm_s390_enable_css_support(S390CPU *cpu); int kvm_s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch, int vq, bool assign); --=20 2.21.1