Received: by 10.192.165.156 with SMTP id m28csp2993783imm; Sun, 15 Apr 2018 14:27:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+2f+PO14q9Ct1UxRC0zTWBidUcGyay0A4wnkZkz8Jw/2Mdxq0MaWdFqlvfKYuuMTo/h9XF X-Received: by 10.101.65.75 with SMTP id x11mr11090907pgp.203.1523827635736; Sun, 15 Apr 2018 14:27:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523827635; cv=none; d=google.com; s=arc-20160816; b=PTHHZLd/d8EcvPj4a4PfAshjRX6tebhrdConYsAz8H4vU/aD+wA9DMTqjch+Rxt7hn s7xTZtJVIjWJpw08yl4eZi4KBwx6rK0tw3krPUCCGCpnL+qEV2MWu79ccZBY5DmO/+RR OmfbJB9er7mNboVdaTar3q5d7r37clN2FaSgqbq0BCJTkviN6IpCSkiX0e0rrE3+Ru5l BZfYdzW1KZXpOQxuWnfs85s3tWl7pyRrKbmokurKNgAXEsGe5e74ocZC+Zp184IMkZmV BlWTgBOh19cv1YDX+hgUA5T2R98zwTlJ4v0rPt2dxMWKOb/kikxGe6aAgNm3vYJ7qQXq 4i1w== 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=4VBDY/PF3XafvDzT81b4TwUVDoh1+XDw93ch1ZaC8ic=; b=uQl+PMNGnVWfxGHq5217LY+TDUOulD+8Uj4shKyEJB3sWCgdozN0Tf3gSNABtU6o3T NAkDu/VcK1uf1MxaqaqSPQ+zrZCsEVDlSBu1hQgm09REDm8cXLyNWiz6atljRhwfSjh8 IYjty3drXKLryORVFh9ZwaUaWlmxGbifKZcguKXcfZC7+h1XH7n5W/yzHNPufjGDPgJJ FAcAH314mPac244zstfOE2zWbAT/qY+Jj5/OwajBPzTgvNxI0phGL+TgpQPADMnQkbrm U4HbJprCkDKi+Ut/f+ZmqpjqZtNS6bfYQr18jYB03wjcpPt7gu5TlXGoxGiWZKEsC9co ItLw== 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 73si93732pfb.204.2018.04.15.14.26.28; Sun, 15 Apr 2018 14:27:15 -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 S1753318AbeDOVXc (ORCPT + 99 others); Sun, 15 Apr 2018 17:23:32 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40124 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753231AbeDOVXE (ORCPT ); Sun, 15 Apr 2018 17:23:04 -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 w3FLLHTh068633 for ; Sun, 15 Apr 2018 17:23:04 -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 2hc14ynyfq-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Sun, 15 Apr 2018 17:23:03 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 15 Apr 2018 17:23:02 -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; Sun, 15 Apr 2018 17:22:59 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3FLMw6056164494; Sun, 15 Apr 2018 21:22:58 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 85125AE034; Sun, 15 Apr 2018 17:24:44 -0400 (EDT) Received: from localhost.localdomain (unknown [9.85.139.141]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTPS id 76CD8AE03C; Sun, 15 Apr 2018 17:24:43 -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 Subject: [PATCH v4 14/15] s390: vfio-ap: implement VFIO_DEVICE_GET_INFO ioctl Date: Sun, 15 Apr 2018 17:22:24 -0400 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1523827345-11600-1-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1523827345-11600-1-git-send-email-akrowiak@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041521-0036-0000-0000-000002E25DDD X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008862; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01018429; UDB=6.00519481; IPR=6.00797666; MB=3.00020592; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-15 21:23:02 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041521-0037-0000-0000-000043FEA899 Message-Id: <1523827345-11600-15-git-send-email-akrowiak@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-15_10:,, 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 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804150214 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Reviewed-by: Pierre Morel Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 43 +++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index e3ff5ab..00179cd 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -101,6 +101,48 @@ static void vfio_ap_mdev_release(struct mdev_device *mdev) &matrix_mdev->group_notifier); } +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) { + pr_err("%s: Argument size %u less than min size %li", + VFIO_AP_MODULE_NAME, 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: + pr_err("%s: ioctl command %d is not a supported command", + VFIO_AP_MODULE_NAME, cmd); + ret = -EOPNOTSUPP; + break; + } + + return ret; +} + static ssize_t name_show(struct kobject *kobj, struct device *dev, char *buf) { return sprintf(buf, "%s\n", VFIO_AP_MDEV_NAME_HWVIRT); @@ -804,6 +846,7 @@ static ssize_t matrix_show(struct device *dev, struct device_attribute *attr, .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(struct ap_matrix *ap_matrix) -- 1.7.1