Received: by 10.192.165.148 with SMTP id m20csp3200068imm; Mon, 7 May 2018 08:16:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrnEsGG2z1KMLMoMCQOKEUs5zkyRnhW0AKs9gYDWan1LDI4hi8jHP75p3oPlZW/HdwqJu6+ X-Received: by 2002:a9d:5c7:: with SMTP id 65-v6mr7550058otd.78.1525706171854; Mon, 07 May 2018 08:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525706171; cv=none; d=google.com; s=arc-20160816; b=CrnkbngtAtMNAEVqM7IGEqas2lgIJfykN7QcEuhTjAYghvjkkvBVRjOMXqxfnhEe+a QTqKGGiBNBfcToHobjYIJJLiwe7RGkQsPD4omIDCk6QQGOb+9dQ5QNy30PvB5W+CeuQ0 Oif73dL2eKl/Xdt+47IupxoPqCu3ZiGAWSnQf/c+iyGZBVfy7BtQCwAufj5zanB9r0VQ mOR77eimVhCSg+GyMFDCDELElqG8DySBIqKa8/FD62yBEM5RsSD2oeuxo3n5VJ9Ntnqk P600X1aq6RCjQ8YywSan2ANNFzDVR/D7m6aEACU6fWVdhe0sylF5OfsErakIp4x8Ftn+ 5MjA== 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=JJ8UBYUquPDrQgt32/7ZPkqEBT6GpjB4Tgt4qiijwdw=; b=Hx0QTgTpjMYUOdNDUBY/RHC2VjHnakCnzCTCXDo/kYxS4mbkFdmwk33tdFCexM/0G+ Ys76PHvWh3+LWniewAZkvChTBzFl2eEhjV0lx8jfbSk6UP6DgKYDDrEGx3Own0aFGjXD g5sdAh6zGPZX7ercVrojG3Cf/OAurNHgZ7BuQMzy6DPOFoB0I6leRmMngxGv8xdzBeQw CRWImqsKYGN9MNvMQn/gk68rlAop5DiXheAPJ49I40haRIKX0bY6DFaqfQ6TuALS4Y3y /wse2uQvxMZXUEt5kuDIKgl15fDTlNhIyyk9QyfRLlJuNQFZEblUTTvcmzVzmKBo5HaS +8Pw== 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 191-v6si7263694itf.50.2018.05.07.08.15.58; Mon, 07 May 2018 08:16:11 -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 S1752537AbeEGPO6 (ORCPT + 99 others); Mon, 7 May 2018 11:14:58 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35876 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751976AbeEGPMj (ORCPT ); Mon, 7 May 2018 11:12:39 -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 w47F9Elx136024 for ; Mon, 7 May 2018 11:12:39 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2htrpy9mhg-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 07 May 2018 11:12:39 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 7 May 2018 09:12:38 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 7 May 2018 09:12:34 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w47FCXka8847814; Mon, 7 May 2018 08:12:33 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00395C604A; Mon, 7 May 2018 09:12:33 -0600 (MDT) Received: from localhost.localdomain (unknown [9.85.146.27]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTPS id A7F1AC603E; Mon, 7 May 2018 09:12:30 -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 10/13] s390: vfio-ap: sysfs interface to view matrix mdev matrix Date: Mon, 7 May 2018 11:11:49 -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-8235-0000-0000-00000D713EBC 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:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18050715-8236-0000-0000-000040D4AA68 Message-Id: <1525705912-12815-11-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 Provides a sysfs interface to view the AP matrix configured for the mediated matrix device. The relevant sysfs structures are: /sys/devices/vfio_ap ... [matrix] ...... [mdev_supported_types] ......... [vfio_ap-passthrough] ............ [devices] ...............[$uuid] .................. matrix To view the matrix configured for the mediated matrix device, print the matrix file: cat matrix Signed-off-by: Tony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 755be1d..81e03b8 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -716,6 +716,36 @@ static ssize_t control_domains_show(struct device *dev, } DEVICE_ATTR_RO(control_domains); +static ssize_t matrix_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct mdev_device *mdev = mdev_from_dev(dev); + struct ap_matrix_mdev *matrix_mdev = mdev_get_drvdata(mdev); + char *bufpos = buf; + unsigned long apid; + unsigned long apqi; + unsigned long napm = matrix_mdev->matrix.apm_max + 1; + unsigned long naqm = matrix_mdev->matrix.aqm_max + 1; + int nchars = 0; + int n; + + for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, napm) { + n = sprintf(bufpos, "%02lx\n", apid); + bufpos += n; + nchars += n; + + for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, naqm) { + n = sprintf(bufpos, "%02lx.%04lx\n", apid, apqi); + bufpos += n; + nchars += n; + } + } + + return nchars; +} +DEVICE_ATTR_RO(matrix); + + static struct attribute *vfio_ap_mdev_attrs[] = { &dev_attr_assign_adapter.attr, &dev_attr_unassign_adapter.attr, @@ -724,6 +754,7 @@ static ssize_t control_domains_show(struct device *dev, &dev_attr_assign_control_domain.attr, &dev_attr_unassign_control_domain.attr, &dev_attr_control_domains.attr, + &dev_attr_matrix.attr, NULL, }; -- 1.7.1