From patchwork Thu Nov 22 17:11:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10694567 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 4AB6C13BB for ; Thu, 22 Nov 2018 17:11:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DDFF2CDBD for ; Thu, 22 Nov 2018 17:11:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 21E0F2CE0B; Thu, 22 Nov 2018 17:11:27 +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 vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C833C2CDE1 for ; Thu, 22 Nov 2018 17:11:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406281AbeKWDvl (ORCPT ); Thu, 22 Nov 2018 22:51:41 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39590 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392238AbeKWDvk (ORCPT ); Thu, 22 Nov 2018 22:51:40 -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 wAMH9CpB031094 for ; Thu, 22 Nov 2018 12:11:23 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nwxd65s7h-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 12:11:23 -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 17:11:21 -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 17:11:19 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAMHBHCP60489738 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Nov 2018 17:11:17 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 65F3442049; Thu, 22 Nov 2018 17:11:17 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0C464203F; Thu, 22 Nov 2018 17:11:16 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.168]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Nov 2018 17:11:16 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Cc: alex.williamson@redhat.com, cohuck@redhat.com, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, frankja@linux.ibm.com, akrowiak@linux.ibm.com, pasic@linux.ibm.com, david@redhat.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, freude@linux.ibm.com, mimu@linux.ibm.com Subject: [PATCH v2 1/3] vfio: ap: Add AP Queue Interruption Control facility Date: Thu, 22 Nov 2018 18:11:13 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542906675-7949-1-git-send-email-pmorel@linux.ibm.com> References: <1542906675-7949-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112217-0008-0000-0000-0000029701E5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112217-0009-0000-0000-000022013788 Message-Id: <1542906675-7949-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=884 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220153 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP AP Queue Interruption Control (AQIC) facility gives the guest the possibility to control interruption for the Cryptographic Adjunct Processor queues Signed-off-by: Pierre Morel Reviewed-by: Tony Krowiak --- arch/s390/tools/gen_facilities.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/s390/tools/gen_facilities.c b/arch/s390/tools/gen_facilities.c index fd788e0..18d317d 100644 --- a/arch/s390/tools/gen_facilities.c +++ b/arch/s390/tools/gen_facilities.c @@ -108,6 +108,7 @@ static struct facility_def facility_defs[] = { .bits = (int[]){ 12, /* AP Query Configuration Information */ 15, /* AP Facilities Test */ + 65, /* AP Queue Interruption Control */ 156, /* etoken facility */ -1 /* END */ } From patchwork Thu Nov 22 17:11:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10694571 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 6648E14DE for ; Thu, 22 Nov 2018 17:11:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 488CD2CDE3 for ; Thu, 22 Nov 2018 17:11:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C4112CE0B; Thu, 22 Nov 2018 17:11:35 +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 vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C906A2CDBF for ; Thu, 22 Nov 2018 17:11:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406283AbeKWDvn (ORCPT ); Thu, 22 Nov 2018 22:51:43 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37056 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2392238AbeKWDvn (ORCPT ); Thu, 22 Nov 2018 22:51:43 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wAMH9Btj023834 for ; Thu, 22 Nov 2018 12:11:25 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nwxtamr93-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 12:11:25 -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 17:11:23 -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 17:11:20 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAMHBJBE61538384 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Nov 2018 17:11:19 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E4A0F42047; Thu, 22 Nov 2018 17:11:18 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 751624203F; Thu, 22 Nov 2018 17:11:18 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.168]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Nov 2018 17:11:18 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Cc: alex.williamson@redhat.com, cohuck@redhat.com, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, frankja@linux.ibm.com, akrowiak@linux.ibm.com, pasic@linux.ibm.com, david@redhat.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, freude@linux.ibm.com, mimu@linux.ibm.com Subject: [PATCH v2 2/3] vfio: ap: ioctl definitions for AP Queue Interrupt Control Date: Thu, 22 Nov 2018 18:11:14 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542906675-7949-1-git-send-email-pmorel@linux.ibm.com> References: <1542906675-7949-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112217-0008-0000-0000-0000029701E6 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112217-0009-0000-0000-000022013789 Message-Id: <1542906675-7949-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=871 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220153 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We define two VFIO ioctl command to setup and clear the AP Queues interrupt. Arguments passed by the guest are: - the apqn, AP queue number - the Notification by address - the identifier of the previously associated adapter Signed-off-by: Pierre Morel --- include/uapi/linux/vfio.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index 8131028..9a1b350 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -866,6 +866,31 @@ 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; + /* 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) + /* ***************************************************************** */ + #endif /* _UAPIVFIO_H */ From patchwork Thu Nov 22 17:11:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10694569 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 1E04A14DE for ; Thu, 22 Nov 2018 17:11:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F40482CB63 for ; Thu, 22 Nov 2018 17:11:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E853A2CC7B; Thu, 22 Nov 2018 17:11:31 +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 vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 782692CDE3 for ; Thu, 22 Nov 2018 17:11:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406303AbeKWDvp (ORCPT ); Thu, 22 Nov 2018 22:51:45 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38606 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406285AbeKWDvo (ORCPT ); Thu, 22 Nov 2018 22:51:44 -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 wAMH9Ddq144200 for ; Thu, 22 Nov 2018 12:11:27 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nwxjx5b47-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 22 Nov 2018 12:11:27 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 22 Nov 2018 17:11:24 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 22 Nov 2018 17:11:22 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id wAMHBKCt56492100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Nov 2018 17:11:20 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F74642045; Thu, 22 Nov 2018 17:11:20 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F361D4203F; Thu, 22 Nov 2018 17:11:19 +0000 (GMT) Received: from morel-ThinkPad-W530.boeblingen.de.ibm.com (unknown [9.152.224.168]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 22 Nov 2018 17:11:19 +0000 (GMT) From: Pierre Morel To: borntraeger@de.ibm.com Cc: alex.williamson@redhat.com, cohuck@redhat.com, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, frankja@linux.ibm.com, akrowiak@linux.ibm.com, pasic@linux.ibm.com, david@redhat.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, freude@linux.ibm.com, mimu@linux.ibm.com Subject: [PATCH v2 3/3] vfio: ap: AP Queue Interrupt Control VFIO ioctl calls Date: Thu, 22 Nov 2018 18:11:15 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542906675-7949-1-git-send-email-pmorel@linux.ibm.com> References: <1542906675-7949-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18112217-0028-0000-0000-0000031EF78E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18112217-0029-0000-0000-000023DB0552 Message-Id: <1542906675-7949-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=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=984 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811220153 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is the implementation of the VFIO ioctl calls to handle the AQIC interception and use GISA to handle interrupts. Signed-off-by: Pierre Morel --- drivers/s390/crypto/vfio_ap_ops.c | 110 +++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 1 deletion(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 272ef42..f6e942f 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -895,12 +895,121 @@ static int vfio_ap_mdev_get_device_info(unsigned long arg) return copy_to_user((void __user *)arg, &info, minsz); } +static unsigned long vfio_ap_get_nib(struct kvm *kvm, struct vfio_ap_aqic *parm) +{ + struct s390_io_adapter *adapter; + struct s390_map_info *map; + unsigned long nib; + int found = 0; + + /* find the adapter */ + if (parm->adapter_id > MAX_S390_IO_ADAPTERS) + return 0; + + adapter = kvm->arch.adapters[parm->adapter_id]; + if (!adapter) + return 0; + + down_write(&adapter->maps_lock); + list_for_each_entry(map, &adapter->maps, list) { + if (map->guest_addr == parm->nib) { + found = 1; + break; + } + } + up_write(&adapter->maps_lock); + + if (!found) + return 0; + + nib = (unsigned long) page_address(map->page); + nib += (map->guest_addr & 0x0fff); + + return nib; +} + +static int vfio_ap_ioctl_setirq(struct mdev_device *mdev, unsigned long arg) +{ + struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev); + struct vfio_ap_aqic parm; + struct ap_qirq_ctrl aqic_gisa = {}; + struct kvm *kvm = matrix_mdev->kvm; + struct kvm_s390_gisa *gisa = kvm->arch.gisa; + struct ap_queue_status ap_status; + unsigned long nib; + + if (copy_from_user(&parm, (void __user *)arg, sizeof(parm))) + return -EFAULT; + + if (parm.isc > MAX_ISC) + return -EINVAL; + + if (kvm->vcpus[0]->arch.sie_block->gd & 0x01) + aqic_gisa.gf = 1; + + nib = vfio_ap_get_nib(kvm, &parm); + if (!nib) + return -ENODEV; + + aqic_gisa.gisc = parm.isc; + aqic_gisa.isc = kvm_s390_gisc_register(kvm, parm.isc); + aqic_gisa.ir = 1; + aqic_gisa.gisa = gisa->next_alert >> 4; + + ap_status = ap_aqic(parm.apqn, aqic_gisa, (void *)nib); + parm.status = *(uint32_t *)(&ap_status); + + if (copy_to_user((void __user *)arg, &parm, sizeof(parm))) { + kvm_s390_gisc_unregister(kvm, parm.isc); + return -EFAULT; + } + + if (ap_status.response_code) { + kvm_s390_gisc_unregister(kvm, parm.isc); + return -EIO; + } + + return 0; +} + +static int vfio_ap_ioctl_clrirq(struct mdev_device *mdev, unsigned long arg) +{ + struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev); + struct vfio_ap_aqic parm; + struct ap_qirq_ctrl aqic_gisa = {}; + struct ap_queue_status ap_status; + struct kvm *kvm = matrix_mdev->kvm; + + if (copy_from_user(&parm, (void __user *)arg, sizeof(parm))) + return -EFAULT; + + if (kvm->vcpus[0]->arch.sie_block->gd & 0x01) + aqic_gisa.gf = 1; + aqic_gisa.ir = 0; + + ap_status = ap_aqic(parm.apqn, aqic_gisa, NULL); + parm.status = *(uint32_t *)(&ap_status); + + kvm_s390_gisc_unregister(kvm, parm.isc); + + if (copy_to_user((void __user *)arg, &parm, sizeof(parm))) + return -EFAULT; + + return (ap_status.response_code) ? -EIO : 0; +} + static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev, unsigned int cmd, unsigned long arg) { int ret; switch (cmd) { + case VFIO_AP_SET_IRQ: + ret = vfio_ap_ioctl_setirq(mdev, arg); + break; + case VFIO_AP_CLEAR_IRQ: + ret = vfio_ap_ioctl_clrirq(mdev, arg); + break; case VFIO_DEVICE_GET_INFO: ret = vfio_ap_mdev_get_device_info(arg); break; @@ -911,7 +1020,6 @@ static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev, ret = -EOPNOTSUPP; break; } - return ret; }