From nobody Tue May 7 04:39:57 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507125107246590.2822487372016; Wed, 4 Oct 2017 06:51:47 -0700 (PDT) Received: from localhost ([::1]:35312 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk5P-0007DN-88 for importer@patchew.org; Wed, 04 Oct 2017 09:51:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk3f-00066W-BZ for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:50:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzk3b-0003ji-EC for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:55 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48228 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 1dzk3b-0003iv-7n for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:51 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v94Dn2nN005747 for ; Wed, 4 Oct 2017 09:49:47 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2dcxvfftf9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 04 Oct 2017 09:49:46 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Oct 2017 14:49:45 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Oct 2017 14:49:42 +0100 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 v94Dnfpo27459668; Wed, 4 Oct 2017 13:49:41 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACB014C044; Wed, 4 Oct 2017 14:45:47 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 601DE4C040; Wed, 4 Oct 2017 14:45:47 +0100 (BST) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.145.179.43]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Oct 2017 14:45:47 +0100 (BST) From: Pierre Morel To: qemu-devel@nongnu.org Date: Wed, 4 Oct 2017 15:49:35 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> References: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17100413-0020-0000-0000-000003BD57CD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17100413-0021-0000-0000-0000424FA8F1 Message-Id: <1507124979-8880-2-git-send-email-pmorel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-04_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710040194 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 v1 1/5] s390x/kvm: Enable AIS from CPU model always 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: borntraeger@de.ibm.com, pasic@linux.vnet.ibm.com, cohuck@redhat.com, zyimin@linux.vnet.ibm.com, agraf@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" As this patchset will introduce AIS emulation, we always enable Adapter Interrupt Suppression, depending only from the CPU model. Signed-off-by: Pierre Morel --- target/s390x/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 931b85f..06fe56d 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2807,6 +2807,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model,= Error **errp) if (pci_available) { set_bit(S390_FEAT_ZPCI, model->features); } + set_bit(S390_FEAT_ADAPTER_INT_SUPPRESSION, model->features); set_bit(S390_FEAT_ADAPTER_EVENT_NOTIFICATION, model->features); =20 if (s390_known_cpu_type(cpu_type)) { --=20 2.3.0 From nobody Tue May 7 04:39:57 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507125320724135.34344803857414; Wed, 4 Oct 2017 06:55:20 -0700 (PDT) Received: from localhost ([::1]:35319 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk8n-0001Mz-OB for importer@patchew.org; Wed, 04 Oct 2017 09:55:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk3h-00067n-Se for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzk3e-0003mg-0e for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57088) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzk3d-0003kw-CQ for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:53 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v94Dn3bk059635 for ; Wed, 4 Oct 2017 09:49:47 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dcufa2y2r-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 04 Oct 2017 09:49:47 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Oct 2017 14:49:45 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Oct 2017 14:49:43 +0100 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 v94DnhtJ20709516; Wed, 4 Oct 2017 13:49:43 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0C9D84C040; Wed, 4 Oct 2017 14:45:49 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BBA3A4C044; Wed, 4 Oct 2017 14:45:48 +0100 (BST) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.145.179.43]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Oct 2017 14:45:48 +0100 (BST) From: Pierre Morel To: qemu-devel@nongnu.org Date: Wed, 4 Oct 2017 15:49:36 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> References: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17100413-0012-0000-0000-0000057E63C8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17100413-0013-0000-0000-000018F7D2A3 Message-Id: <1507124979-8880-3-git-send-email-pmorel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-04_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710040194 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 v1 2/5] s390x/css: Use AIS AIRQ injection only if adapter support AIS 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: borntraeger@de.ibm.com, pasic@linux.vnet.ibm.com, cohuck@redhat.com, zyimin@linux.vnet.ibm.com, agraf@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Testing to use Adapter Interrupt suppression or not depend on AIS being enabled in the kernel. To implement AIS emulation we must move this test inside the FLIC dedicated irq_inject function. Furthermore, a test to verify that the adapter is subject to the AIS must be added. Last, there is no need to crash QEMU if the injection failed, the guest may recover from it. Signed-off-by: Pierre Morel --- hw/s390x/css.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 901dc6a..6e74a5c 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -672,10 +672,12 @@ void css_adapter_interrupt(CssIoAdapterType type, uin= t8_t isc) } =20 trace_css_adapter_interrupt(isc); - if (fs->ais_supported) { + /* Use standard IRQ injection for adapters not supporting AIS */ + if (adapter->flags & S390_ADAPTER_SUPPRESSIBLE) { + /* Use AIRQ injection for adapters subject to AIS */ if (fsc->inject_airq(fs, type, isc, adapter->flags)) { error_report("Failed to inject airq with AIS supported"); - exit(1); + /* Report error - guest will handle not receiving interrupts */ } } else { s390_io_interrupt(0, 0, 0, io_int_word); --=20 2.3.0 From nobody Tue May 7 04:39:57 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 15071251174176.617185957095671; Wed, 4 Oct 2017 06:51:57 -0700 (PDT) Received: from localhost ([::1]:35311 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk5M-0007AK-HM for importer@patchew.org; Wed, 04 Oct 2017 09:51:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk3i-00068N-Fy for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzk3e-0003n6-F1 for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:58 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54834) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzk3e-0003m0-0r for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:54 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v94Dn3Kk005413 for ; Wed, 4 Oct 2017 09:49:50 -0400 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dcwe4vtg3-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 04 Oct 2017 09:49:50 -0400 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Oct 2017 14:49:47 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Oct 2017 14:49:45 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v94Dni4I17891486; Wed, 4 Oct 2017 13:49:44 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 61A2B4C046; Wed, 4 Oct 2017 14:45:50 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D6FB4C040; Wed, 4 Oct 2017 14:45:50 +0100 (BST) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.145.179.43]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Oct 2017 14:45:50 +0100 (BST) From: Pierre Morel To: qemu-devel@nongnu.org Date: Wed, 4 Oct 2017 15:49:37 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> References: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17100413-0040-0000-0000-000003DF57AF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17100413-0041-0000-0000-000025E0C2B1 Message-Id: <1507124979-8880-4-git-send-email-pmorel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-04_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710040194 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 v1 3/5] s390x/intc: Emulate Adapter Interrupt Suppression 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: borntraeger@de.ibm.com, pasic@linux.vnet.ibm.com, cohuck@redhat.com, zyimin@linux.vnet.ibm.com, agraf@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Emulate the Adapter Interrupt Suppression in the KVM FLIC interface when the kernel does not support AIS. When the kernel KVM does not support AIS, we can not support VFIO PCI devices but we still can support emulated devices if we emulate AIS inside QEMU. Let's emulate AIS, allowing to use emulated PCI devices without KVM AIS support. Signed-off-by: Pierre Morel --- hw/intc/s390_flic.c | 3 +- hw/intc/s390_flic_kvm.c | 76 ++++++++++++++++++++++++++++++++++++++++-----= ---- 2 files changed, 64 insertions(+), 15 deletions(-) diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c index 6eaf178..33a7cde 100644 --- a/hw/intc/s390_flic.c +++ b/hw/intc/s390_flic.c @@ -185,8 +185,7 @@ static void s390_flic_common_realize(DeviceState *dev, = Error **errp) " (%d > %d)", max_batch, ADAPTER_ROUTES_MAX_GSI); return; } - - fs->ais_supported =3D s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION); + fs->ais_supported =3D false; } =20 static void s390_flic_class_init(ObjectClass *oc, void *data) diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index 7ead17a..fd1aa22 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -33,6 +33,8 @@ typedef struct KVMS390FLICState { =20 uint32_t fd; bool clear_io_supported; + uint8_t simm; + uint8_t nimm; } KVMS390FLICState; =20 DeviceState *s390_flic_kvm_create(void) @@ -164,11 +166,24 @@ static int kvm_s390_modify_ais_mode(S390FLICState *fs= , uint8_t isc, .addr =3D (uint64_t)&req, }; =20 - if (!fs->ais_supported) { - return -ENOSYS; + if (fs->ais_supported) { + return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0; } =20 - return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0; + /* Kernel does not support AIS, emulate it here */ + switch (mode) { + case SIC_IRQ_MODE_ALL: + flic->simm &=3D ~AIS_MODE_MASK(isc); + flic->nimm &=3D ~AIS_MODE_MASK(isc); + break; + case SIC_IRQ_MODE_SINGLE: + flic->simm |=3D AIS_MODE_MASK(isc); + flic->nimm &=3D ~AIS_MODE_MASK(isc); + break; + default: + return -EINVAL; + } + return 0; } =20 static int kvm_s390_inject_airq(S390FLICState *fs, uint8_t type, @@ -180,12 +195,23 @@ static int kvm_s390_inject_airq(S390FLICState *fs, ui= nt8_t type, .group =3D KVM_DEV_FLIC_AIRQ_INJECT, .attr =3D id, }; + uint32_t io_int_word =3D (isc << 27) | IO_INT_WORD_AI; =20 - if (!fs->ais_supported) { - return -ENOSYS; + if (fs->ais_supported) { + return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0; } =20 - return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0; + /* Kernel does not support AIS, emulate it here */ + if (flags && (flic->nimm & AIS_MODE_MASK(isc))) { + return 0; + } + + s390_io_interrupt(0, 0, 0, io_int_word); + + if (flags && (flic->simm & AIS_MODE_MASK(isc))) { + flic->nimm |=3D AIS_MODE_MASK(isc); + } + return 0; } =20 /** @@ -557,6 +583,32 @@ static void kvm_s390_flic_realize(DeviceState *dev, Er= ror **errp) test_attr.group =3D KVM_DEV_FLIC_CLEAR_IO_IRQ; flic_state->clear_io_supported =3D !ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr= ); + /* To support ais we need all these three FLIC attributes */ + test_attr.group =3D KVM_DEV_FLIC_AISM; + ret =3D !ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr); + flic_state->parent_obj.ais_supported &=3D ret; + + test_attr.group =3D KVM_DEV_FLIC_AIRQ_INJECT; + ret =3D !ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr); + flic_state->parent_obj.ais_supported &=3D ret; + + test_attr.group =3D KVM_DEV_FLIC_AISM_ALL; + ret &=3D !ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr); + flic_state->parent_obj.ais_supported &=3D ret; + + /* For buggy kernels we need to really test that the attribute is supp= orted */ + { + struct kvm_s390_ais_req req =3D { + .mode =3D SIC_IRQ_MODE_ALL, + }; + struct kvm_device_attr attr =3D { + .group =3D KVM_DEV_FLIC_AISM, + .addr =3D (uint64_t)&req, + }; + ret =3D !ioctl(flic_state->fd, KVM_SET_DEVICE_ATTR, &attr); + } + flic_state->parent_obj.ais_supported &=3D ret; + return; fail: error_propagate(errp, errp_local); @@ -578,13 +630,11 @@ static void kvm_s390_flic_reset(DeviceState *dev) =20 flic_disable_wait_pfault(flic); =20 - if (fs->ais_supported) { - for (isc =3D 0; isc <=3D MAX_ISC; isc++) { - rc =3D kvm_s390_modify_ais_mode(fs, isc, SIC_IRQ_MODE_ALL); - if (rc) { - error_report("Failed to reset ais mode for isc %d: %s", - isc, strerror(-rc)); - } + for (isc =3D 0; isc <=3D MAX_ISC; isc++) { + rc =3D kvm_s390_modify_ais_mode(fs, isc, SIC_IRQ_MODE_ALL); + if (rc) { + error_report("Failed to reset ais mode for isc %d: %s", + isc, strerror(-rc)); } } =20 --=20 2.3.0 From nobody Tue May 7 04:39:57 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507125220569244.89548572969102; Wed, 4 Oct 2017 06:53:40 -0700 (PDT) Received: from localhost ([::1]:35315 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk78-0000CQ-Ip for importer@patchew.org; Wed, 04 Oct 2017 09:53:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk3h-00066Y-Ec for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzk3d-0003mN-HF for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51436) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzk3d-0003ko-8d for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:53 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v94DmxuZ103723 for ; Wed, 4 Oct 2017 09:49:52 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dcyrhmd23-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 04 Oct 2017 09:49:51 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Oct 2017 14:49:49 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Oct 2017 14:49:46 +0100 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 v94DnjlN29950124; Wed, 4 Oct 2017 13:49:45 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B41534C046; Wed, 4 Oct 2017 14:45:51 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 718EC4C044; Wed, 4 Oct 2017 14:45:51 +0100 (BST) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.145.179.43]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Oct 2017 14:45:51 +0100 (BST) From: Pierre Morel To: qemu-devel@nongnu.org Date: Wed, 4 Oct 2017 15:49:38 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> References: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17100413-0012-0000-0000-0000057E63C9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17100413-0013-0000-0000-000018F7D2A5 Message-Id: <1507124979-8880-5-git-send-email-pmorel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-04_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710040194 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 v1 4/5] s390x/pci: Refuse to realize VFIO-PCI if AIS needed but supported 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: borntraeger@de.ibm.com, pasic@linux.vnet.ibm.com, cohuck@redhat.com, zyimin@linux.vnet.ibm.com, agraf@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In S390x the Adapter Interrupt Suppression facility is used to mask interrupts of other PCI devices during interruption handling. VFIO PCI allows the interrupts to be delivered rapidely through KVM via IRQfd or to be delivered through QEMU. The choice is made through the x-kvm-intx and x-kvo-misx properties of the VFIO PCI device. If the VFIO PCI device is using the direct KVM access through IRQfd and we know that KVM does not implement AIS support we refuse to realize the VFIO PCI device. In all other cases, emulation and VFIO PCI sending interrupts through QEMU, we intercept the propagated IRQ, and protect it with the QEMU AIS implementation before to send it to the guest through KVM. Signed-off-by: Pierre Morel --- hw/s390x/s390-pci-bus.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c index d9c294a..4afe49b 100644 --- a/hw/s390x/s390-pci-bus.c +++ b/hw/s390x/s390-pci-bus.c @@ -21,18 +21,21 @@ #include "hw/pci/pci_bus.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/msi.h" +#include "hw/vfio/pci.h" #include "qemu/error-report.h" =20 #ifndef DEBUG_S390PCI_BUS #define DEBUG_S390PCI_BUS 0 #endif =20 +#ifndef DPRINTF #define DPRINTF(fmt, ...) \ do { \ if (DEBUG_S390PCI_BUS) { \ fprintf(stderr, "S390pci-bus: " fmt, ## __VA_ARGS__); \ } \ } while (0) +#endif =20 S390pciState *s390_get_phb(void) { @@ -751,6 +754,15 @@ static void s390_pcihost_hot_plug(HotplugHandler *hotp= lug_dev, } =20 if (object_dynamic_cast(OBJECT(dev), "vfio-pci")) { + S390FLICState *fs =3D s390_get_flic(); + VFIOPCIDevice *vdev =3D DO_UPCAST(VFIOPCIDevice, pdev, pdev); + + if ((!vdev->no_kvm_msix || !vdev->no_kvm_msix) && + (!fs || !fs->ais_supported)) { + error_setg(errp, "VFIO PCI is not supported " + "because kernel has no AIS capability."); + return; + } pbdev->fh |=3D FH_SHM_VFIO; } else { pbdev->fh |=3D FH_SHM_EMUL; --=20 2.3.0 From nobody Tue May 7 04:39:57 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507125230756453.092869552656; Wed, 4 Oct 2017 06:53:50 -0700 (PDT) Received: from localhost ([::1]:35316 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk7B-0000Ee-IS for importer@patchew.org; Wed, 04 Oct 2017 09:53:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55477) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dzk3k-00069M-PA for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:50:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dzk3g-0003pz-RS for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:50:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38166) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dzk3g-0003p1-IT for qemu-devel@nongnu.org; Wed, 04 Oct 2017 09:49:56 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v94Dnb8e085094 for ; Wed, 4 Oct 2017 09:49:51 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dcx4ut8cw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 04 Oct 2017 09:49:51 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Oct 2017 14:49:49 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 4 Oct 2017 14:49:47 +0100 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 v94DnlDU16974012; Wed, 4 Oct 2017 13:49:47 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 154BE4C040; Wed, 4 Oct 2017 14:45:53 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C33C24C044; Wed, 4 Oct 2017 14:45:52 +0100 (BST) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.145.179.43]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 4 Oct 2017 14:45:52 +0100 (BST) From: Pierre Morel To: qemu-devel@nongnu.org Date: Wed, 4 Oct 2017 15:49:39 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> References: <1507124979-8880-1-git-send-email-pmorel@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17100413-0012-0000-0000-0000057E63CB X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17100413-0013-0000-0000-000018F7D2A7 Message-Id: <1507124979-8880-6-git-send-email-pmorel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-04_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710040194 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 v1 5/5] s390x/intc: AIS is now always migratable 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: borntraeger@de.ibm.com, pasic@linux.vnet.ibm.com, cohuck@redhat.com, zyimin@linux.vnet.ibm.com, agraf@suse.de Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Adapter Interrupt Suppression can now be emulated if the host kernel does not support the FLIC AIS attributes in KVM. It follows it can always be migrated. In the case AIS is supported by the kernel at one side of the migration 1) SRC and DST AIS in KVM All PCI devices can be created on SRC and DST All PCI devices can migrate 2) SRC and DST AIS NOT in KVM Only emulated PCI devices can be used on SRC and DST Only emulated PCI devices can migrate 3) SRC AIS in KVM DST has NOT AIS in KVM Only emulated PCI devices can migrate Only emulated PCI devices can be created on SRC and DST VFIO PCI devices can be used only on SRC 4) SRC has NOT AIS in KVM DST AIS in KVM Only emulated PCI devices can migrate Only emulated PCI devices can be created on SRC and DST VFIO PCI devices can be used only on DST Signed-off-by: Pierre Morel --- hw/intc/s390_flic_kvm.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c index fd1aa22..6f44b1d 100644 --- a/hw/intc/s390_flic_kvm.c +++ b/hw/intc/s390_flic_kvm.c @@ -457,6 +457,12 @@ static void kvm_flic_ais_pre_save(void *opaque) .attr =3D sizeof(ais), }; =20 + if (!flic->parent_obj.ais_supported) { + tmp->simm =3D flic->simm; + tmp->nimm =3D flic->nimm; + return; + } + if (ioctl(flic->fd, KVM_GET_DEVICE_ATTR, &attr)) { error_report("Failed to retrieve kvm flic ais states"); return; @@ -479,14 +485,10 @@ static int kvm_flic_ais_post_load(void *opaque, int v= ersion_id) .addr =3D (uint64_t)&ais, }; =20 - /* This can happen when the user mis-configures its guests in an - * incompatible fashion or without a CPU model. For example using - * qemu with -cpu host (which is not migration safe) and do a - * migration from a host that has AIS to a host that has no AIS. - * In that case the target system will reject the migration here. - */ - if (!ais_needed(flic)) { - return -ENOSYS; + if (!flic->parent_obj.ais_supported) { + flic->simm =3D tmp->simm; + flic->nimm =3D tmp->nimm; + return 0; } =20 return ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr) ? -errno : 0; --=20 2.3.0