Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp911850imm; Wed, 8 Aug 2018 07:47:22 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxrrt7hoiDelnv+pT26QXZCpwp8wRyxtiixyz66EUOZ3ToC9vRG/sUbEjUDizO9uOx4nIhH X-Received: by 2002:a17:902:28a6:: with SMTP id f35-v6mr2852152plb.240.1533739642156; Wed, 08 Aug 2018 07:47:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533739642; cv=none; d=google.com; s=arc-20160816; b=pANMazWcdTyW4Rk5f/nQADmCZwcIGE9OdAF65bArxMCtIc/qpO2K7Nn/pP282rJRfU q7pDPVPL2IpjAyWRelpFBY4wmpOqMcf6owno15DEpH1Hr24ZXZApScwmUObhSQXEMpy3 JAmRRWITHm5dNbFSVhAQ9jm7xcqHzzaXHeiePOZijdVpHqYRRuAAGLQCthz+n1khBaEn r0LGRwpjaLQitgG7h4oeIPSFA5p3IxYOce/EROzXxfSyVAwJ5TMf8wZ02akDHHXqEa2E LbY6jZ//16UVp/GMwMRLkIjp+Mgn1B2T2klSfRJCenEX1SLj70duDNdP6K4skxXZPqfn QZUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=3DRiGPzL6vuISMWtntcwWhqbJIGlMu4Cuu4kwjfk7ws=; b=D8d2RjiMLosIVK260h5wMNR58IbAfDVaw5cPiTwpN7G8ZuUw37MCxGYyosRxArlXRC LnL/ZA8UcweBqbDdYgVL/zk+8imqmWzo5n4wm7Om6uQ2fbmBGkgLzvE1fqJlEveqvAYT jJbgmeebI1nwXsEnD43PGNopwA5fLAiwIUJmIgfF73lKpjehnmP7Y6gAVRJKj8n6CKbp o8X7Uh8pLrTl8ky/rasOAo9sG/QbZruFubfpkZ5xrhVr8pn6FOOSuT+d5t2V5eBMhUhJ ezZDgAwvXSgnMrvDJ9zcdaYHEupIFIJM1VsTflnBuksqZwwLu0hXT07od2WYyIOEdyYG GB+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q18-v6si3393312plr.134.2018.08.08.07.47.07; Wed, 08 Aug 2018 07:47:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728400AbeHHRFE (ORCPT + 99 others); Wed, 8 Aug 2018 13:05:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37136 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728304AbeHHRFD (ORCPT ); Wed, 8 Aug 2018 13:05:03 -0400 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 w78EiOcI016586 for ; Wed, 8 Aug 2018 10:45:05 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kr1ew3bgp-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 08 Aug 2018 10:45:05 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 8 Aug 2018 10:45:03 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 8 Aug 2018 10:45:00 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w78EiwGt53280798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 8 Aug 2018 14:44:58 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBDB828064; Wed, 8 Aug 2018 10:43:46 -0400 (EDT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C89852805E; Wed, 8 Aug 2018 10:43:45 -0400 (EDT) Received: from localhost.localdomain (unknown [9.85.187.56]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTPS; Wed, 8 Aug 2018 10:43:45 -0400 (EDT) From: Tony Krowiak To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, cohuck@redhat.com, kwankhede@nvidia.com, bjsdjshi@linux.vnet.ibm.com, pbonzini@redhat.com, alex.williamson@redhat.com, pmorel@linux.vnet.ibm.com, alifm@linux.vnet.ibm.com, mjrosato@linux.vnet.ibm.com, jjherne@linux.vnet.ibm.com, thuth@redhat.com, pasic@linux.vnet.ibm.com, berrange@redhat.com, fiuczy@linux.vnet.ibm.com, buendgen@de.ibm.com, akrowiak@linux.vnet.ibm.com, frankja@linux.ibm.com, Tony Krowiak Subject: [PATCH v8 16/22] s390: vfio-ap: implement VFIO_DEVICE_GET_INFO ioctl Date: Wed, 8 Aug 2018 10:44:26 -0400 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1533739472-7172-1-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1533739472-7172-1-git-send-email-akrowiak@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18080814-0068-0000-0000-000003257AC2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009507; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01070983; UDB=6.00551366; IPR=6.00850513; MB=3.00022589; MTD=3.00000008; XFM=3.00000015; UTC=2018-08-08 14:45:02 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18080814-0069-0000-0000-000045526DA2 Message-Id: <1533739472-7172-17-git-send-email-akrowiak@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-08_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1808080153 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tony Krowiak Introduces ioctl access to the VFIO AP Matrix device driver by implementing the VFIO_DEVICE_GET_INFO ioctl. This ioctl provides the VFIO AP Matrix device driver information to the guest machine. Signed-off-by: Tony Krowiak Reviewed-by: Pierre Morel Acked-by: Halil Pasic Tested-by: Michael Mueller Tested-by: Farhan Ali Tested-by: Pierre Morel Signed-off-by: Christian Borntraeger --- drivers/s390/crypto/vfio_ap_ops.c | 38 +++++++++++++++++++++++++++++++++++++ include/uapi/linux/vfio.h | 1 + 2 files changed, 39 insertions(+), 0 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index ea96b95..31e0dbe 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -795,6 +795,43 @@ static void vfio_ap_mdev_release(struct mdev_device *mdev) module_put(THIS_MODULE); } +static int vfio_ap_mdev_get_device_info(unsigned long arg) +{ + unsigned long minsz; + struct vfio_device_info info; + + minsz = offsetofend(struct vfio_device_info, num_irqs); + + if (copy_from_user(&info, (void __user *)arg, minsz)) + return -EFAULT; + + if (info.argsz < minsz) + return -EINVAL; + + info.flags = VFIO_DEVICE_FLAGS_AP; + info.num_regions = 0; + info.num_irqs = 0; + + return copy_to_user((void __user *)arg, &info, minsz); +} + +static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev, + unsigned int cmd, unsigned long arg) +{ + int ret; + + switch (cmd) { + case VFIO_DEVICE_GET_INFO: + ret = vfio_ap_mdev_get_device_info(arg); + break; + default: + ret = -EOPNOTSUPP; + break; + } + + return ret; +} + static const struct mdev_parent_ops vfio_ap_matrix_ops = { .owner = THIS_MODULE, .supported_type_groups = vfio_ap_mdev_type_groups, @@ -803,6 +840,7 @@ static void vfio_ap_mdev_release(struct mdev_device *mdev) .remove = vfio_ap_mdev_remove, .open = vfio_ap_mdev_open, .release = vfio_ap_mdev_release, + .ioctl = vfio_ap_mdev_ioctl, }; int vfio_ap_mdev_register(void) diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index bfbe2be..f378b98 100644 --- a/include/uapi/linux/vfio.h +++ b/include/uapi/linux/vfio.h @@ -200,6 +200,7 @@ struct vfio_device_info { #define VFIO_DEVICE_FLAGS_PLATFORM (1 << 2) /* vfio-platform device */ #define VFIO_DEVICE_FLAGS_AMBA (1 << 3) /* vfio-amba device */ #define VFIO_DEVICE_FLAGS_CCW (1 << 4) /* vfio-ccw device */ +#define VFIO_DEVICE_FLAGS_AP (1 << 5) /* vfio-ap device */ __u32 num_regions; /* Max region index + 1 */ __u32 num_irqs; /* Max IRQ index + 1 */ }; -- 1.7.1