Received: by 10.192.165.148 with SMTP id m20csp3199019imm; Mon, 7 May 2018 08:15:12 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpYDXMQWmGLNSYxMkUrYwqlKrz1EiynL3XGMOGC/7bJq9y/0Itn3WRlS2nmAKeEzHeF5RPQ X-Received: by 2002:aca:35c2:: with SMTP id c185-v6mr12029323oia.326.1525706112808; Mon, 07 May 2018 08:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525706112; cv=none; d=google.com; s=arc-20160816; b=iCaY+76kFtsgC7oHy0i05QrRzsr80rflif9OoLc9EVTzVCpjtK7GUIWvGCbIUcMZD/ EcknZGTS7lAdb5wyrhBRvuf6zZmHTv4+xSJXkMSxDXww75YPSxkBLcxPOnzAfms32GOE Q+xs3FypOj1+wGOzQBys7vWnvO/lh59Zcwwmeevcd0LhHzGa8UCbPgylePico6Q6yPJQ 2vTaDUd1g4JyF2Kvx0RKgrv4pq1zrMr2HWGNB6wDzMqLpM33idKfdDmcrDkpGqVNZX+T JaaNqSCn0H2MmhDr77Zhot0izMigNLI3aRhwN3EsudA09cuVbeDGubWeME0PfgwZbqS6 wefg== 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=+Zu3+0Oa7cTTXWC/0qx85m14djZ53g2pFuJiMHvp9vA=; b=Hkh3guX9CQY+56D1dKwbw2JWxdPE4KOw+41cKDwnaoLh/spxOkPjw67gKlpMu1CapK nRFWx/vAor4xW7erdE7UtoY/jUZ95IwGrkXvu0EVR9O7tdivzBYZf9B3dQmj0kYpK4FU akHCbwz/bWYTEIepv8+K5Z17Ntiw7MqpVM7ZqdRqmHrAZYKJkipSdjXJS8zxNB2yjA8E X36FZNPLm/Ltf7lw3sV8HOx+r4LAwHUP4helHfOFf3YPyESpbxHNlwHtti/MIND6a+Ng zFKtk83DimqwRcGQEU7FVniPUB0ffwwqAzBRK2QboV+ChxW+iU52C/LDneE3jsf3oFex k0kQ== 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 v3-v6si7328879oie.31.2018.05.07.08.14.58; Mon, 07 May 2018 08:15:12 -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 S1752653AbeEGPNV (ORCPT + 99 others); Mon, 7 May 2018 11:13:21 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60982 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752583AbeEGPMq (ORCPT ); Mon, 7 May 2018 11:12:46 -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 w47F9LRc023260 for ; Mon, 7 May 2018 11:12:46 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2htr6j38ns-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 07 May 2018 11:12:46 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 May 2018 09:12:45 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 7 May 2018 09:12:41 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w47FCbNe10223914; Mon, 7 May 2018 08:12:40 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D861CC6042; Mon, 7 May 2018 09:12:39 -0600 (MDT) Received: from localhost.localdomain (unknown [9.85.146.27]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTPS id A15C5C604F; Mon, 7 May 2018 09:12:37 -0600 (MDT) 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 v5 12/13] s390: vfio-ap: implement VFIO_DEVICE_GET_INFO ioctl Date: Mon, 7 May 2018 11:11:51 -0400 X-Mailer: git-send-email 1.7.1 In-Reply-To: <1525705912-12815-1-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1525705912-12815-1-git-send-email-akrowiak@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18050715-0012-0000-0000-0000162D3B6D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008987; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000258; SDB=6.01028859; UDB=6.00525678; IPR=6.00807992; MB=3.00020972; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-07 15:12:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050715-0013-0000-0000-000052A179A5 Message-Id: <1525705912-12815-13-git-send-email-akrowiak@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-07_06:,, 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-1805070154 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 8866b0e..01a036f 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -113,6 +113,48 @@ 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) { + 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); @@ -841,6 +883,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