From nobody Sat Apr 27 06:41:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542904705041561.1620589308169; Thu, 22 Nov 2018 08:38:25 -0800 (PST) Received: from localhost ([::1]:47622 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPrzc-0000PA-PH for importer@patchew.org; Thu, 22 Nov 2018 11:38:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59424) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPrxc-0007ee-B4 for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPrxX-0008Tj-AP for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:12 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53276) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gPrxX-0008SW-2F for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:07 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAMGYFp2099197 for ; Thu, 22 Nov 2018 11:36:06 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nwxns3xdp-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 11:36:05 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Nov 2018 16:36:03 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) 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) Thu, 22 Nov 2018 16:35:59 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAMGZvu561603930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Nov 2018 16:35:57 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 614374C04A; Thu, 22 Nov 2018 16:35:57 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E31F44C044; Thu, 22 Nov 2018 16:35:56 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.168]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Nov 2018 16:35:56 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Thu, 22 Nov 2018 17:35:50 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> References: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112216-0012-0000-0000-000002CEA9D1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112216-0013-0000-0000-00002103DC2B Message-Id: <1542904555-1136-2-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-22_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=988 adultscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220147 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 1/6] s390x/vfio: ap: Finding the AP bridge X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: akrowiak@linux.ibm.com, peter.maydell@linaro.org, david@redhat.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, pasic@linux.ibm.com, eric.auger@redhat.com, qemu-s390x@nongnu.org, mst@redhat.com, pbonzini@redhat.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" In the case we will enter QEMU through interception of instructions, we will need to retrieve the AP devices. The base device is the AP bridge. Let us implement a way to retrieve the AP Bridge from qtree. Signed-off-by: Pierre Morel --- hw/s390x/ap-bridge.c | 12 ++++++++++++ include/hw/s390x/ap-bridge.h | 1 + 2 files changed, 13 insertions(+) diff --git a/hw/s390x/ap-bridge.c b/hw/s390x/ap-bridge.c index 3795d30..831ad5d 100644 --- a/hw/s390x/ap-bridge.c +++ b/hw/s390x/ap-bridge.c @@ -14,6 +14,18 @@ #include "hw/s390x/ap-bridge.h" #include "cpu.h" =20 +DeviceState *s390_get_ap_bridge(void) +{ + static DeviceState *apb; + + if (!apb) { + apb =3D DEVICE(object_resolve_path(TYPE_AP_BRIDGE, NULL)); + assert(apb !=3D NULL); + } + + return apb; +} + static char *ap_bus_get_dev_path(DeviceState *dev) { /* at most one */ diff --git a/include/hw/s390x/ap-bridge.h b/include/hw/s390x/ap-bridge.h index 470e439..dacb877 100644 --- a/include/hw/s390x/ap-bridge.h +++ b/include/hw/s390x/ap-bridge.h @@ -15,5 +15,6 @@ #define TYPE_AP_BUS "ap-bus" =20 void s390_init_ap(void); +DeviceState *s390_get_ap_bridge(void); =20 #endif --=20 2.7.4 From nobody Sat Apr 27 06:41:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542904708662369.0414313618003; Thu, 22 Nov 2018 08:38:28 -0800 (PST) Received: from localhost ([::1]:47621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPrza-0000N3-39 for importer@patchew.org; Thu, 22 Nov 2018 11:38:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPrxb-0007eS-Or for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPrxW-0008TE-UB for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:11 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33652 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 1gPrxW-0008Sc-PW for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:06 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAMGYGBR103188 for ; Thu, 22 Nov 2018 11:36:06 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nwya82388-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 11:36:06 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Nov 2018 16:36:04 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) 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) Thu, 22 Nov 2018 16:36:00 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAMGZwjT58785912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Nov 2018 16:35:59 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBEEC4C050; Thu, 22 Nov 2018 16:35:58 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 706074C046; Thu, 22 Nov 2018 16:35:58 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.168]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Nov 2018 16:35:58 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Thu, 22 Nov 2018 17:35:51 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> References: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112216-0008-0000-0000-00000296FEAB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112216-0009-0000-0000-000022013426 Message-Id: <1542904555-1136-3-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-22_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1811220147 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH v2 2/6] s390x/vfio: ap: Use the APdevice as a child of the APBus X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: akrowiak@linux.ibm.com, peter.maydell@linaro.org, david@redhat.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, pasic@linux.ibm.com, eric.auger@redhat.com, qemu-s390x@nongnu.org, mst@redhat.com, pbonzini@redhat.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" Two good reasons to use the base device as a child of the AP BUS: - We can easily find the device without traversing the qtree. - In case we have different APdevice instantiation, VFIO with interception or emulation, we will need the APDevice as a parent device. Signed-off-by: Pierre Morel --- hw/s390x/ap-device.c | 22 ++++++++++++++++++++++ hw/vfio/ap.c | 16 ++++++---------- include/hw/s390x/ap-device.h | 2 ++ 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/hw/s390x/ap-device.c b/hw/s390x/ap-device.c index f5ac8db..554d5aa 100644 --- a/hw/s390x/ap-device.c +++ b/hw/s390x/ap-device.c @@ -11,13 +11,35 @@ #include "qemu/module.h" #include "qapi/error.h" #include "hw/qdev.h" +#include "hw/s390x/ap-bridge.h" #include "hw/s390x/ap-device.h" =20 +APDevice *s390_get_ap(void) +{ + static DeviceState *apb; + BusState *bus; + BusChild *child; + static APDevice *ap; + + if (ap) { + return ap; + } + + apb =3D s390_get_ap_bridge(); + /* We have only a single child on the BUS */ + bus =3D qdev_get_child_bus(apb, TYPE_AP_BUS); + child =3D QTAILQ_FIRST(&bus->children); + assert(child !=3D NULL); + ap =3D DO_UPCAST(APDevice, parent_obj, child->child); + return ap; +} + static void ap_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 dc->desc =3D "AP device class"; + dc->bus_type =3D TYPE_AP_BUS; dc->hotpluggable =3D false; } =20 diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 65de952..94e5a1a 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -35,9 +35,6 @@ typedef struct VFIOAPDevice { VFIODevice vdev; } VFIOAPDevice; =20 -#define VFIO_AP_DEVICE(obj) \ - OBJECT_CHECK(VFIOAPDevice, (obj), VFIO_AP_DEVICE_TYPE) - static void vfio_ap_compute_needs_reset(VFIODevice *vdev) { vdev->needs_reset =3D false; @@ -90,8 +87,8 @@ static void vfio_ap_realize(DeviceState *dev, Error **err= p) char *mdevid; Error *local_err =3D NULL; VFIOGroup *vfio_group; - APDevice *apdev =3D AP_DEVICE(dev); - VFIOAPDevice *vapdev =3D VFIO_AP_DEVICE(apdev); + APDevice *apdev =3D DO_UPCAST(APDevice, parent_obj, dev); + VFIOAPDevice *vapdev =3D DO_UPCAST(VFIOAPDevice, apdev, apdev); =20 vfio_group =3D vfio_ap_get_group(vapdev, &local_err); if (!vfio_group) { @@ -120,8 +117,8 @@ out_err: =20 static void vfio_ap_unrealize(DeviceState *dev, Error **errp) { - APDevice *apdev =3D AP_DEVICE(dev); - VFIOAPDevice *vapdev =3D VFIO_AP_DEVICE(apdev); + APDevice *apdev =3D DO_UPCAST(APDevice, parent_obj, dev); + VFIOAPDevice *vapdev =3D DO_UPCAST(VFIOAPDevice, apdev, apdev); VFIOGroup *group =3D vapdev->vdev.group; =20 vfio_ap_put_device(vapdev); @@ -136,8 +133,8 @@ static Property vfio_ap_properties[] =3D { static void vfio_ap_reset(DeviceState *dev) { int ret; - APDevice *apdev =3D AP_DEVICE(dev); - VFIOAPDevice *vapdev =3D VFIO_AP_DEVICE(apdev); + APDevice *apdev =3D DO_UPCAST(APDevice, parent_obj, dev); + VFIOAPDevice *vapdev =3D DO_UPCAST(VFIOAPDevice, apdev, apdev); =20 ret =3D ioctl(vapdev->vdev.fd, VFIO_DEVICE_RESET); if (ret) { @@ -163,7 +160,6 @@ static void vfio_ap_class_init(ObjectClass *klass, void= *data) dc->unrealize =3D vfio_ap_unrealize; dc->hotpluggable =3D false; dc->reset =3D vfio_ap_reset; - dc->bus_type =3D TYPE_AP_BUS; } =20 static const TypeInfo vfio_ap_info =3D { diff --git a/include/hw/s390x/ap-device.h b/include/hw/s390x/ap-device.h index 765e908..5f3c840 100644 --- a/include/hw/s390x/ap-device.h +++ b/include/hw/s390x/ap-device.h @@ -19,4 +19,6 @@ typedef struct APDevice { #define AP_DEVICE(obj) \ OBJECT_CHECK(APDevice, (obj), AP_DEVICE_TYPE) =20 +APDevice *s390_get_ap(void); + #endif /* HW_S390X_AP_DEVICE_H */ --=20 2.7.4 From nobody Sat Apr 27 06:41:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542904881795585.9530522365768; Thu, 22 Nov 2018 08:41:21 -0800 (PST) Received: from localhost ([::1]:47643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPs2a-0003ec-Im for importer@patchew.org; Thu, 22 Nov 2018 11:41:20 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPrxe-0007fz-Ny for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPrxa-0000Br-3B for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:14 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60994) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gPrxZ-00008V-R2 for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:10 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAMGYjf0039321 for ; Thu, 22 Nov 2018 11:36:09 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nwxjx42ns-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 11:36:08 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Nov 2018 16:36:06 -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) Thu, 22 Nov 2018 16:36:02 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAMGa0De10486164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Nov 2018 16:36:00 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B79C4C050; Thu, 22 Nov 2018 16:36:00 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EAFAF4C046; Thu, 22 Nov 2018 16:35:59 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.168]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Nov 2018 16:35:59 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Thu, 22 Nov 2018 17:35:52 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> References: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112216-0012-0000-0000-000002CEA9D4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112216-0013-0000-0000-00002103DC2C Message-Id: <1542904555-1136-4-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-22_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=958 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220147 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 3/6] s390x/vfio: ap: Linux uapi VFIO place holder X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: akrowiak@linux.ibm.com, peter.maydell@linaro.org, david@redhat.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, pasic@linux.ibm.com, eric.auger@redhat.com, qemu-s390x@nongnu.org, mst@redhat.com, pbonzini@redhat.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" This file would be copied from Linux, I put it here for the review. Signed-off-by: Pierre Morel --- linux-headers/linux/vfio.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index ceb6453..d5d10bc9 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -816,6 +816,31 @@ struct vfio_iommu_spapr_tce_remove { }; #define VFIO_IOMMU_SPAPR_TCE_REMOVE _IO(VFIO_TYPE, VFIO_BASE + 20) =20 +/** + * VFIO_AP_SET_IRQ - _IOWR(VFIO_TYPE, VFIO_BASE + 21, struct vfio_ap_aqic) + * + * Setup IRQ for an AP Queue + * @cmd contains the AP queue number (apqn) + * @status receives the resulting status of the command + * @nib is the Notification Indicator byte address + * @adapter_id allows to retrieve the associated adapter + */ +struct vfio_ap_aqic { + __u32 argsz; + __u32 flags; + /* out */ + __u32 status; + /* in */ + __u32 adapter_id; + __u64 nib; + __u16 apqn; + __u8 isc; + __u8 reserved[5]; +}; +#define VFIO_AP_SET_IRQ _IO(VFIO_TYPE, VFIO_BASE + 21) +#define VFIO_AP_CLEAR_IRQ _IO(VFIO_TYPE, VFIO_BASE + 22) + /* ***************************************************************** */ =20 + #endif /* VFIO_H */ --=20 2.7.4 From nobody Sat Apr 27 06:41:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542904876144653.9934384192725; Thu, 22 Nov 2018 08:41:16 -0800 (PST) Received: from localhost ([::1]:47642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPs2U-0003cg-W9 for importer@patchew.org; Thu, 22 Nov 2018 11:41:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPrxc-0007ef-BH for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPrxa-0000Dh-C8 for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:12 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38582) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gPrxa-00009u-3T for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:10 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAMGYHc2059920 for ; Thu, 22 Nov 2018 11:36:09 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nwwu0e805-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 11:36:09 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Nov 2018 16:36:06 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) 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) Thu, 22 Nov 2018 16:36:03 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAMGa2x851052728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Nov 2018 16:36:02 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E39AC4C04A; Thu, 22 Nov 2018 16:36:01 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7AA964C046; Thu, 22 Nov 2018 16:36:01 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.168]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Nov 2018 16:36:01 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Thu, 22 Nov 2018 17:35:53 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> References: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112216-0008-0000-0000-00000296FEAC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112216-0009-0000-0000-000022013427 Message-Id: <1542904555-1136-5-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-22_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1811220147 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 4/6] s390x/cpumodel: Set up CPU model for AQIC interception X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: akrowiak@linux.ibm.com, peter.maydell@linaro.org, david@redhat.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, pasic@linux.ibm.com, eric.auger@redhat.com, qemu-s390x@nongnu.org, mst@redhat.com, pbonzini@redhat.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" A new CPU model facilities is introduced to support AP devices interruption interception for a KVM guest. CPU model facility: The S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL, CPU facility indicates whether AP interruption interception is available to the guest. This feature will be enabled only if the AP instructions are available on the linux host and AQIC facility is installed on the host. This feature must be turned on from userspace to intercept AP instructions on the KVM guest. The QEMU command line to turn this feature on looks something like this: qemu-system-s390x ... -cpu xxx,aqci=3Don ... Signed-off-by: Pierre Morel Reviewed-by: Tony Krowiak --- target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/cpu_models.c | 1 + target/s390x/gen-features.c | 1 + 4 files changed, 4 insertions(+) diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c index 60cfeba..c464abf 100644 --- a/target/s390x/cpu_features.c +++ b/target/s390x/cpu_features.c @@ -84,6 +84,7 @@ static const S390FeatDef s390_features[] =3D { FEAT_INIT("sema", S390_FEAT_TYPE_STFL, 59, "Semaphore-assist facility"= ), FEAT_INIT("tsi", S390_FEAT_TYPE_STFL, 60, "Time-slice Instrumentation = facility"), FEAT_INIT("ri", S390_FEAT_TYPE_STFL, 64, "CPU runtime-instrumentation = facility"), + FEAT_INIT("aqic", S390_FEAT_TYPE_STFL, 65, "AP-Queue interruption Cont= rol facility"), FEAT_INIT("zpci", S390_FEAT_TYPE_STFL, 69, "z/PCI facility"), FEAT_INIT("aen", S390_FEAT_TYPE_STFL, 71, "General-purpose-adapter-eve= nt-notification facility"), FEAT_INIT("ais", S390_FEAT_TYPE_STFL, 72, "General-purpose-adapter-int= erruption-suppression facility"), diff --git a/target/s390x/cpu_features_def.h b/target/s390x/cpu_features_de= f.h index 5fc7e7b..3f22780 100644 --- a/target/s390x/cpu_features_def.h +++ b/target/s390x/cpu_features_def.h @@ -72,6 +72,7 @@ typedef enum { S390_FEAT_SEMAPHORE_ASSIST, S390_FEAT_TIME_SLICE_INSTRUMENTATION, S390_FEAT_RUNTIME_INSTRUMENTATION, + S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL, S390_FEAT_ZPCI, S390_FEAT_ADAPTER_EVENT_NOTIFICATION, S390_FEAT_ADAPTER_INT_SUPPRESSION, diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 7c253ff..6b5e94b 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -788,6 +788,7 @@ static void check_consistency(const S390CPUModel *model) { S390_FEAT_SIE_KSS, S390_FEAT_SIE_F2 }, { S390_FEAT_AP_QUERY_CONFIG_INFO, S390_FEAT_AP }, { S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP }, + { S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL, S390_FEAT_AP }, }; int i; =20 diff --git a/target/s390x/gen-features.c b/target/s390x/gen-features.c index 70015ea..b051221 100644 --- a/target/s390x/gen-features.c +++ b/target/s390x/gen-features.c @@ -448,6 +448,7 @@ static uint16_t full_GEN12_GA1[] =3D { S390_FEAT_EDAT_2, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2, S390_FEAT_AP_QUERY_CONFIG_INFO, + S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL, S390_FEAT_AP_FACILITIES_TEST, S390_FEAT_AP, }; --=20 2.7.4 From nobody Sat Apr 27 06:41:03 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542905032503199.07924903421895; Thu, 22 Nov 2018 08:43:52 -0800 (PST) Received: from localhost ([::1]:47663 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPs4h-0005XO-8Q for importer@patchew.org; Thu, 22 Nov 2018 11:43:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPrxg-0007j0-Ut for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPrxc-0000K2-KQ for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:17 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40804) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gPrxc-0000Gx-A0 for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:12 -0500 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAMGYG4R062475 for ; Thu, 22 Nov 2018 11:36:11 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nwxd64kq9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 11:36:10 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Nov 2018 16:36:08 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 22 Nov 2018 16:36:05 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAMGa3HB7995810 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Nov 2018 16:36:03 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 719BC4C050; Thu, 22 Nov 2018 16:36:03 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F254B4C044; Thu, 22 Nov 2018 16:36:02 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.168]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Nov 2018 16:36:02 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Thu, 22 Nov 2018 17:35:54 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> References: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112216-0016-0000-0000-0000022B2755 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112216-0017-0000-0000-000032836E23 Message-Id: <1542904555-1136-6-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-22_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=702 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220147 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 5/6] s390x/vfio: ap: Definition for AP Adapter type X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: akrowiak@linux.ibm.com, peter.maydell@linaro.org, david@redhat.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, pasic@linux.ibm.com, eric.auger@redhat.com, qemu-s390x@nongnu.org, mst@redhat.com, pbonzini@redhat.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" Let's define the AP adapter type to use it with standard adapter interface Signed-off-by: Pierre Morel --- include/hw/s390x/css.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/hw/s390x/css.h b/include/hw/s390x/css.h index aae19c4..9946492 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -217,6 +217,7 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev *s= ub); typedef enum { CSS_IO_ADAPTER_VIRTIO =3D 0, CSS_IO_ADAPTER_PCI =3D 1, + CSS_IO_ADAPTER_AP =3D 2, CSS_IO_ADAPTER_TYPE_NUMS, } CssIoAdapterType; =20 --=20 2.7.4 From nobody Sat Apr 27 06:41:03 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1542904722985550.9463242197616; Thu, 22 Nov 2018 08:38:42 -0800 (PST) Received: from localhost ([::1]:47624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPrzp-00010S-Ia for importer@patchew.org; Thu, 22 Nov 2018 11:38:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPrxg-0007j2-VD for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPrxd-0000Mx-H2 for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:17 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57522) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gPrxd-0000K8-7Q for qemu-devel@nongnu.org; Thu, 22 Nov 2018 11:36:13 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAMGYJbn140298 for ; Thu, 22 Nov 2018 11:36:12 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nwy77aa51-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 11:36:12 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Nov 2018 16:36:09 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) 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) Thu, 22 Nov 2018 16:36:06 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAMGa5t66160840 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Nov 2018 16:36:05 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F08294C04A; Thu, 22 Nov 2018 16:36:04 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F7694C040; Thu, 22 Nov 2018 16:36:04 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.168]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Nov 2018 16:36:04 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Thu, 22 Nov 2018 17:35:55 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> References: <1542904555-1136-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112216-0008-0000-0000-00000296FEAD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112216-0009-0000-0000-000022013428 Message-Id: <1542904555-1136-7-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-22_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1811220147 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v2 6/6] s390x/vfio: ap: Implementing AP Queue Interrupt Control X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: akrowiak@linux.ibm.com, peter.maydell@linaro.org, david@redhat.com, cohuck@redhat.com, qemu-devel@nongnu.org, agraf@suse.de, pasic@linux.ibm.com, eric.auger@redhat.com, qemu-s390x@nongnu.org, mst@redhat.com, pbonzini@redhat.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" We intercept the PQAP(AQIC) instruction and transform the guest's AQIC command parameters for the host AQIC parameters. Doing this we use the standard adapter interface to provide the adapter NIB, indicator and ISC. We define new structures, APCard and APQueue to keep track of the ISC, route and indicator address and we add an array of APCards in the APDevice. We call the VFIO ioctl to set or clear the interruption according to the "i" bit of the parameter. Signed-off-by: Pierre Morel --- hw/vfio/ap.c | 117 +++++++++++++++++++++++++++++++++++++++= +++- include/hw/s390x/ap-device.h | 63 +++++++++++++++++++++++ target/s390x/kvm.c | 31 ++++++++++++ 3 files changed, 210 insertions(+), 1 deletion(-) diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 94e5a1a..20d2e5f 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -4,6 +4,7 @@ * Copyright 2018 IBM Corp. * Author(s): Tony Krowiak * Halil Pasic + * Pierre Morel * * This work is licensed under the terms of the GNU GPL, version 2 or (at * your option) any later version. See the COPYING file in the top-level @@ -14,7 +15,6 @@ #include #include "qemu/osdep.h" #include "qapi/error.h" -#include "hw/sysbus.h" #include "hw/vfio/vfio.h" #include "hw/vfio/vfio-common.h" #include "hw/s390x/ap-device.h" @@ -27,6 +27,8 @@ #include "sysemu/sysemu.h" #include "hw/s390x/ap-bridge.h" #include "exec/address-spaces.h" +#include "hw/s390x/s390_flic.h" +#include "hw/s390x/css.h" =20 #define VFIO_AP_DEVICE_TYPE "vfio-ap" =20 @@ -35,6 +37,117 @@ typedef struct VFIOAPDevice { VFIODevice vdev; } VFIOAPDevice; =20 +static uint32_t ap_pqap_clear_irq(VFIODevice *vdev, APQueue *apq) +{ + struct vfio_ap_aqic param; + uint32_t retval; + + param.apqn =3D apq->apqn; + param.isc =3D apq->isc; + param.argsz =3D sizeof(param); + + retval =3D ioctl(vdev->fd, VFIO_AP_CLEAR_IRQ, ¶m); + switch (retval) { + case 0: /* Fall through and return the instruction status */ + release_indicator(&apq->routes.adapter, apq->nib); + case -EIO: /* The case the PQAP instruction failed with status */ + return param.status; + default: /* The case the ioctl call failed without isuing instructio= n */ + break; + } + return ap_reg_set_status(AP_RC_INVALID_ADDR); +} + +static uint32_t ap_pqap_set_irq(VFIODevice *vdev, APQueue *apq, uint64_t g= _nib) +{ + struct vfio_ap_aqic param; + uint32_t retval; + uint32_t id; + + id =3D css_get_adapter_id(CSS_IO_ADAPTER_AP, apq->isc); + if (id =3D=3D -1) { + return ap_reg_set_status(AP_RC_INVALID_ADDR); + } + apq->routes.adapter.adapter_id =3D id; + apq->nib =3D get_indicator(ldq_p(&g_nib), 8); + + retval =3D map_indicator(&apq->routes.adapter, apq->nib); + if (retval) { + return ap_reg_set_status(AP_RC_INVALID_ADDR); + } + + param.apqn =3D apq->apqn; + param.isc =3D apq->isc; + param.nib =3D g_nib; + param.adapter_id =3D id; + param.argsz =3D sizeof(param); + + retval =3D ioctl(vdev->fd, VFIO_AP_SET_IRQ, ¶m); + switch (retval) { + case -EIO: /* The case the PQAP instruction failed with status */ + release_indicator(&apq->routes.adapter, apq->nib); + case 0: /* Fall through and return the instruction status */ + return param.status; + default: /* The case the ioctl call failed without isuing instructio= n */ + break; + } + release_indicator(&apq->routes.adapter, apq->nib); + return ap_reg_set_status(AP_RC_INVALID_ADDR); +} + +static int ap_pqap_aqic(CPUS390XState *env) +{ + uint64_t g_nib =3D env->regs[2]; + uint8_t apid =3D ap_reg_get_apid(env->regs[0]); + uint8_t apqi =3D ap_reg_get_apqi(env->regs[0]); + uint32_t retval; + APDevice *ap =3D s390_get_ap(); + VFIODevice *vdev; + VFIOAPDevice *ap_vdev; + APQueue *apq; + + ap_vdev =3D DO_UPCAST(VFIOAPDevice, apdev, ap); + vdev =3D &ap_vdev->vdev; + apq =3D &ap->card[apid].queue[apqi]; + apq->isc =3D ap_reg_get_isc(env->regs[1]); + apq->apqn =3D (apid << 8) | apqi; + + if (ap_reg_get_ir(env->regs[1])) { + retval =3D ap_pqap_set_irq(vdev, apq, g_nib); + } else { + retval =3D ap_pqap_clear_irq(vdev, apq); + } + + env->regs[1] =3D retval; + if (retval & AP_STATUS_RC_MASK) { + return 3; + } + + return 0; +} + +/* + * ap_pqap + * @env: environment pointing to registers + * return value: Code Condition + */ +int ap_pqap(CPUS390XState *env) +{ + int cc =3D 0; + + switch (ap_reg_get_fc(env->regs[0])) { + case AQIC: + if (!s390_has_feat(S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL)) { + return -PGM_OPERATION; + } + cc =3D ap_pqap_aqic(env); + break; + default: + return -PGM_OPERATION; + } + return cc; +} + static void vfio_ap_compute_needs_reset(VFIODevice *vdev) { vdev->needs_reset =3D false; @@ -106,6 +219,8 @@ static void vfio_ap_realize(DeviceState *dev, Error **e= rrp) goto out_get_dev_err; } =20 + css_register_io_adapters(CSS_IO_ADAPTER_AP, true, false, + 0, &error_abort); return; =20 out_get_dev_err: diff --git a/include/hw/s390x/ap-device.h b/include/hw/s390x/ap-device.h index 5f3c840..8a36780 100644 --- a/include/hw/s390x/ap-device.h +++ b/include/hw/s390x/ap-device.h @@ -12,8 +12,25 @@ =20 #define AP_DEVICE_TYPE "ap-device" =20 +#define MAX_AP_CARD 256 +#define MAX_AP_DOMAIN 256 + +#include "hw/s390x/s390_flic.h" +#include "hw/s390x/css.h" +typedef struct APQueue { + AdapterRoutes routes; + IndAddr *nib; + uint16_t apqn; + uint8_t isc; +} APQueue; + +typedef struct APCard { + APQueue queue[MAX_AP_DOMAIN]; +} APCard; + typedef struct APDevice { DeviceState parent_obj; + APCard card[MAX_AP_CARD]; } APDevice; =20 #define AP_DEVICE(obj) \ @@ -21,4 +38,50 @@ typedef struct APDevice { =20 APDevice *s390_get_ap(void); =20 +#include "cpu.h" +int ap_pqap(CPUS390XState *env); + +/* AP PQAP commands definitions */ +#define AQIC 0x03 + +#define AP_AQIC_ZERO_BITS 0x0ff0000 + +/* Register 0 hold the command and APQN */ +static inline uint8_t ap_reg_get_apid(uint64_t r) +{ + return (r >> 8) & 0xff; +} + +static inline uint8_t ap_reg_get_apqi(uint64_t r) +{ + return r & 0xff; +} + +static inline uint16_t ap_reg_get_fc(uint64_t r) +{ + return (r >> 24) & 0xff; +} + +static inline uint16_t ap_reg_get_ir(uint64_t r) +{ + return (r >> 47) & 0x01; +} + +static inline uint16_t ap_reg_get_isc(uint64_t r) +{ + return r & 0x7; +} + +/* AP status returned by the AP PQAP commands */ +#define AP_STATUS_RC_MASK 0x00ff0000 +#define AP_RC_APQN_INVALID 0x01 +#define AP_RC_INVALID_ADDR 0x06 +#define AP_RC_BAD_STATE 0x07 + +/* Register 1 as input hold the AQIC information */ +static inline uint32_t ap_reg_set_status(uint8_t status) +{ + return status << 16; +} + #endif /* HW_S390X_AP_DEVICE_H */ diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 2ebf26a..a4b5d90 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -45,6 +45,7 @@ #include "trace.h" #include "hw/s390x/s390-pci-inst.h" #include "hw/s390x/s390-pci-bus.h" +#include "hw/s390x/ap-device.h" #include "hw/s390x/ipl.h" #include "hw/s390x/ebcdic.h" #include "exec/memattrs.h" @@ -88,6 +89,7 @@ #define PRIV_B2_CHSC 0x5f #define PRIV_B2_SIGA 0x74 #define PRIV_B2_XSCH 0x76 +#define PRIV_B2_PQAP 0xaf =20 #define PRIV_EB_SQBS 0x8a #define PRIV_EB_PCISTB 0xd0 @@ -1154,6 +1156,32 @@ static int kvm_sclp_service_call(S390CPU *cpu, struc= t kvm_run *run, return 0; } =20 +static int kvm_ap_pqap(S390CPU *cpu, uint16_t ipbh0) +{ + CPUS390XState *env =3D &cpu->env; + int r; + + if (env->psw.mask & PSW_MASK_PSTATE) { + kvm_s390_program_interrupt(cpu, PGM_PRIVILEGED); + return 0; + } + + if (env->regs[0] & AP_AQIC_ZERO_BITS) { + kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION); + return 0; + } + + r =3D ap_pqap(&cpu->env); + + if (r < 0) { + kvm_s390_program_interrupt(cpu, -r); + } else { + setcc(cpu, r); + } + + return 0; +} + static int handle_b2(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) { CPUS390XState *env =3D &cpu->env; @@ -1216,6 +1244,9 @@ static int handle_b2(S390CPU *cpu, struct kvm_run *ru= n, uint8_t ipa1) case PRIV_B2_SCLP_CALL: rc =3D kvm_sclp_service_call(cpu, run, ipbh0); break; + case PRIV_B2_PQAP: + rc =3D kvm_ap_pqap(cpu, ipbh0); + break; default: rc =3D -1; DPRINTF("KVM: unhandled PRIV: 0xb2%x\n", ipa1); --=20 2.7.4