From nobody Sat May 4 06:04:27 2024 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=1573789620; cv=none; d=zoho.com; s=zohoarc; b=RBEczHW16D9uq7dPQf/tlV7alOENML0rBA4kOuehcmmVTKg/3lPUcJB1OqThZvCd/i8xCtpg3i+AdJLKwIjFDIPjbUUaok66s7tw9IybRQ21Dxxr6ol4lxMMxRTu3j532m5Z5l/HYSAKlsXxDKKqOWV/f+U7N7LEZN+N0Y9aEGo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573789620; 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; bh=3bj+Gn7K25XRtKcn/9OzM3h5qyPKhkdzGK0oZYpS42I=; b=Tsr609MwPU3RziFnshMwbFgBjm/bVDRgUmza1g0XT2kl9qgCr6ADqdJVx72nqbyftN0irJuTFWFvkfUDAA99KIyVAmI1HIYmaVJZsEmCzKWjxNSb7g45Bi/m2OUdyMk1Ex8mfBeTVZMHP61Kx8y6MI89r4jGnIvt3AIFYBaY3hM= 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 1573789620384632.3285922856675; Thu, 14 Nov 2019 19:47:00 -0800 (PST) Received: from localhost ([::1]:35206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSZX-0001ZX-8r for importer@patchew.org; Thu, 14 Nov 2019 22:46:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44963) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSXW-0008PT-DM for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:44:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVSXV-0001Xo-DC for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:44:54 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:17612) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iVSXV-0001XB-5f for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:44:53 -0500 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 xAF3iRWd054597 for ; Thu, 14 Nov 2019 22:44:51 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2w9jtsr4ew-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Nov 2019 22:44:50 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Nov 2019 03:34:41 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 15 Nov 2019 03:34:39 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAF3Yc7s55115780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2019 03:34:38 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EB625A4053; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9B83A404D; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 97D4BE0193; Fri, 15 Nov 2019 04:34:37 +0100 (CET) From: Eric Farman To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [RFC PATCH v1 1/8] vfio-ccw: Return IOINST_CC_NOT_OPERATIONAL for EIO Date: Fri, 15 Nov 2019 04:34:30 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115033437.37926-1-farman@linux.ibm.com> References: <20191115033437.37926-1-farman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19111503-4275-0000-0000-0000037DDC75 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111503-4276-0000-0000-00003891447C Message-Id: <20191115033437.37926-2-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-14_07:2019-11-14,2019-11-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 mlxscore=0 clxscore=1015 suspectscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150031 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 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: Halil Pasic , Jason Herne , Eric Farman , Cornelia Huck , Jared Rossi 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: Farhan Ali EIO is returned by vfio-ccw mediated device when the backing host subchannel is not operational anymore. So return cc=3D3 back to the guest, rather than returning a unit check. This way the guest can take appropriate action such as issue an 'stsch'. Signed-off-by: Farhan Ali --- hw/vfio/ccw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 6863f6c69f..0919ddbeb8 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -114,6 +114,7 @@ again: return IOINST_CC_BUSY; case -ENODEV: case -EACCES: + case -EIO: return IOINST_CC_NOT_OPERATIONAL; case -EFAULT: default: --=20 2.17.1 From nobody Sat May 4 06:04:27 2024 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=1573788998; cv=none; d=zoho.com; s=zohoarc; b=D36dH6xzaTgsyCCSIkopLQwwzdf5Z2AGSEQeL3fVAa+xwehAb0eEOhgJpNHiSb8htdXcGHnl+tPXnNvNXz6Oho/auPjjLX8EXzGefcZHK0E/zu1xd/9L3Y48UARZgzeYFj1M3RQQ5iu37tyYexefN3dASIFG90x3IL/RtRovxPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573788998; 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; bh=E1nHYdUmmzoF3wHJFXNBeAlMz/y2x+qjj452pn1yZ5U=; b=cK2GaE2uCXkxthSZij1do0mcFm5o7ciFISWqSbC1/6zz5u89+AMcZd0r2qvQpe9QnY2hrSK6yzhUJkxNJT9U2MnNII0G6GAwPIrDSOQoyLICfMDkC7O5iOsGEOS5Qh/sS3wtMzRyBtj5GFHDVJ/DTSQeQf1jS3lux5GPZtbCgIg= 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 1573788998134586.6090571214335; Thu, 14 Nov 2019 19:36:38 -0800 (PST) Received: from localhost ([::1]:35130 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSPP-0004co-1h for importer@patchew.org; Thu, 14 Nov 2019 22:36:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44016) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSOT-00042H-St for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:35:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVSOS-0003Fo-R3 for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:35:33 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:65144 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 1iVSOS-0003AW-Md for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:35:32 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAF3YT2L117971 for ; Thu, 14 Nov 2019 22:35:24 -0500 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2w9jtv6qbx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Nov 2019 22:35:24 -0500 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Nov 2019 03:34:40 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) 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, 15 Nov 2019 03:34:39 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAF3Ycq152101186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2019 03:34:38 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ED89BA4055; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBE49A4051; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 9A9FCE01E7; Fri, 15 Nov 2019 04:34:37 +0100 (CET) From: Eric Farman To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [RFC PATCH v1 2/8] vfio-ccw: Don't inject an I/O interrupt if the subchannel is not enabled Date: Fri, 15 Nov 2019 04:34:31 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115033437.37926-1-farman@linux.ibm.com> References: <20191115033437.37926-1-farman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19111503-0020-0000-0000-000003865014 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111503-0021-0000-0000-000021DC69D2 Message-Id: <20191115033437.37926-3-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-14_07:2019-11-14,2019-11-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=932 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150029 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: Halil Pasic , Jason Herne , Eric Farman , Cornelia Huck , Jared Rossi 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: Farhan Ali According to PoPs, when the SCHIB.PMCW bit 8 is 0 status presented by the device is not made available to the program. So don't inject an interrupt in the guest if the guest OS has not enabled the subchannel. Signed-off-by: Farhan Ali Signed-off-by: Eric Farman --- Notes: v0->v1: [EF] - Update commit message, as the bit in question is bit 8 not 15 hw/vfio/ccw.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 0919ddbeb8..0590a6f512 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -230,6 +230,11 @@ static void vfio_ccw_io_notifier_handler(void *opaque) return; } =20 + /* Virtual subchannel is not enabled */ + if (!(schib->pmcw.flags & PMCW_FLAGS_MASK_ENA)) { + return; + } + size =3D pread(vcdev->vdev.fd, region, vcdev->io_region_size, vcdev->io_region_offset); if (size =3D=3D -1) { --=20 2.17.1 From nobody Sat May 4 06:04:27 2024 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=1573789091; cv=none; d=zoho.com; s=zohoarc; b=KAK22ALclDFFiUu+nvP591Hh19Sv8hgm51BUCYevrFH05U8cgGgPJ06CuwnIm/rSDT5H1SoHlmYW7CAnvwwIcARJ/nNNc4UqFK8rDR8+xxcWFpwB4sr+uNilr9KbaOqXzV4zPdTnNPwahDcLKHNIsr5Uyjuqi8UDAfnUkmNhvpM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573789091; 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; bh=KQVNZYDoyWAogV+DCIqUACNZOTJ8TMqBnwI/ZjryIF8=; b=f3CjAYUSR2gGx8IHhVh9hZ7mcfGUmRYnTexB27sdqdvoJouba7Lbi+aFBebQICtJ6pl/xFCH9T5f2ujUDLLBZozAQlOU2WxHEEnHzLqlvHi8FOkYNQZ6K85vXOlG59Wc4EgqwvbMYN0bzu8Rq3MiM3Q/evSTnoUiIQeGsRnyaCc= 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 157378909100627.89939633210429; Thu, 14 Nov 2019 19:38:11 -0800 (PST) Received: from localhost ([::1]:35148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSQy-00066x-2K for importer@patchew.org; Thu, 14 Nov 2019 22:38:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44225) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSPu-0005ET-7k for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:37:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVSPs-0003fO-DD for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:37:02 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:4230) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iVSPs-0003ey-5c for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:37:00 -0500 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 xAF3YXCT110737 for ; Thu, 14 Nov 2019 22:36:58 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2w9jtsq86v-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Nov 2019 22:36:56 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Nov 2019 03:34:41 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 15 Nov 2019 03:34:39 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAF3Y1dq39125348 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2019 03:34:01 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EFF6311C052; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC2DA11C04A; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 9D1A5E01F2; Fri, 15 Nov 2019 04:34:37 +0100 (CET) From: Eric Farman To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [RFC PATCH v1 3/8] linux-headers: update Date: Fri, 15 Nov 2019 04:34:32 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115033437.37926-1-farman@linux.ibm.com> References: <20191115033437.37926-1-farman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19111503-0028-0000-0000-000003B7041A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111503-0029-0000-0000-0000247A13B3 Message-Id: <20191115033437.37926-4-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-14_07:2019-11-14,2019-11-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 mlxlogscore=987 impostorscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 mlxscore=0 clxscore=1015 suspectscore=0 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150029 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 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: Halil Pasic , Jason Herne , Eric Farman , Cornelia Huck , Jared Rossi 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: Farhan Ali Signed-off-by: Farhan Ali Signed-off-by: Eric Farman --- Notes: v0->v1: [EF] - Run scripts/update-linux-headers.sh properly, but do not add resulting changes to linux-headers/asm-mips/ linux-headers/linux/vfio.h | 3 +++ linux-headers/linux/vfio_ccw.h | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index fb10370d29..9e227348b3 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -378,6 +378,8 @@ struct vfio_region_gfx_edid { =20 /* sub-types for VFIO_REGION_TYPE_CCW */ #define VFIO_REGION_SUBTYPE_CCW_ASYNC_CMD (1) +#define VFIO_REGION_SUBTYPE_CCW_SCHIB (2) +#define VFIO_REGION_SUBTYPE_CCW_CRW (3) =20 /* * The MSIX mappable capability informs that MSIX data of a BAR can be mma= pped @@ -577,6 +579,7 @@ enum { =20 enum { VFIO_CCW_IO_IRQ_INDEX, + VFIO_CCW_CRW_IRQ_INDEX, VFIO_CCW_NUM_IRQS }; =20 diff --git a/linux-headers/linux/vfio_ccw.h b/linux-headers/linux/vfio_ccw.h index fcc3e69ef5..8654c9afca 100644 --- a/linux-headers/linux/vfio_ccw.h +++ b/linux-headers/linux/vfio_ccw.h @@ -34,4 +34,14 @@ struct ccw_cmd_region { __u32 ret_code; } __attribute__((packed)); =20 +struct ccw_schib_region { +#define SCHIB_AREA_SIZE 52 + __u8 schib_area[SCHIB_AREA_SIZE]; +} __attribute__((packed)); + +struct ccw_crw_region { + __u32 crw0; + __u32 crw1; +} __attribute__((packed)); + #endif --=20 2.17.1 From nobody Sat May 4 06:04:28 2024 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=1573789695; cv=none; d=zoho.com; s=zohoarc; b=cZqm0cwaPAaZkG4Mt25xA/ipd4n1xpfpPJ15DoD9xPNw+pVAMazwdiXoRq30e9bVkEwyWL3/yidnG4TG1CyojRHnND8rBF0v0JBMMCfTY2TwvYbxAQArjSBbP76VUMIdIsq18fwSZ/LyEUnR4hfoFxyZwM0qzPzaJuRADWBa4EA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573789695; 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; bh=A4VMOCnDvPao5xz/w2QslB62zxVQ2QRMdNXMoPWWnAw=; b=NZA9BcaQYg0GXj+jqw5OVPp6IpapQncqLb5Eq70ApdpV2TbzG9Ocy6t6AH02Fq9aGEN+l3IkYKXQOvfGL+ow8eR4TAZWWtv8ezEy8R9xMMzjkwDAaeD3XRbG0ssSoFUP8Hgn8VkoSEkvGmYABeMprW7YEMu3UKAxmH8Xy2lBL0U= 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 1573789695171108.67681824175588; Thu, 14 Nov 2019 19:48:15 -0800 (PST) Received: from localhost ([::1]:35216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSaj-0002iC-VN for importer@patchew.org; Thu, 14 Nov 2019 22:48:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45111) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSZb-0001od-47 for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:47:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVSZa-0002Zg-1C for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:47:03 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:7744) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iVSZZ-0002ZS-Pw for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:47:01 -0500 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 xAF3iTM4054759 for ; Thu, 14 Nov 2019 22:47:01 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2w9jtsr5cb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Nov 2019 22:47:00 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Nov 2019 03:34:42 -0000 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 15 Nov 2019 03:34:39 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAF3YcrL39191026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2019 03:34:38 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0931542049; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E80C742042; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 15 Nov 2019 03:34:37 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id 9F920E021D; Fri, 15 Nov 2019 04:34:37 +0100 (CET) From: Eric Farman To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [RFC PATCH v1 4/8] vfio-ccw: Refactor cleanup of regions Date: Fri, 15 Nov 2019 04:34:33 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115033437.37926-1-farman@linux.ibm.com> References: <20191115033437.37926-1-farman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19111503-0008-0000-0000-0000032F2619 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111503-0009-0000-0000-00004A4E36D6 Message-Id: <20191115033437.37926-5-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-14_07:2019-11-14,2019-11-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 spamscore=0 mlxlogscore=717 impostorscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 mlxscore=0 clxscore=1015 suspectscore=2 malwarescore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150031 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 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: Halil Pasic , Jason Herne , Eric Farman , Cornelia Huck , Jared Rossi 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" While we're at it, add a g_free() for the async_cmd_region that is the last thing currently created. g_free() knows how to handle NULL pointers, so this makes it easier to remember what cleanups need to be performed when new regions are added. Signed-off-by: Eric Farman Reviewed-by: Cornelia Huck --- hw/vfio/ccw.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 0590a6f512..3e32bc1819 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -376,8 +376,7 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, E= rror **errp) vcdev->io_region_size =3D info->size; if (sizeof(*vcdev->io_region) !=3D vcdev->io_region_size) { error_setg(errp, "vfio: Unexpected size of the I/O region"); - g_free(info); - return; + goto out_err; } =20 vcdev->io_region_offset =3D info->offset; @@ -390,15 +389,20 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev,= Error **errp) vcdev->async_cmd_region_size =3D info->size; if (sizeof(*vcdev->async_cmd_region) !=3D vcdev->async_cmd_region_= size) { error_setg(errp, "vfio: Unexpected size of the async cmd regio= n"); - g_free(vcdev->io_region); - g_free(info); - return; + goto out_err; } vcdev->async_cmd_region_offset =3D info->offset; vcdev->async_cmd_region =3D g_malloc0(info->size); } =20 g_free(info); + return; + +out_err: + g_free(vcdev->async_cmd_region); + g_free(vcdev->io_region); + g_free(info); + return; } =20 static void vfio_ccw_put_region(VFIOCCWDevice *vcdev) --=20 2.17.1 From nobody Sat May 4 06:04:28 2024 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=1573790306; cv=none; d=zoho.com; s=zohoarc; b=b96ngPZBBH0heucqRZrj8RNPErjymm64mRfMVS/8RTPrb8G9ViCurJogeHGI4fS+YNqO4dQDzEr7xkpQEv39zLdtPKxNdcpAdmcKHJdDsPC/rsQXaKPoIP8UkDlI2eYCMht71tYeuAW8IJEhaeD0N/QnU/UiZoZlJBCE0WrqY8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573790306; 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; bh=k0R9R4TmHhBeUBkXuF3cC+JOrZxskWJiEBQq9a+czfk=; b=N2Dapm65YK/tGdKjtSBq9dt6hyHH6G3sEEg3yZhLnpF30Dkg3olxNqxL+xdC0n0BpkAw+F3lVmZMyK2JifowBMk87OuABo/DX0EdPZZ7kReBMbbzgVX5VLQRhqvbi8gdJe6Ju1LRyuKZ4N/RnV7JeLaoRDx2yRaWi6OoHpIZnpE= 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 1573790306387583.998442096888; Thu, 14 Nov 2019 19:58:26 -0800 (PST) Received: from localhost ([::1]:35242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSkT-0005zk-Jz for importer@patchew.org; Thu, 14 Nov 2019 22:58:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45949) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSjl-0005YJ-SJ for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:57:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVSjk-0007R5-E0 for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:57:33 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:16278 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 1iVSjk-0007Qd-9l for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:57:32 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAF3YTb3117986 for ; Thu, 14 Nov 2019 22:35:30 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2w9jtv6qgq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Nov 2019 22:35:29 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Nov 2019 03:34:42 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 15 Nov 2019 03:34:39 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAF3Yc6W55115786 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2019 03:34:38 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4BCB5A4053; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30E76A4051; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id A2193E0248; Fri, 15 Nov 2019 04:34:37 +0100 (CET) From: Eric Farman To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [RFC PATCH v1 5/8] vfio-ccw: Add support for the schib region Date: Fri, 15 Nov 2019 04:34:34 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115033437.37926-1-farman@linux.ibm.com> References: <20191115033437.37926-1-farman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19111503-0028-0000-0000-000003B7041C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111503-0029-0000-0000-0000247A13B4 Message-Id: <20191115033437.37926-6-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-14_07:2019-11-14,2019-11-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=2 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150029 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: Halil Pasic , Jason Herne , Eric Farman , Cornelia Huck , Jared Rossi 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: Farhan Ali The schib region can be used to obtain the latest SCHIB from the host passthrough subchannel. Since the guest SCHIB is virtualized, we currently only update the path related information so that the guest is aware of any path related changes when it issues the 'stsch' instruction. Signed-off-by: Farhan Ali Signed-off-by: Eric Farman --- Notes: v0->v1: [EF] - Change various incarnations of "update chp status" to "handle_store", to reflect the STSCH instruction that will drive this code - Remove temporary variable for casting/testing purposes in s390_ccw_store(), and add a block comment of WHY its there. - Add a few comments to vfio_ccw_handle_store() hw/s390x/css.c | 8 ++++-- hw/s390x/s390-ccw.c | 20 +++++++++++++ hw/vfio/ccw.c | 57 +++++++++++++++++++++++++++++++++++++ include/hw/s390x/css.h | 3 +- include/hw/s390x/s390-ccw.h | 1 + target/s390x/ioinst.c | 3 +- 6 files changed, 87 insertions(+), 5 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 844caab408..6ee6a96d75 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -1335,11 +1335,15 @@ static void copy_schib_to_guest(SCHIB *dest, const = SCHIB *src) } } =20 -int css_do_stsch(SubchDev *sch, SCHIB *schib) +IOInstEnding css_do_stsch(SubchDev *sch, SCHIB *schib) { + int ret =3D IOINST_CC_EXPECTED; + + ret =3D s390_ccw_store(sch); + /* Use current status. */ copy_schib_to_guest(schib, &sch->curr_status); - return 0; + return ret; } =20 static void copy_pmcw_from_guest(PMCW *dest, const PMCW *src) diff --git a/hw/s390x/s390-ccw.c b/hw/s390x/s390-ccw.c index 0c5a5b60bd..be0b379338 100644 --- a/hw/s390x/s390-ccw.c +++ b/hw/s390x/s390-ccw.c @@ -51,6 +51,26 @@ int s390_ccw_clear(SubchDev *sch) return cdc->handle_clear(sch); } =20 +IOInstEnding s390_ccw_store(SubchDev *sch) +{ + S390CCWDeviceClass *cdc =3D NULL; + int ret =3D IOINST_CC_EXPECTED; + + /* + * This only applies to passthrough devices, so we can't unconditional= ly + * set this variable like we would for halt/clear. + */ + if (object_dynamic_cast(OBJECT(sch->driver_data), TYPE_S390_CCW)) { + cdc =3D S390_CCW_DEVICE_GET_CLASS(sch->driver_data); + } + + if (cdc && cdc->handle_store) { + ret =3D cdc->handle_store(sch); + } + + return ret; +} + static void s390_ccw_get_dev_info(S390CCWDevice *cdev, char *sysfsdev, Error **errp) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 3e32bc1819..2ff223470f 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -41,6 +41,9 @@ struct VFIOCCWDevice { uint64_t async_cmd_region_size; uint64_t async_cmd_region_offset; struct ccw_cmd_region *async_cmd_region; + uint64_t schib_region_size; + uint64_t schib_region_offset; + struct ccw_schib_region *schib_region; EventNotifier io_notifier; bool force_orb_pfch; bool warned_orb_pfch; @@ -124,6 +127,45 @@ again: } } =20 +static IOInstEnding vfio_ccw_handle_store(SubchDev *sch) +{ + S390CCWDevice *cdev =3D sch->driver_data; + VFIOCCWDevice *vcdev =3D DO_UPCAST(VFIOCCWDevice, cdev, cdev); + SCHIB *schib =3D &sch->curr_status; + struct ccw_schib_region *region =3D vcdev->schib_region; + SCHIB *s =3D (SCHIB *)region->schib_area; + int ret; + + /* schib region not available so nothing else to do */ + if (!region) { + return IOINST_CC_EXPECTED; + } + + memset(region, 0, sizeof(*region)); + ret =3D pread(vcdev->vdev.fd, region, vcdev->schib_region_size, + vcdev->schib_region_offset); + + if (ret =3D=3D -1) { + /* Assume device is damaged, regardless of errno */ + return IOINST_CC_NOT_OPERATIONAL; + } + + /* + * Selectively copy path-related bits of the SCHIB, + * rather than copying the entire struct. + */ + schib->pmcw.pnom =3D s->pmcw.pnom; + schib->pmcw.lpum =3D s->pmcw.lpum; + schib->pmcw.pam =3D s->pmcw.pam; + schib->pmcw.pom =3D s->pmcw.pom; + + if (s->scsw.flags & SCSW_FLAGS_MASK_PNO) { + schib->scsw.flags |=3D SCSW_FLAGS_MASK_PNO; + } + + return IOINST_CC_EXPECTED; +} + static int vfio_ccw_handle_clear(SubchDev *sch) { S390CCWDevice *cdev =3D sch->driver_data; @@ -395,10 +437,23 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev,= Error **errp) vcdev->async_cmd_region =3D g_malloc0(info->size); } =20 + ret =3D vfio_get_dev_region_info(vdev, VFIO_REGION_TYPE_CCW, + VFIO_REGION_SUBTYPE_CCW_SCHIB, &info); + if (!ret) { + vcdev->schib_region_size =3D info->size; + if (sizeof(*vcdev->schib_region) !=3D vcdev->schib_region_size) { + error_setg(errp, "vfio: Unexpected size of the schib region"); + goto out_err; + } + vcdev->schib_region_offset =3D info->offset; + vcdev->schib_region =3D g_malloc(info->size); + } + g_free(info); return; =20 out_err: + g_free(vcdev->schib_region); g_free(vcdev->async_cmd_region); g_free(vcdev->io_region); g_free(info); @@ -407,6 +462,7 @@ out_err: =20 static void vfio_ccw_put_region(VFIOCCWDevice *vcdev) { + g_free(vcdev->schib_region); g_free(vcdev->async_cmd_region); g_free(vcdev->io_region); } @@ -582,6 +638,7 @@ static void vfio_ccw_class_init(ObjectClass *klass, voi= d *data) cdc->handle_request =3D vfio_ccw_handle_request; cdc->handle_halt =3D vfio_ccw_handle_halt; cdc->handle_clear =3D vfio_ccw_handle_clear; + cdc->handle_store =3D vfio_ccw_handle_store; } =20 static const TypeInfo vfio_ccw_info =3D { diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index f46bcafb16..7e3a5e7433 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -218,6 +218,7 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev *s= ub); =20 int s390_ccw_halt(SubchDev *sch); int s390_ccw_clear(SubchDev *sch); +IOInstEnding s390_ccw_store(SubchDev *sch); =20 typedef enum { CSS_IO_ADAPTER_VIRTIO =3D 0, @@ -242,7 +243,7 @@ SubchDev *css_find_subch(uint8_t m, uint8_t cssid, uint= 8_t ssid, uint16_t schid); bool css_subch_visible(SubchDev *sch); void css_conditional_io_interrupt(SubchDev *sch); -int css_do_stsch(SubchDev *sch, SCHIB *schib); +IOInstEnding css_do_stsch(SubchDev *sch, SCHIB *schib); bool css_schid_final(int m, uint8_t cssid, uint8_t ssid, uint16_t schid); IOInstEnding css_do_msch(SubchDev *sch, const SCHIB *schib); IOInstEnding css_do_xsch(SubchDev *sch); diff --git a/include/hw/s390x/s390-ccw.h b/include/hw/s390x/s390-ccw.h index fffb54562f..4a43803ef2 100644 --- a/include/hw/s390x/s390-ccw.h +++ b/include/hw/s390x/s390-ccw.h @@ -37,6 +37,7 @@ typedef struct S390CCWDeviceClass { IOInstEnding (*handle_request) (SubchDev *sch); int (*handle_halt) (SubchDev *sch); int (*handle_clear) (SubchDev *sch); + IOInstEnding (*handle_store) (SubchDev *sch); } S390CCWDeviceClass; =20 #endif diff --git a/target/s390x/ioinst.c b/target/s390x/ioinst.c index c437a1d8c6..63b4c84215 100644 --- a/target/s390x/ioinst.c +++ b/target/s390x/ioinst.c @@ -257,8 +257,7 @@ void ioinst_handle_stsch(S390CPU *cpu, uint64_t reg1, u= int32_t ipb, sch =3D css_find_subch(m, cssid, ssid, schid); if (sch) { if (css_subch_visible(sch)) { - css_do_stsch(sch, &schib); - cc =3D 0; + cc =3D css_do_stsch(sch, &schib); } else { /* Indicate no more subchannels in this css/ss */ cc =3D 3; --=20 2.17.1 From nobody Sat May 4 06:04:28 2024 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=1573789103; cv=none; d=zoho.com; s=zohoarc; b=YHAHQIvqsd5zkln0M23UK4IZRB9xZKBNhfwn0h1k2dWZGbPXbCz4y0JtmRq75PSIFWt1LFOiOEA6+Jp9a69n/3fmLfweAy6NKh3oAiZq3/9VAuf6TQCGQc5GLtHeIDImLXslq7K6d0ivw518kAyMVaS+u4PkTKR2kd4rzZbfJnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573789103; 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; bh=IBKTCkKS0F9p1Jbr+YiJl27rbsWWXpkbnwHOyy9OkSE=; b=Nv9VfvnILlMVm2fJIe4X19kDjmhD+MpOyQGTpYrbgpMC3bvTRrc6gBYvt/8coBUtWUoDygYqkVMdckHQ1IYyTdGIb0W/7BkCfCk1NcsawHMl0lx9epVwbjTBnjpvL+O9XpVqxqcqYjH/R7ehmRes+jIHzKnU0aXz/bzjC3osM5Q= 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 1573789103499461.9239611772381; Thu, 14 Nov 2019 19:38:23 -0800 (PST) Received: from localhost ([::1]:35150 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSRC-0006RK-DO for importer@patchew.org; Thu, 14 Nov 2019 22:38:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44285) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSQH-0005Z0-26 for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:37:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVSQF-0003pr-VD for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:37:25 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:17234 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 1iVSQF-0003pj-Qr for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:37:23 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAF3YTpK117994 for ; Thu, 14 Nov 2019 22:37:23 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2w9jtv6qgf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Nov 2019 22:37:22 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Nov 2019 03:34:42 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 15 Nov 2019 03:34:39 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAF3YceO53280838 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2019 03:34:38 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 514984C044; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3D2FD4C04E; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id A4976E0285; Fri, 15 Nov 2019 04:34:37 +0100 (CET) From: Eric Farman To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [RFC PATCH v1 6/8] vfio-ccw: Add support for the crw region Date: Fri, 15 Nov 2019 04:34:35 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115033437.37926-1-farman@linux.ibm.com> References: <20191115033437.37926-1-farman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19111503-0028-0000-0000-000003B7041B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111503-0029-0000-0000-0000247A13B5 Message-Id: <20191115033437.37926-7-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-14_07:2019-11-14,2019-11-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=2 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150029 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: Halil Pasic , Jason Herne , Eric Farman , Cornelia Huck , Jared Rossi 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: Farhan Ali The crw region can be used to obtain information about Channel Report Words (CRW) from vfio-ccw driver. Currently only channel path related CRWs are passed to QEMU from vfio-ccw driver. Signed-off-by: Farhan Ali Signed-off-by: Eric Farman --- Notes: v0->v1: [EF] - Fixed copy/paste error in error message (s/schib/CRW) hw/vfio/ccw.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 2ff223470f..2b1a83b94c 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -44,6 +44,9 @@ struct VFIOCCWDevice { uint64_t schib_region_size; uint64_t schib_region_offset; struct ccw_schib_region *schib_region; + uint64_t crw_region_size; + uint64_t crw_region_offset; + struct ccw_crw_region *crw_region; EventNotifier io_notifier; bool force_orb_pfch; bool warned_orb_pfch; @@ -449,10 +452,24 @@ static void vfio_ccw_get_region(VFIOCCWDevice *vcdev,= Error **errp) vcdev->schib_region =3D g_malloc(info->size); } =20 + ret =3D vfio_get_dev_region_info(vdev, VFIO_REGION_TYPE_CCW, + VFIO_REGION_SUBTYPE_CCW_CRW, &info); + + if (!ret) { + vcdev->crw_region_size =3D info->size; + if (sizeof(*vcdev->crw_region) !=3D vcdev->crw_region_size) { + error_setg(errp, "vfio: Unexpected size of the CRW region"); + goto out_err; + } + vcdev->crw_region_offset =3D info->offset; + vcdev->crw_region =3D g_malloc(info->size); + } + g_free(info); return; =20 out_err: + g_free(vcdev->crw_region); g_free(vcdev->schib_region); g_free(vcdev->async_cmd_region); g_free(vcdev->io_region); @@ -462,6 +479,7 @@ out_err: =20 static void vfio_ccw_put_region(VFIOCCWDevice *vcdev) { + g_free(vcdev->crw_region); g_free(vcdev->schib_region); g_free(vcdev->async_cmd_region); g_free(vcdev->io_region); --=20 2.17.1 From nobody Sat May 4 06:04:28 2024 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=1573791683; cv=none; d=zoho.com; s=zohoarc; b=SkTRw92tV5Lp3Ijl8N0KPohnnkefvQsvEuEIVpmTXzl0+ur09HWLW3St/go6lma6LVqJUHSzJNTqXVRPccuzjjZvfVzovOIymJdeJM9UBdCJ08TRbEU597jIFki2o1PP8gKsW/M6Hnj4B11aRbiP5qybfjz21BQAh0BQmwqy/Hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573791683; 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; bh=hEJ7bN/AO2n2PARIpWbPeAO4jmH3DhAtSEdyOSA5F+Q=; b=KbnCxy9zvqi6jEklFxFfiFVY+d82W+snnahCkmdIDd59b9zTWoQhYytzxO+ZhVDNoLU9uwS3RkPsz2l9j8ZxMrJ/qSDq2JIAzKfTVB7NSmIIShux/UOu2u1DOQGUXIfBTgJ0UnZumtyZO6H8j2yqy5uPanCMTrmLW8SfM87P7Ic= 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 1573791683379155.41496990080293; Thu, 14 Nov 2019 20:21:23 -0800 (PST) Received: from localhost ([::1]:35280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVT6h-0002Im-Dk for importer@patchew.org; Thu, 14 Nov 2019 23:21:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48272) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVT5h-0001gY-Gn for qemu-devel@nongnu.org; Thu, 14 Nov 2019 23:20:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVT5g-0000mS-BI for qemu-devel@nongnu.org; Thu, 14 Nov 2019 23:20:13 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59602 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 1iVT5g-0000mE-6i for qemu-devel@nongnu.org; Thu, 14 Nov 2019 23:20:12 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAF3YThV117964 for ; Thu, 14 Nov 2019 22:35:25 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2w9jtv6qd7-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Nov 2019 22:35:23 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Nov 2019 03:34:41 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 15 Nov 2019 03:34:40 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAF3YcYC54525998 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2019 03:34:38 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C75DA405C; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 417EDA4054; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id A70A7E02B8; Fri, 15 Nov 2019 04:34:37 +0100 (CET) From: Eric Farman To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [RFC PATCH v1 7/8] vfio-ccw: Refactor ccw irq handler Date: Fri, 15 Nov 2019 04:34:36 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115033437.37926-1-farman@linux.ibm.com> References: <20191115033437.37926-1-farman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19111503-0012-0000-0000-00000363C327 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111503-0013-0000-0000-0000219F3EE0 Message-Id: <20191115033437.37926-8-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-14_07:2019-11-14,2019-11-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=2 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=833 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150029 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: Halil Pasic , Jason Herne , Eric Farman , Cornelia Huck , Jared Rossi 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" Make it easier to add new ones in the future. Signed-off-by: Eric Farman --- hw/vfio/ccw.c | 55 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 2b1a83b94c..b16526d5de 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -334,22 +334,35 @@ read_err: css_inject_io_interrupt(sch); } =20 -static void vfio_ccw_register_io_notifier(VFIOCCWDevice *vcdev, Error **er= rp) +static void vfio_ccw_register_irq_notifier(VFIOCCWDevice *vcdev, int irq, + Error **errp) { VFIODevice *vdev =3D &vcdev->vdev; struct vfio_irq_info *irq_info; size_t argsz; int fd; + EventNotifier *notifier; + IOHandler *fd_read; + + switch (irq) { + case VFIO_CCW_IO_IRQ_INDEX: + notifier =3D &vcdev->io_notifier; + fd_read =3D vfio_ccw_io_notifier_handler; + break; + default: + error_setg(errp, "vfio: Unsupported device irq(%d) fd: %m", irq); + return; + } =20 - if (vdev->num_irqs < VFIO_CCW_IO_IRQ_INDEX + 1) { - error_setg(errp, "vfio: unexpected number of io irqs %u", + if (vdev->num_irqs < irq + 1) { + error_setg(errp, "vfio: unexpected number of irqs %u", vdev->num_irqs); return; } =20 argsz =3D sizeof(*irq_info); irq_info =3D g_malloc0(argsz); - irq_info->index =3D VFIO_CCW_IO_IRQ_INDEX; + irq_info->index =3D irq; irq_info->argsz =3D argsz; if (ioctl(vdev->fd, VFIO_DEVICE_GET_IRQ_INFO, irq_info) < 0 || irq_info->count < 1) { @@ -357,37 +370,47 @@ static void vfio_ccw_register_io_notifier(VFIOCCWDevi= ce *vcdev, Error **errp) goto out_free_info; } =20 - if (event_notifier_init(&vcdev->io_notifier, 0)) { + if (event_notifier_init(notifier, 0)) { error_setg_errno(errp, errno, - "vfio: Unable to init event notifier for IO"); + "vfio: Unable to init event notifier for irq (%d)= ", irq); goto out_free_info; } =20 - fd =3D event_notifier_get_fd(&vcdev->io_notifier); - qemu_set_fd_handler(fd, vfio_ccw_io_notifier_handler, NULL, vcdev); + fd =3D event_notifier_get_fd(notifier); + qemu_set_fd_handler(fd, fd_read, NULL, vcdev); =20 - if (vfio_set_irq_signaling(vdev, VFIO_CCW_IO_IRQ_INDEX, 0, + if (vfio_set_irq_signaling(vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vcdev); - event_notifier_cleanup(&vcdev->io_notifier); + event_notifier_cleanup(notifier); } =20 out_free_info: g_free(irq_info); } =20 -static void vfio_ccw_unregister_io_notifier(VFIOCCWDevice *vcdev) +static void vfio_ccw_unregister_irq_notifier(VFIOCCWDevice *vcdev, int irq) { Error *err =3D NULL; + EventNotifier *notifier; + + switch (irq) { + case VFIO_CCW_IO_IRQ_INDEX: + notifier =3D &vcdev->io_notifier; + break; + default: + error_report("vfio: Unsupported device irq(%d) fd: %m", irq); + return; + } =20 - if (vfio_set_irq_signaling(&vcdev->vdev, VFIO_CCW_IO_IRQ_INDEX, 0, + if (vfio_set_irq_signaling(&vcdev->vdev, irq, 0, VFIO_IRQ_SET_ACTION_TRIGGER, -1, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vcdev->vdev.name); } =20 - qemu_set_fd_handler(event_notifier_get_fd(&vcdev->io_notifier), + qemu_set_fd_handler(event_notifier_get_fd(notifier), NULL, NULL, vcdev); - event_notifier_cleanup(&vcdev->io_notifier); + event_notifier_cleanup(notifier); } =20 static void vfio_ccw_get_region(VFIOCCWDevice *vcdev, Error **errp) @@ -590,7 +613,7 @@ static void vfio_ccw_realize(DeviceState *dev, Error **= errp) goto out_region_err; } =20 - vfio_ccw_register_io_notifier(vcdev, &err); + vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX, &err); if (err) { goto out_notifier_err; } @@ -619,7 +642,7 @@ static void vfio_ccw_unrealize(DeviceState *dev, Error = **errp) S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_GET_CLASS(cdev); VFIOGroup *group =3D vcdev->vdev.group; =20 - vfio_ccw_unregister_io_notifier(vcdev); + vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX); vfio_ccw_put_region(vcdev); vfio_ccw_put_device(vcdev); vfio_put_group(group); --=20 2.17.1 From nobody Sat May 4 06:04:28 2024 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=1573789728; cv=none; d=zoho.com; s=zohoarc; b=hfxTbr/ufUr0dfycyKsudh82MxcV0FHbzLMjRNSd7vgXiiKTnrPGYQ8x6QtlTg+EcrRofGoEWn81hTLeVaIEpQe2/bL8LQY8nv4qEfFa8ioIJ9X3wSkC8h/+brYijbrxKw5W81fhJ28M80rR7V4gJzuucHk951FCJcjMkuGhBxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573789728; 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; bh=uw6GTdyFMxlByPGyFaNvmNghDcgHFjbKMK0e/N2l65k=; b=nYzaBto0rAjcD6v227NAGP6M2tySZQgmB9hPpDRArboazwfp8ALxIvwShSOSKZYNt56WHfz5kksOKB/u18IdtpvzsgekBiS97hiTJy3Ly5HwUkernKU4KuJwQJBMoEmvf9R/VhIjhuwNVgqMoqhi8liBsYW8UWmQgbth4EjuZbs= 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 1573789728512271.83293359672075; Thu, 14 Nov 2019 19:48:48 -0800 (PST) Received: from localhost ([::1]:35218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSbH-0003Kn-Eq for importer@patchew.org; Thu, 14 Nov 2019 22:48:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45037) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iVSYM-0000vU-DT for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:45:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iVSYK-0002Dj-PJ for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:45:46 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55582 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 1iVSYK-0002Cn-L8 for qemu-devel@nongnu.org; Thu, 14 Nov 2019 22:45:44 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAF3YTXM118046 for ; Thu, 14 Nov 2019 22:35:30 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2w9jtv6qhd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Nov 2019 22:35:29 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Nov 2019 03:34:43 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 15 Nov 2019 03:34:39 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAF3Ycba52953192 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Nov 2019 03:34:38 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4EAC352052; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 3565E5204F; Fri, 15 Nov 2019 03:34:38 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 4958) id A9836E02BB; Fri, 15 Nov 2019 04:34:37 +0100 (CET) From: Eric Farman To: qemu-devel@nongnu.org, qemu-s390x@nongnu.org Subject: [RFC PATCH v1 8/8] vfio-ccw: Add support for the CRW irq Date: Fri, 15 Nov 2019 04:34:37 +0100 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191115033437.37926-1-farman@linux.ibm.com> References: <20191115033437.37926-1-farman@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19111503-4275-0000-0000-0000037DDC76 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111503-4276-0000-0000-00003891447D Message-Id: <20191115033437.37926-9-farman@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-14_07:2019-11-14,2019-11-14 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 adultscore=0 clxscore=1015 impostorscore=0 bulkscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911150029 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: Halil Pasic , Jason Herne , Eric Farman , Cornelia Huck , Jared Rossi 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: Farhan Ali The CRW irq will be used by vfio-ccw to notify the userspace about any CRWs the userspace needs to handle. Let's add support for it. Signed-off-by: Farhan Ali Signed-off-by: Eric Farman --- Notes: v0->v1: [EF] - Check vcdev->crw_region before registering the irq, in case host kernel does not have matching support - Split the refactoring changes to an earlier (new) patch (and don't remove the "num_irqs" check in the register routine, but adjust it to the check the input variable) - Don't revert the cool vfio_set_irq_signaling() stuff - Unregister CRW IRQ before IO IRQ in unrealize - s/crw1/crw0/ hw/vfio/ccw.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index b16526d5de..b3f4120118 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -48,6 +48,7 @@ struct VFIOCCWDevice { uint64_t crw_region_offset; struct ccw_crw_region *crw_region; EventNotifier io_notifier; + EventNotifier crw_notifier; bool force_orb_pfch; bool warned_orb_pfch; }; @@ -259,6 +260,34 @@ static void vfio_ccw_reset(DeviceState *dev) ioctl(vcdev->vdev.fd, VFIO_DEVICE_RESET); } =20 +static void vfio_ccw_crw_notifier_handler(void *opaque) +{ + VFIOCCWDevice *vcdev =3D opaque; + struct ccw_crw_region *region =3D vcdev->crw_region; + CRW crw; + int size; + uint8_t erc; + uint16_t rsid; + + if (!event_notifier_test_and_clear(&vcdev->crw_notifier)) { + return; + } + + memset(region, 0, sizeof(*region)); + size =3D pread(vcdev->vdev.fd, region, vcdev->crw_region_size, + vcdev->crw_region_offset); + + if (size =3D=3D -1) { + error_report("vfio-ccw: Read crw region failed with errno=3D%d", e= rrno); + return; + } + + memcpy(&crw, ®ion->crw0, sizeof(CRW)); + erc =3D crw.flags & 0x003f; + rsid =3D crw.rsid; + css_queue_crw(CRW_RSC_CHP, erc, 0, 0, rsid); +} + static void vfio_ccw_io_notifier_handler(void *opaque) { VFIOCCWDevice *vcdev =3D opaque; @@ -349,6 +378,10 @@ static void vfio_ccw_register_irq_notifier(VFIOCCWDevi= ce *vcdev, int irq, notifier =3D &vcdev->io_notifier; fd_read =3D vfio_ccw_io_notifier_handler; break; + case VFIO_CCW_CRW_IRQ_INDEX: + notifier =3D &vcdev->crw_notifier; + fd_read =3D vfio_ccw_crw_notifier_handler; + break; default: error_setg(errp, "vfio: Unsupported device irq(%d) fd: %m", irq); return; @@ -398,6 +431,9 @@ static void vfio_ccw_unregister_irq_notifier(VFIOCCWDev= ice *vcdev, int irq) case VFIO_CCW_IO_IRQ_INDEX: notifier =3D &vcdev->io_notifier; break; + case VFIO_CCW_CRW_IRQ_INDEX: + notifier =3D &vcdev->crw_notifier; + break; default: error_report("vfio: Unsupported device irq(%d) fd: %m", irq); return; @@ -618,6 +654,14 @@ static void vfio_ccw_realize(DeviceState *dev, Error *= *errp) goto out_notifier_err; } =20 + if (vcdev->crw_region) { + vfio_ccw_register_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX, &err= ); + if (err) { + vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX); + goto out_notifier_err; + } + } + return; =20 out_notifier_err: @@ -642,6 +686,7 @@ static void vfio_ccw_unrealize(DeviceState *dev, Error = **errp) S390CCWDeviceClass *cdc =3D S390_CCW_DEVICE_GET_CLASS(cdev); VFIOGroup *group =3D vcdev->vdev.group; =20 + vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_CRW_IRQ_INDEX); vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_IO_IRQ_INDEX); vfio_ccw_put_region(vcdev); vfio_ccw_put_device(vcdev); --=20 2.17.1