From patchwork Wed Oct 31 18:12:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10663159 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 EEEFA14DE for ; Wed, 31 Oct 2018 18:13:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF6362B576 for ; Wed, 31 Oct 2018 18:13:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D32D12B594; Wed, 31 Oct 2018 18:13:09 +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 88B412B576 for ; Wed, 31 Oct 2018 18:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730105AbeKADMO (ORCPT ); Wed, 31 Oct 2018 23:12:14 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44880 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730097AbeKADMN (ORCPT ); Wed, 31 Oct 2018 23:12:13 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9VIAweL114621 for ; Wed, 31 Oct 2018 14:13:06 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nff64xhh1-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 31 Oct 2018 14:13:05 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Oct 2018 18:13:04 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) 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) Wed, 31 Oct 2018 18:13:00 -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 w9VICxJ840239260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Oct 2018 18:12:59 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3726311C054; Wed, 31 Oct 2018 18:12:59 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C2A7E11C04C; Wed, 31 Oct 2018 18:12:58 +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; Wed, 31 Oct 2018 18:12:58 +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 v1 1/7] vfio: ap: Add AP Queue Interruption Control facility Date: Wed, 31 Oct 2018 19:12:51 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> References: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18103118-0028-0000-0000-00000310C4D0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18103118-0029-0000-0000-000023CCF655 Message-Id: <1541009577-29656-2-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-31_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=847 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810310150 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 fd788e0f2e5b..18d317da02f5 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 Wed Oct 31 18:12:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10663169 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 2F9BB15E9 for ; Wed, 31 Oct 2018 18:13:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E86D2918F for ; Wed, 31 Oct 2018 18:13:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1313129236; Wed, 31 Oct 2018 18:13:37 +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 E94FB2918F for ; Wed, 31 Oct 2018 18:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730270AbeKADMm (ORCPT ); Wed, 31 Oct 2018 23:12:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:48732 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730056AbeKADMN (ORCPT ); Wed, 31 Oct 2018 23:12:13 -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 w9VIA5xc136811 for ; Wed, 31 Oct 2018 14:13:05 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nfh1h19ak-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 31 Oct 2018 14:13:05 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Oct 2018 18:13:04 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) 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) Wed, 31 Oct 2018 18:13:02 -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 w9VID0Wd6881694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Oct 2018 18:13:00 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB54B11C058; Wed, 31 Oct 2018 18:13:00 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 436E811C050; Wed, 31 Oct 2018 18:13:00 +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; Wed, 31 Oct 2018 18:13:00 +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 v1 2/7] vfio: ap: VFIO AP Queue Interrupt Control Date: Wed, 31 Oct 2018 19:12:52 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> References: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18103118-0012-0000-0000-000002C13608 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18103118-0013-0000-0000-000020F5635B Message-Id: <1541009577-29656-3-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-31_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=884 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810310150 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 | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index f378b9802d8b..f13079bb28af 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/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 /* _UAPIVFIO_H */ From patchwork Wed Oct 31 18:12:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10663167 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 9AE9114DE for ; Wed, 31 Oct 2018 18:13:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CA4F2918F for ; Wed, 31 Oct 2018 18:13:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8070129236; Wed, 31 Oct 2018 18:13: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 187AE2918F for ; Wed, 31 Oct 2018 18:13:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730125AbeKADMS (ORCPT ); Wed, 31 Oct 2018 23:12:18 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50572 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730101AbeKADMR (ORCPT ); Wed, 31 Oct 2018 23:12:17 -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 w9VIAZTW004989 for ; Wed, 31 Oct 2018 14:13:09 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nff6975vt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 31 Oct 2018 14:13:09 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Oct 2018 18:13:07 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) 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) Wed, 31 Oct 2018 18:13:03 -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 w9VID27m59375728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Oct 2018 18:13:02 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1946111C052; Wed, 31 Oct 2018 18:13:02 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B81C111C04C; Wed, 31 Oct 2018 18:13:01 +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; Wed, 31 Oct 2018 18:13:01 +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 v1 3/7] vfio: ap: AP Queue Interrupt structures definitions Date: Wed, 31 Oct 2018 19:12:53 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> References: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18103118-0028-0000-0000-00000310C4D1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18103118-0029-0000-0000-000023CCF657 Message-Id: <1541009577-29656-4-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-31_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-1810310150 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 all the structures we need to let GISA handle the AP Queues Interrupt. This patch defines the inline assembler for AP Queue Interrupt Control instruction with GISA, some utilities to manipulate the data in the registers used by this instruction. We also define new ap_matrix components to handle interruptions and adapter mapping. Signed-off-by: Pierre Morel --- drivers/s390/crypto/vfio_ap_private.h | 77 +++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h index 5675492233c7..45103865bd7f 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -74,15 +74,92 @@ struct ap_matrix { * @group_notifier: notifier block used for specifying callback function for * handling the VFIO_GROUP_NOTIFY_SET_KVM event * @kvm: the struct holding guest's state + * @map: the adapter information for QEMU mapping + * @gisc: the Guest ISC */ struct ap_matrix_mdev { struct list_head node; struct ap_matrix matrix; struct notifier_block group_notifier; struct kvm *kvm; + struct s390_map_info *map; + unsigned char gisc; }; extern int vfio_ap_mdev_register(void); extern void vfio_ap_mdev_unregister(void); +/* AP Queue Interrupt Control associated structures and functions */ +struct aqic_gisa { + uint8_t rzone; + uint8_t izone; + unsigned ir:1; + unsigned reserved1:4; + unsigned gisc:3; + unsigned reserved2:6; + unsigned f:2; + unsigned reserved3:1; + unsigned gisao:27; + unsigned t:1; + unsigned isc:3; +} __packed __aligned(8); + +struct ap_status { + unsigned e:1; + unsigned r:1; + unsigned f:1; + unsigned reserved:4; + unsigned i:1; + unsigned rc:8; + unsigned pad:16; +} __packed __aligned(4); + +static inline uint32_t status2reg(struct ap_status a) +{ + return *(uint32_t *)(&a); +} + +static inline struct ap_status reg2status(uint32_t r) +{ + return *(struct ap_status *)(&r); +} + +static inline struct aqic_gisa reg2aqic(uint64_t r) +{ + return *((struct aqic_gisa *)&r); +} + +static inline uint64_t aqic2reg(struct aqic_gisa a) +{ + return *((uint64_t *)&a); +} + +/** + * ap_host_aqic - Issue the host AQIC instruction. + * @apqn is the AP queue number + * @gr1 the caller must have setup the register + * with GISA address and format, with interrupt + * request, ISC and guest ISC + * @gr2 the caller must have setup the register + * to the guest NIB physical address + * + * issue the AQIC PQAP instruction and return the AP status + * word + */ +static inline uint32_t ap_host_aqic(uint64_t apqn, uint64_t gr1, + uint64_t gr2) +{ + register unsigned long reg0 asm ("0") = apqn | (3UL << 24); + register unsigned long reg1_in asm ("1") = gr1; + register uint32_t reg1_out asm ("1"); + register unsigned long reg2 asm ("2") = gr2; + + asm volatile( + ".long 0xb2af0000" /* PQAP(AQIC) */ + : "+d" (reg0), "+d" (reg1_in), "=d" (reg1_out), "+d" (reg2) + : + : "cc"); + return reg1_out; +} + #endif /* _VFIO_AP_PRIVATE_H_ */ From patchwork Wed Oct 31 18:12:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10663171 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 3689C15E9 for ; Wed, 31 Oct 2018 18:14:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26D0D2ADE5 for ; Wed, 31 Oct 2018 18:14:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A69B2AE1C; Wed, 31 Oct 2018 18:14:04 +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 999342ADE5 for ; Wed, 31 Oct 2018 18:14:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730005AbeKADNJ (ORCPT ); Wed, 31 Oct 2018 23:13:09 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58826 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729206AbeKADNJ (ORCPT ); Wed, 31 Oct 2018 23:13:09 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9VIBEv9024144 for ; Wed, 31 Oct 2018 14:14:01 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nfek98w5x-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 31 Oct 2018 14:13:30 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Oct 2018 18:13:08 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) 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) Wed, 31 Oct 2018 18:13:05 -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 w9VID3Nd57344114 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Oct 2018 18:13:03 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F09A11C054; Wed, 31 Oct 2018 18:13:03 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3022811C050; Wed, 31 Oct 2018 18:13:03 +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; Wed, 31 Oct 2018 18:13:03 +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 v1 4/7] vfio: ap: AP Queue Interrupt Control VFIO ioctl calls Date: Wed, 31 Oct 2018 19:12:54 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> References: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18103118-0012-0000-0000-000002C1360B X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18103118-0013-0000-0000-000020F5635D Message-Id: <1541009577-29656-5-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-31_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-1810310150 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 | 95 +++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 272ef427dcc0..f68102163bf4 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -895,12 +895,107 @@ static int vfio_ap_mdev_get_device_info(unsigned long arg) return copy_to_user((void __user *)arg, &info, minsz); } +static int ap_ioctl_setirq(struct ap_matrix_mdev *matrix_mdev, + struct vfio_ap_aqic *parm) +{ + struct aqic_gisa aqic_gisa = reg2aqic(0); + struct kvm_s390_gisa *gisa = matrix_mdev->kvm->arch.gisa; + struct ap_status ap_status = reg2status(0); + unsigned long p; + int ret = -1; + int apqn; + uint32_t gd; + + apqn = (int)(parm->cmd & 0xffff); + + gd = matrix_mdev->kvm->vcpus[0]->arch.sie_block->gd; + if (gd & 0x01) + aqic_gisa.f = 1; + aqic_gisa.gisc = matrix_mdev->gisc; + aqic_gisa.isc = GAL_ISC; + aqic_gisa.ir = 1; + aqic_gisa.gisao = gisa->next_alert >> 4; + + p = (unsigned long) page_address(matrix_mdev->map->page); + p += (matrix_mdev->map->guest_addr & 0x0fff); + + ret = ap_host_aqic((uint64_t)apqn, aqic2reg(aqic_gisa), p); + parm->status = ret; + + ap_status = reg2status(ret); + return (ap_status.rc) ? -EIO : 0; +} + +static int ap_ioctl_clrirq(struct ap_matrix_mdev *matrix_mdev, + struct vfio_ap_aqic *parm) +{ + struct aqic_gisa aqic_gisa = reg2aqic(0); + struct ap_status ap_status = reg2status(0); + int apqn; + int retval; + uint32_t gd; + + apqn = (int)(parm->cmd & 0xffff); + + gd = matrix_mdev->kvm->vcpus[0]->arch.sie_block->gd; + if (gd & 0x01) + aqic_gisa.f = 1; + aqic_gisa.ir = 0; + + retval = ap_host_aqic((uint64_t)apqn, aqic2reg(aqic_gisa), 0); + parm->status = retval; + + ap_status = reg2status(retval); + return (ap_status.rc) ? -EIO : 0; +} + static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev, unsigned int cmd, unsigned long arg) { int ret; + struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev); + struct s390_io_adapter *adapter; + struct vfio_ap_aqic parm; + struct s390_map_info *map; + int apqn, found = 0; switch (cmd) { + case VFIO_AP_SET_IRQ: + if (copy_from_user(&parm, (void __user *)arg, sizeof(parm))) + return -EFAULT; + apqn = (int)(parm.cmd & 0xffff); + parm.status &= 0x00000000ffffffffUL; + matrix_mdev->gisc = parm.status & 0x07; + /* find the adapter */ + adapter = matrix_mdev->kvm->arch.adapters[parm.adapter_id]; + if (!adapter) + return -ENOENT; + 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 -EINVAL; + + matrix_mdev->map = map; + ret = ap_ioctl_setirq(matrix_mdev, &parm); + parm.status &= 0x00000000ffffffffUL; + if (copy_to_user((void __user *)arg, &parm, sizeof(parm))) + return -EFAULT; + + break; + case VFIO_AP_CLEAR_IRQ: + if (copy_from_user(&parm, (void __user *)arg, sizeof(parm))) + return -EFAULT; + ret = ap_ioctl_clrirq(matrix_mdev, &parm); + if (copy_to_user((void __user *)arg, &parm, sizeof(parm))) + return -EFAULT; + break; case VFIO_DEVICE_GET_INFO: ret = vfio_ap_mdev_get_device_info(arg); break; From patchwork Wed Oct 31 18:12:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10663163 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 0C95215E9 for ; Wed, 31 Oct 2018 18:13:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F37D229236 for ; Wed, 31 Oct 2018 18:13:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6D22294A9; Wed, 31 Oct 2018 18:13: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 vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 928E129236 for ; Wed, 31 Oct 2018 18:13:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730247AbeKADM2 (ORCPT ); Wed, 31 Oct 2018 23:12:28 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37072 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730189AbeKADMU (ORCPT ); Wed, 31 Oct 2018 23:12:20 -0400 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 w9VIA4Vq104602 for ; Wed, 31 Oct 2018 14:13:13 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2nffw0vjmn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 31 Oct 2018 14:13:12 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Oct 2018 18:13:10 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 31 Oct 2018 18:13:06 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9VID54e60424238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Oct 2018 18:13:05 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0591011C05C; Wed, 31 Oct 2018 18:13:05 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9BC5711C052; Wed, 31 Oct 2018 18:13:04 +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; Wed, 31 Oct 2018 18:13:04 +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 v1 5/7] s390: kvm: export GIB registration Date: Wed, 31 Oct 2018 19:12:55 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> References: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18103118-4275-0000-0000-000002D743D8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18103118-4276-0000-0000-000037E44CCE Message-Id: <1541009577-29656-6-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-31_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=869 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810310150 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Define the GIB Alert registration for external users inside the standrd kvm_host.h header file. Signed-off-by: Pierre Morel --- arch/s390/include/asm/kvm_host.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/s390/include/asm/kvm_host.h b/arch/s390/include/asm/kvm_host.h index 512ea9f200fa..7e76a56da72d 100644 --- a/arch/s390/include/asm/kvm_host.h +++ b/arch/s390/include/asm/kvm_host.h @@ -902,4 +902,7 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu) {} void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu); +extern int kvm_s390_gisc_register(struct kvm *kvm, u32 gisc); +extern int kvm_s390_gisc_unregister(struct kvm *kvm, u32 gisc); + #endif From patchwork Wed Oct 31 18:12:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10663173 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 BF6AF13A4 for ; Wed, 31 Oct 2018 18:23:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADCAB28A1D for ; Wed, 31 Oct 2018 18:23:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A08DE28CE7; Wed, 31 Oct 2018 18:23: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 vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 470D728A1D for ; Wed, 31 Oct 2018 18:23:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730259AbeKADWi (ORCPT ); Wed, 31 Oct 2018 23:22:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51744 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730097AbeKADWd (ORCPT ); Wed, 31 Oct 2018 23:22:33 -0400 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 w9VIFTmq132073 for ; Wed, 31 Oct 2018 14:23:23 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nfgkfu0m2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 31 Oct 2018 14:23:23 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Oct 2018 18:13:09 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 31 Oct 2018 18:13:08 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9VID6PN4981004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Oct 2018 18:13:06 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 70FA011C058; Wed, 31 Oct 2018 18:13:06 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1AA7B11C04C; Wed, 31 Oct 2018 18:13:06 +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; Wed, 31 Oct 2018 18:13:06 +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 v1 6/7] vfio: ap: register guest ISC with GISA and GIB Date: Wed, 31 Oct 2018 19:12:56 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> References: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18103118-0028-0000-0000-00000310C4D5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18103118-0029-0000-0000-000023CCF65A Message-Id: <1541009577-29656-7-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-31_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=889 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810310151 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Register to the GIB Alert list and retrieve the GAL_ISC to pass to the GISA registration. Unregister on error and when clearing the interrupt. Signed-off-by: Pierre Morel Signed-off-by: Michael Mueller --- drivers/s390/crypto/vfio_ap_ops.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index f68102163bf4..232168797fb8 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -903,16 +903,20 @@ static int ap_ioctl_setirq(struct ap_matrix_mdev *matrix_mdev, struct ap_status ap_status = reg2status(0); unsigned long p; int ret = -1; - int apqn; + int apqn, gal_isc; uint32_t gd; + gal_isc = kvm_s390_gisc_register(matrix_mdev->kvm, matrix_mdev->gisc); + if (gal_isc < 0) + return -EIO; + apqn = (int)(parm->cmd & 0xffff); gd = matrix_mdev->kvm->vcpus[0]->arch.sie_block->gd; if (gd & 0x01) aqic_gisa.f = 1; aqic_gisa.gisc = matrix_mdev->gisc; - aqic_gisa.isc = GAL_ISC; + aqic_gisa.isc = gal_isc; aqic_gisa.ir = 1; aqic_gisa.gisao = gisa->next_alert >> 4; @@ -923,7 +927,11 @@ static int ap_ioctl_setirq(struct ap_matrix_mdev *matrix_mdev, parm->status = ret; ap_status = reg2status(ret); - return (ap_status.rc) ? -EIO : 0; + if (ap_status.rc) { + kvm_s390_gisc_unregister(matrix_mdev->kvm, matrix_mdev->gisc); + return -EIO; + } + return 0; } static int ap_ioctl_clrirq(struct ap_matrix_mdev *matrix_mdev, @@ -946,6 +954,8 @@ static int ap_ioctl_clrirq(struct ap_matrix_mdev *matrix_mdev, parm->status = retval; ap_status = reg2status(retval); + /* unregister the IAM from the GIB anyway! */ + kvm_s390_gisc_unregister(matrix_mdev->kvm, matrix_mdev->gisc); return (ap_status.rc) ? -EIO : 0; } From patchwork Wed Oct 31 18:12:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 10663161 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 CBA8714DE for ; Wed, 31 Oct 2018 18:13:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD81E2B57A for ; Wed, 31 Oct 2018 18:13:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B1C332B595; Wed, 31 Oct 2018 18:13:18 +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 64E632B57A for ; Wed, 31 Oct 2018 18:13:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730243AbeKADMX (ORCPT ); Wed, 31 Oct 2018 23:12:23 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49954 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730182AbeKADMX (ORCPT ); Wed, 31 Oct 2018 23:12:23 -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 w9VIA2l9010935 for ; Wed, 31 Oct 2018 14:13:15 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2nffynm8qu-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 31 Oct 2018 14:13:14 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Oct 2018 18:13:12 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) 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) Wed, 31 Oct 2018 18:13:09 -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 w9VID89463307894 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 31 Oct 2018 18:13:08 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E720111C05B; Wed, 31 Oct 2018 18:13:07 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8848611C04A; Wed, 31 Oct 2018 18:13:07 +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; Wed, 31 Oct 2018 18:13:07 +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 v1 7/7] s390: kvm: Handle all GISA IPM bits through GISA Date: Wed, 31 Oct 2018 19:12:57 +0100 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> References: <1541009577-29656-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18103118-0020-0000-0000-000002DDB50D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18103118-0021-0000-0000-0000212D0C86 Message-Id: <1541009577-29656-8-git-send-email-pmorel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-31_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=841 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810310150 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we use GISA and GIB we can handle all IPM bits from GISA directly from firmware. They will be interpreted on SIE entry or during guest run. We remove them from the pending_irqs() test. Signed-off-by: Pierre Morel --- arch/s390/kvm/interrupt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c index 6d0193173388..3174d9946523 100644 --- a/arch/s390/kvm/interrupt.c +++ b/arch/s390/kvm/interrupt.c @@ -248,8 +248,7 @@ static inline unsigned long pending_irqs_no_gisa(struct kvm_vcpu *vcpu) static inline unsigned long pending_irqs(struct kvm_vcpu *vcpu) { - return pending_irqs_no_gisa(vcpu) | - kvm_s390_gisa_get_ipm(vcpu->kvm->arch.gisa) << IRQ_PEND_IO_ISC_7; + return pending_irqs_no_gisa(vcpu); } static inline int isc_to_irq_type(unsigned long isc)