Received: by 10.223.185.116 with SMTP id b49csp5016227wrg; Tue, 27 Feb 2018 06:32:43 -0800 (PST) X-Google-Smtp-Source: AG47ELv3k/Xl0Nqlwv/6mb4MXppclNk+vWddzbyWtJ88SPDnC/1Ko8W9/qW6rSpJXt6uHl6C+35F X-Received: by 10.99.55.11 with SMTP id e11mr9934517pga.237.1519741963542; Tue, 27 Feb 2018 06:32:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519741963; cv=none; d=google.com; s=arc-20160816; b=rp3lJIaI+Z8iAufLrzSJJfAsa9XSRTy3es/cVv5DAYvqqDltfa5IJc1MmDICxMxM4H vJAGKlnnMCsfDg3MyY3VBoVJL6xYNOqcLxzdr92WqrIISgVra/YenrGWFu+47Az7v5Ll bLgHf2+hK9o4RWIZ6mAR1yY1df3MJH6zn9AbQSZSiYvOp1pkvP7udoYNjYsr/jZoksNL 57D2AXmDFnBroPpE+2YRggOWsm1ECNfyii91rXK8dMpLUeSg9NLHVOrIgXFehJ4ZzlFS r4GFkKxpuekeXENkxvecwHa1UMxyJ+ccxhEDHJ6hpglxFqAMmrNQFPdzeLJs8A6/8Bj7 6obg== 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=CwWPFvEZS5bR5leDVn32ub0tAykAGEiUQFnrNmfgp7Y=; b=I2B4vm6O9qQmrB4hP6fhJjMMyVE6Riw/pt5g+Qz/eeypV2Cm7aWd+mCWy82/WueZf5 h74XwVXgsSZPcD9U53ykaPFQg7GsHaQb0hOEFNVUI9vZcEmW0UTe/58FLwGNuhZ5jQUI SsfPdQsApX8X9TyILkA/4MS47ZB6WgOrMgL2TFU4zlEY7MxstW1nXogGJ82PBK/XXOFO M0m5rOlx0MOWKe2lzZOlJDP6NxCHpM7RbXgLj3owrYTBL618a6qWblL26n0IYMLjYlMe Mqu7wvSdv19odo2XU06qbyXLTUFch6Ql7SUG3Q3RaK+KxwjEDZA0jInn+995a+TdZPRu LbUQ== 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 p13si7058252pgf.358.2018.02.27.06.32.28; Tue, 27 Feb 2018 06:32:43 -0800 (PST) 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 S1753750AbeB0ObL (ORCPT + 99 others); Tue, 27 Feb 2018 09:31:11 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55158 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753723AbeB0ObI (ORCPT ); Tue, 27 Feb 2018 09:31:08 -0500 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 w1REUH86076535 for ; Tue, 27 Feb 2018 09:31:07 -0500 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gd4huck3g-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 27 Feb 2018 09:30:24 -0500 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Feb 2018 07:29:09 -0700 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 27 Feb 2018 07:29:06 -0700 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1RET5Eo7471422; Tue, 27 Feb 2018 07:29:05 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 79DE87803F; Tue, 27 Feb 2018 07:29:05 -0700 (MST) Received: from localhost.localdomain (unknown [9.60.75.238]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTPS id AD6FA78038; Tue, 27 Feb 2018 07:29:03 -0700 (MST) 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, fiuczy@linux.vnet.ibm.com, buendgen@de.ibm.com, Tony Krowiak Subject: [PATCH v2 14/15] s390: vfio-ap: implement VFIO_DEVICE_GET_INFO ioctl Date: Tue, 27 Feb 2018 09:28:12 -0500 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1519741693-17440-1-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1519741693-17440-1-git-send-email-akrowiak@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18022714-8235-0000-0000-00000D149E28 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008601; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.00995862; UDB=6.00506230; IPR=6.00775186; MB=3.00019761; MTD=3.00000008; XFM=3.00000015; UTC=2018-02-27 14:29:09 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18022714-8236-0000-0000-00003FD98581 Message-Id: <1519741693-17440-15-git-send-email-akrowiak@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-27_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 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802270183 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 752d171..49c119d 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -97,6 +97,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_MATRIX_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_MATRIX_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); @@ -803,6 +845,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