From patchwork Fri Nov 2 10:30:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10665251 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54CBB14E2 for ; Fri, 2 Nov 2018 10:32:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3694B2B8EF for ; Fri, 2 Nov 2018 10:32:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ADC22B8EC; Fri, 2 Nov 2018 10:32:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B48772B93E for ; Fri, 2 Nov 2018 10:32:43 +0000 (UTC) Received: from localhost ([::1]:50649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWkt-0003MU-3A for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Nov 2018 06:32:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39673) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWj5-0001sI-Ig for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIWj2-0004HH-Eq for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45508) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gIWj2-00049b-0a for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:48 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wA2ATfVH120222 for ; Fri, 2 Nov 2018 06:30:31 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ngmkwrmvw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Nov 2018 06:30:30 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Nov 2018 10:30:28 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) 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, 2 Nov 2018 10:30:25 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wA2AUNlL59965518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 10:30:23 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6396B11C052; Fri, 2 Nov 2018 10:30:23 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 000B311C066; Fri, 2 Nov 2018 10:30:22 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.73]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 2 Nov 2018 10:30:22 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Fri, 2 Nov 2018 11:30:17 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> References: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18110210-4275-0000-0000-000002D834EE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18110210-4276-0000-0000-000037E544E0 Message-Id: <1541154621-22423-2-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-02_06:, , 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=970 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811020099 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 1/5] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This file would be copied from Linux, I put it here for the review. Signed-off-by: Pierre Morel --- linux-headers/linux/vfio.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index ceb6453394..32b1fec362 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -816,6 +816,28 @@ struct vfio_iommu_spapr_tce_remove { }; #define VFIO_IOMMU_SPAPR_TCE_REMOVE _IO(VFIO_TYPE, VFIO_BASE + 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; + /* in */ + __u64 cmd; + __u64 status; + __u64 nib; + __u32 adapter_id; +}; +#define VFIO_AP_SET_IRQ _IO(VFIO_TYPE, VFIO_BASE + 21) +#define VFIO_AP_CLEAR_IRQ _IO(VFIO_TYPE, VFIO_BASE + 22) + /* ***************************************************************** */ + #endif /* VFIO_H */ From patchwork Fri Nov 2 10:30:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10665253 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3BED14E2 for ; Fri, 2 Nov 2018 10:35:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A42442B619 for ; Fri, 2 Nov 2018 10:35:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94FE82B948; Fri, 2 Nov 2018 10:35:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F06752B907 for ; Fri, 2 Nov 2018 10:35:22 +0000 (UTC) Received: from localhost ([::1]:50665 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWnI-0006FV-7O for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Nov 2018 06:35:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWj4-0001r9-23 for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIWj1-0004G1-1x for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:49 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46180) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gIWj0-0004At-N6 for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:46 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wA2ATgaB120256 for ; Fri, 2 Nov 2018 06:30:34 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ngmkwrmys-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Nov 2018 06:30:34 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Nov 2018 10:30:31 -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) Fri, 2 Nov 2018 10:30:26 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wA2AUOds43122936 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 10:30:24 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C159C11C05E; Fri, 2 Nov 2018 10:30:24 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7057411C052; Fri, 2 Nov 2018 10:30:24 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.73]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 2 Nov 2018 10:30:24 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Fri, 2 Nov 2018 11:30:18 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> References: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18110210-0012-0000-0000-000002C2268A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18110210-0013-0000-0000-000020F65BCA Message-Id: <1541154621-22423-3-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-02_06:, , 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-1807170000 definitions=main-1811020099 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/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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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=on ... Signed-off-by: Pierre Morel --- target/s390x/cpu_features.c | 1 + target/s390x/cpu_features_def.h | 1 + target/s390x/cpu_models.c | 1 + 3 files changed, 3 insertions(+) diff --git a/target/s390x/cpu_features.c b/target/s390x/cpu_features.c index 60cfeba48f..c464abf30a 100644 --- a/target/s390x/cpu_features.c +++ b/target/s390x/cpu_features.c @@ -84,6 +84,7 @@ static const S390FeatDef s390_features[] = { 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 Control facility"), FEAT_INIT("zpci", S390_FEAT_TYPE_STFL, 69, "z/PCI facility"), FEAT_INIT("aen", S390_FEAT_TYPE_STFL, 71, "General-purpose-adapter-event-notification facility"), FEAT_INIT("ais", S390_FEAT_TYPE_STFL, 72, "General-purpose-adapter-interruption-suppression facility"), diff --git a/target/s390x/cpu_features_def.h b/target/s390x/cpu_features_def.h index 5fc7e7bf01..3f22780104 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 7c253ff308..6b5e94b9f6 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; From patchwork Fri Nov 2 10:30:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10665261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 13BDE14BD for ; Fri, 2 Nov 2018 10:37:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE0CF2B619 for ; Fri, 2 Nov 2018 10:37:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E132B2B948; Fri, 2 Nov 2018 10:37:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 993202B619 for ; Fri, 2 Nov 2018 10:37:26 +0000 (UTC) Received: from localhost ([::1]:50680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWpS-0007n7-2K for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Nov 2018 06:37:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWj4-0001rf-Vq for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIWj2-0004Gy-7Z for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:50 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33984 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 1gIWj1-00049v-UN for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:48 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wA2ATZNe066886 for ; Fri, 2 Nov 2018 06:30:32 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ngm31a04r-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Nov 2018 06:30:32 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Nov 2018 10:30:30 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) 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, 2 Nov 2018 10:30:27 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wA2AUQYS54264010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 10:30:26 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4583311C058; Fri, 2 Nov 2018 10:30:26 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D715511C04C; Fri, 2 Nov 2018 10:30:25 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.73]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 2 Nov 2018 10:30:25 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Fri, 2 Nov 2018 11:30:19 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> References: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18110210-0020-0000-0000-000002DEA4F1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18110210-0021-0000-0000-0000212E0742 Message-Id: <1541154621-22423-4-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-02_06:, , 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=684 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811020099 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 3/5] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Pierre Morel 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 aae19c4272..9946492214 100644 --- a/include/hw/s390x/css.h +++ b/include/hw/s390x/css.h @@ -217,6 +217,7 @@ IOInstEnding do_subchannel_work_passthrough(SubchDev *sub); typedef enum { CSS_IO_ADAPTER_VIRTIO = 0, CSS_IO_ADAPTER_PCI = 1, + CSS_IO_ADAPTER_AP = 2, CSS_IO_ADAPTER_TYPE_NUMS, } CssIoAdapterType; From patchwork Fri Nov 2 10:30:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10665255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D648B14BD for ; Fri, 2 Nov 2018 10:35:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B89AF2B619 for ; Fri, 2 Nov 2018 10:35:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACB032B948; Fri, 2 Nov 2018 10:35:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 477BF2B619 for ; Fri, 2 Nov 2018 10:35:30 +0000 (UTC) Received: from localhost ([::1]:50669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWnZ-0006YI-HG for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Nov 2018 06:35:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWj6-0001so-4e for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIWj3-0004I6-3s for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:51 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60134 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 1gIWj2-0004BO-Rs for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:49 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wA2ATg7d031795 for ; Fri, 2 Nov 2018 06:30:36 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nghj988x5-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Nov 2018 06:30:36 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Nov 2018 10:30:33 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 2 Nov 2018 10:30:29 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wA2AURuD49873014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 10:30:27 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A173611C04C; Fri, 2 Nov 2018 10:30:27 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 51C5011C050; Fri, 2 Nov 2018 10:30:27 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.73]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 2 Nov 2018 10:30:27 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Fri, 2 Nov 2018 11:30:20 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> References: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18110210-0020-0000-0000-000002DEA4F5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18110210-0021-0000-0000-0000212E0743 Message-Id: <1541154621-22423-5-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-02_06:, , 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-1807170000 definitions=main-1811020099 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 4/5] s390x/vfio: ap: Intercepting 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Pierre Morel We intercept the PQAP(AQIC) instruction. Until we implement AQIC we return a PGM_OPERATION. Signed-off-by: Pierre Morel --- hw/vfio/ap.c | 10 ++++++++++ include/hw/s390x/ap-device.h | 9 +++++++++ target/s390x/kvm.c | 20 ++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index 3962bb74e5..d8d9cadc46 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -38,6 +38,16 @@ typedef struct VFIOAPDevice { #define VFIO_AP_DEVICE(obj) \ OBJECT_CHECK(VFIOAPDevice, (obj), VFIO_AP_DEVICE_TYPE) +/* + * ap_pqap + * @env: environment pointing to registers + * return value: Code Condition + */ +int ap_pqap(CPUS390XState *env) +{ + return -PGM_OPERATION; +} + static void vfio_ap_compute_needs_reset(VFIODevice *vdev) { vdev->needs_reset = false; diff --git a/include/hw/s390x/ap-device.h b/include/hw/s390x/ap-device.h index 765e9082a3..a83ea096c7 100644 --- a/include/hw/s390x/ap-device.h +++ b/include/hw/s390x/ap-device.h @@ -19,4 +19,13 @@ typedef struct APDevice { #define AP_DEVICE(obj) \ OBJECT_CHECK(APDevice, (obj), AP_DEVICE_TYPE) +#define AP_DEVICE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(APDeviceClass, (obj), AP_DEVICE_TYPE) + +#define AP_DEVICE_CLASS(klass) \ + OBJECT_CLASS_CHECK(APDeviceClass, (klass), AP_DEVICE_TYPE) + +#include "cpu.h" +int ap_pqap(CPUS390XState *env); + #endif /* HW_S390X_AP_DEVICE_H */ diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 2ebf26adfe..3eac59549d 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 #define PRIV_EB_SQBS 0x8a #define PRIV_EB_PCISTB 0xd0 @@ -1154,6 +1156,21 @@ static int kvm_sclp_service_call(S390CPU *cpu, struct kvm_run *run, return 0; } +static int kvm_ap_pqap(S390CPU *cpu, uint16_t ipbh0) +{ + int r; + + r = 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 = &cpu->env; @@ -1216,6 +1233,9 @@ static int handle_b2(S390CPU *cpu, struct kvm_run *run, uint8_t ipa1) case PRIV_B2_SCLP_CALL: rc = kvm_sclp_service_call(cpu, run, ipbh0); break; + case PRIV_B2_PQAP: + rc = kvm_ap_pqap(cpu, ipbh0); + break; default: rc = -1; DPRINTF("KVM: unhandled PRIV: 0xb2%x\n", ipa1); From patchwork Fri Nov 2 10:30:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10665257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7D7614BD for ; Fri, 2 Nov 2018 10:35:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BD0B2B619 for ; Fri, 2 Nov 2018 10:35:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F7412B948; Fri, 2 Nov 2018 10:35:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E3BF72B619 for ; Fri, 2 Nov 2018 10:35:33 +0000 (UTC) Received: from localhost ([::1]:50670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWnc-0006dY-T1 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Nov 2018 06:35:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIWj5-0001sJ-JG for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIWj2-0004HB-EL for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:51 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42018 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 1gIWj2-0004By-3n for qemu-devel@nongnu.org; Fri, 02 Nov 2018 06:30:48 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wA2ATFhE019043 for ; Fri, 2 Nov 2018 06:30:37 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ngm26j1sy-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Nov 2018 06:30:37 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 2 Nov 2018 10:30:35 -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, 2 Nov 2018 10:30:30 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wA2AUT8g57278482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 2 Nov 2018 10:30:29 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E52711C054; Fri, 2 Nov 2018 10:30:29 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B725E11C052; Fri, 2 Nov 2018 10:30:28 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.73]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 2 Nov 2018 10:30:28 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Date: Fri, 2 Nov 2018 11:30:21 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> References: <1541154621-22423-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18110210-0012-0000-0000-000002C2268C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18110210-0013-0000-0000-000020F65BCE Message-Id: <1541154621-22423-6-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-11-02_06:, , 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=860 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811020099 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 5/5] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 a new structure, APQueue to keep track of the route and indicator address and we add an array of AP Queues in the VFIOAPDevice. 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 | 92 +++++++++++++++++++++++++++++++++++- include/hw/s390x/ap-device.h | 46 ++++++++++++++++++ 2 files changed, 137 insertions(+), 1 deletion(-) diff --git a/hw/vfio/ap.c b/hw/vfio/ap.c index d8d9cadc46..67a46e163e 100644 --- a/hw/vfio/ap.c +++ b/hw/vfio/ap.c @@ -27,17 +27,90 @@ #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" #define VFIO_AP_DEVICE_TYPE "vfio-ap" typedef struct VFIOAPDevice { APDevice apdev; VFIODevice vdev; + QTAILQ_ENTRY(VFIOAPDevice) sibling; + APQueue apq[MAX_AP][MAX_DOMAIN]; } VFIOAPDevice; #define VFIO_AP_DEVICE(obj) \ OBJECT_CHECK(VFIOAPDevice, (obj), VFIO_AP_DEVICE_TYPE) +VFIOAPDevice *vfio_apdev; +static APDevice *matrix; + +static int ap_aqic(CPUS390XState *env) +{ + struct pqap_cmd cmd = reg2cmd(env->regs[0]); + struct ap_status status = reg2status(env->regs[1]); + uint64_t guest_nib = env->regs[2]; + struct vfio_ap_aqic param = {}; + int retval; + VFIODevice *vdev; + VFIOAPDevice *ap_vdev; + APQueue *apq; + + ap_vdev = DO_UPCAST(VFIOAPDevice, apdev, matrix); + apq = &ap_vdev->apq[cmd.apid][cmd.apqi]; + vdev = &ap_vdev->vdev; + + if (status.irq) { + if (apq->nib) { + status.rc = AP_RC_BAD_STATE; + goto error; + } + } else { + if (!apq->nib) { + status.rc = AP_RC_BAD_STATE; + goto error; + } + } + if (!guest_nib) { + status.rc = AP_RC_INVALID_ADDR; + goto error; + } + + apq->routes.adapter.adapter_id = css_get_adapter_id( + CSS_IO_ADAPTER_AP, status.isc); + + apq->nib = get_indicator(ldq_p(&guest_nib), 8); + + retval = map_indicator(&apq->routes.adapter, apq->nib); + if (retval) { + status.rc = AP_RC_INVALID_ADDR; + env->regs[1] = status2reg(status); + goto error; + } + + param.cmd = env->regs[0]; + param.status = env->regs[1]; + param.nib = env->regs[2]; + param.adapter_id = apq->routes.adapter.adapter_id; + param.argsz = sizeof(param); + + retval = ioctl(vdev->fd, VFIO_AP_SET_IRQ, ¶m); + status = reg2status(param.status); + if (retval) { + goto err_ioctl; + } + + env->regs[1] = param.status; + + return 0; +err_ioctl: + release_indicator(&apq->routes.adapter, apq->nib); + apq->nib = NULL; +error: + env->regs[1] = status2reg(status); + return 0; +} + /* * ap_pqap * @env: environment pointing to registers @@ -45,7 +118,20 @@ typedef struct VFIOAPDevice { */ int ap_pqap(CPUS390XState *env) { - return -PGM_OPERATION; + struct pqap_cmd cmd = reg2cmd(env->regs[0]); + int cc = 0; + + switch (cmd.fc) { + case AQIC: + if (!s390_has_feat(S390_FEAT_AP_QUEUE_INTERRUPT_CONTROL)) { + return -PGM_OPERATION; + } + cc = ap_aqic(env); + break; + default: + return -PGM_OPERATION; + } + return cc; } static void vfio_ap_compute_needs_reset(VFIODevice *vdev) @@ -119,6 +205,9 @@ static void vfio_ap_realize(DeviceState *dev, Error **errp) goto out_get_dev_err; } + matrix = apdev; + css_register_io_adapters(CSS_IO_ADAPTER_AP, true, false, + 0, &error_abort); return; out_get_dev_err: @@ -135,6 +224,7 @@ static void vfio_ap_unrealize(DeviceState *dev, Error **errp) VFIOGroup *group = vapdev->vdev.group; vfio_ap_put_device(vapdev); + matrix = NULL; vfio_put_group(group); } diff --git a/include/hw/s390x/ap-device.h b/include/hw/s390x/ap-device.h index a83ea096c7..bc2b7bcd8e 100644 --- a/include/hw/s390x/ap-device.h +++ b/include/hw/s390x/ap-device.h @@ -28,4 +28,50 @@ typedef struct APDevice { #include "cpu.h" int ap_pqap(CPUS390XState *env); +#define MAX_AP 256 +#define MAX_DOMAIN 256 + +#include "hw/s390x/s390_flic.h" +#include "hw/s390x/css.h" +typedef struct APQueue { + uint32_t apid; + uint32_t apqi; + AdapterRoutes routes; + IndAddr *nib; +} APQueue; + +/* AP PQAP commands definitions */ +#define AQIC 0x03 + +struct pqap_cmd { + uint32_t unused; + uint8_t fc; + unsigned t:1; + unsigned reserved:7; + uint8_t apid; + uint8_t apqi; +}; +/* AP status returned by the AP PQAP commands */ +#define AP_RC_APQN_INVALID 0x01 +#define AP_RC_INVALID_ADDR 0x06 +#define AP_RC_BAD_STATE 0x07 + +struct ap_status { + uint16_t pad; + unsigned irq:1; + unsigned pad2:15; + unsigned e:1; + unsigned r:1; + unsigned f:1; + unsigned unused:4; + unsigned i:1; + unsigned char rc; + unsigned reserved:13; + unsigned isc:3; +}; + +#define reg2cmd(reg) (*(struct pqap_cmd *)&(reg)) +#define status2reg(status) (*((uint64_t *)&status)) +#define reg2status(reg) (*(struct ap_status *)&(reg)) + #endif /* HW_S390X_AP_DEVICE_H */