From nobody Mon Feb 9 07:55:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=1569595631; cv=none; d=zoho.com; s=zohoarc; b=YSD0kNwj4LB10BvDwxJ0ddwPTqueaykFdncpb3FJXcPrgBLV+cZlfG+ekiP41cjRqVGp+ZOQQrGV9P5TnSFLtKDPsO5KagZ8dvy3Qw0ntaSuT4pqXViaWx3tQWS2GS1zzfeRBBRIU6u/eQ+xJTj3akwdcknxu9Tb1UYfRQuuhv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569595631; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=6UOqyvJhCkePPM1lPHgcoPavOjPuhhBZlpWTJnzo1q8=; b=LpgT2kDCcotITot9YTUxrEzO2Gqat2OZpN/kWJjxYYryjjbzu6Ezh6axcTRqU0e9b/Za7JYKR2087cfgKda6HQUM8vHmlwW+7IlB/eHxmTYk5K2TkY7gA2A5VpMOjkgMsmqNgR1eIYUmPUJuKBdJ+eojes8HlmEFBU2IdfSihAg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1569595631477168.27113762641727; Fri, 27 Sep 2019 07:47:11 -0700 (PDT) Received: from localhost ([::1]:51914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDrWV-0005Tn-JX for importer@patchew.org; Fri, 27 Sep 2019 10:47:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36800) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iDqNM-0005Qd-0R for qemu-devel@nongnu.org; Fri, 27 Sep 2019 09:33:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iDqNK-0001zL-D9 for qemu-devel@nongnu.org; Fri, 27 Sep 2019 09:33:35 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:21970 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iDqNK-0001yM-7u for qemu-devel@nongnu.org; Fri, 27 Sep 2019 09:33:34 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8RDWglK117570 for ; Fri, 27 Sep 2019 09:33:31 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v9jpr1xef-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 27 Sep 2019 09:33:31 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 27 Sep 2019 14:33:30 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 27 Sep 2019 14:33:26 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8RDXOFu46989336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 27 Sep 2019 13:33:24 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A16CF42047; Fri, 27 Sep 2019 13:33:24 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 50B5342042; Fri, 27 Sep 2019 13:33:24 +0000 (GMT) Received: from p-imbrenda.boeblingen.de.ibm.com (unknown [9.152.224.39]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 27 Sep 2019 13:33:24 +0000 (GMT) From: Claudio Imbrenda To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [PATCH v2 1/4] s390x: sclp: refactor invalid command check Date: Fri, 27 Sep 2019 15:33:20 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1569591203-15258-1-git-send-email-imbrenda@linux.ibm.com> References: <1569591203-15258-1-git-send-email-imbrenda@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19092713-0020-0000-0000-000003725099 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19092713-0021-0000-0000-000021C821B0 Message-Id: <1569591203-15258-2-git-send-email-imbrenda@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-09-27_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909270127 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 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, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Janosch Frank Invalid command checking has to be done before the boundary check, refactoring it now allows to insert the boundary check at the correct place later. Signed-off-by: Janosch Frank Reviewed-by: Jason J. Herne Reviewed-by: David Hildenbrand --- hw/s390x/event-facility.c | 3 --- hw/s390x/sclp.c | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c index 797ecbb..6620569 100644 --- a/hw/s390x/event-facility.c +++ b/hw/s390x/event-facility.c @@ -377,9 +377,6 @@ static void command_handler(SCLPEventFacility *ef, SCCB= *sccb, uint64_t code) case SCLP_CMD_WRITE_EVENT_MASK: write_event_mask(ef, sccb); break; - default: - sccb->h.response_code =3D cpu_to_be16(SCLP_RC_INVALID_SCLP_COMMAND= ); - break; } } =20 diff --git a/hw/s390x/sclp.c b/hw/s390x/sclp.c index fac7c3b..95ebfe7 100644 --- a/hw/s390x/sclp.c +++ b/hw/s390x/sclp.c @@ -219,8 +219,23 @@ int sclp_service_call(CPUS390XState *env, uint64_t scc= b, uint32_t code) goto out; } =20 - sclp_c->execute(sclp, &work_sccb, code); + 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: + case SCLP_CMDW_CONFIGURE_IOA: + case SCLP_CMDW_DECONFIGURE_IOA: + case SCLP_CMD_READ_EVENT_DATA: + case SCLP_CMD_WRITE_EVENT_DATA: + case SCLP_CMD_WRITE_EVENT_MASK: + break; + default: + work_sccb.h.response_code =3D cpu_to_be16(SCLP_RC_INVALID_SCLP_COM= MAND); + goto out_write; + } =20 + sclp_c->execute(sclp, &work_sccb, code); +out_write: cpu_physical_memory_write(sccb, &work_sccb, be16_to_cpu(work_sccb.h.length)); =20 --=20 2.7.4