Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp912621imm; Wed, 8 Aug 2018 07:48:11 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzpxWsRVJgpwiqyxa5CN/BpkgBoMEXSJ/b9OtrNeYSJr18YDLSiZu7TAooKMOcWh0i4HlYw X-Received: by 2002:a17:902:46a4:: with SMTP id p33-v6mr2892675pld.205.1533739690996; Wed, 08 Aug 2018 07:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533739690; cv=none; d=google.com; s=arc-20160816; b=jOdEj2b1hRBNzIELTG2F/awkBtgu6kof48DWSu4YVFAtF+G9v9VNtj1A1yULLSlskZ qqx8+mPNvJ3CwdbTmuvxdJtQ6XMhvthIozDbZlkmujKMkZUq0wcRg0bGZVoTQyNJPIRe lcYzOK1hloEPqS32M/OovJ1WmgVPBu4rg5oowCegf9k64t2kBXkELbs3Ry3WEwuvywXH Z3KSYTyIsTfqTNwkpRXfcXT7ZYmBGDvUCkV8zIAoKI+VHKjEdS6Q2+PsJNDTKABF34nq tJwOZdEEbsNvse8UGl0LbNSuLa/1cKz7FewxBexBfpvtUewibTyOc7x+qSuhT5lilEpv /ypQ== 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=wv3KmWwxHTdm8YfcNLqS6TiKv7YGcSN9F4Dl7akm6NU=; b=t6fvuQoE41bAMZ4EfnI+Ysxqhj8rDRrEbYKCq2GhY3/XNMAbdlLeq/u1xG6l1NhEbG zSgKesjV6iRGA4MSafUXBzPfw6YA87l1M9pw2nXgYCC+vNvfuniaPZRBOCj5mkGGI8/T AjG8q6fxumTgoQywPSwfsnb4k7JE3hVxNdvr7BKa0BnV89w0Lm+y1SNLq+C+hneoJTvq kndnunaZeqKKKQYTrfT0fGlBGMniA36gSi0dy1rQYMif/0HZ9z0U9Aiv/zggYqicGLxL 2MQGWa6ToKMNUV4da4iUydwICK3zlPCGRBGaKsioKlZnDJhlhWqc/nOPtMwGO9PZD2Zr oXnw== 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 v28-v6si4532885pfi.22.2018.08.08.07.47.56; Wed, 08 Aug 2018 07:48:10 -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 S1728208AbeHHRFC (ORCPT + 99 others); Wed, 8 Aug 2018 13:05:02 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58932 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728012AbeHHRFB (ORCPT ); Wed, 8 Aug 2018 13:05:01 -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 w78EiPbi065988 for ; Wed, 8 Aug 2018 10:45:02 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kr1evkd4b-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 08 Aug 2018 10:45:02 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 8 Aug 2018 10:45:00 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e17.ny.us.ibm.com (146.89.104.204) 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:44:57 -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 w78EitTp5439804 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 8 Aug 2018 14:44:55 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CEDD28058; Wed, 8 Aug 2018 10:43:43 -0400 (EDT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A2F528059; Wed, 8 Aug 2018 10:43:42 -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:42 -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 13/22] s390: vfio-ap: sysfs interface to view matrix mdev matrix Date: Wed, 8 Aug 2018 10:44:23 -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-0040-0000-0000-0000045B73F1 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.00850514; MB=3.00022589; MTD=3.00000008; XFM=3.00000015; UTC=2018-08-08 14:44:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18080814-0041-0000-0000-0000086275D9 Message-Id: <1533739472-7172-14-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 Provides a sysfs interface to view the AP matrix configured for the mediated matrix device. The relevant sysfs structures are: /sys/devices/virtual/misc/vfio_ap/ ...... [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 Below are examples of the output from the above command: Example 1: Adapters and domains assigned Assignments: Adapters 5 and 6 Domains 4 and 71 (0x47) Output 05.0004 05.0047 06.0004 06.0047 Examples 2: Only adapters assigned Assignments: Adapters 5 and 6 Output: 05. 06. Examples 3: Only domains assigned Assignments: Domains 4 and 71 (0x47) Output: .0004 .0047 Signed-off-by: Tony Krowiak Reviewed-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 | 52 +++++++++++++++++++++++++++++++++++++ 1 files changed, 52 insertions(+), 0 deletions(-) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index a48676a..61a25d4 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -552,6 +552,57 @@ 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 apid1; + unsigned long apqi1; + unsigned long napm_bits = matrix_mdev->matrix.apm_max + 1; + unsigned long naqm_bits = matrix_mdev->matrix.aqm_max + 1; + int nchars = 0; + int n; + + apid1 = find_first_bit_inv(matrix_mdev->matrix.apm, napm_bits); + apqi1 = find_first_bit_inv(matrix_mdev->matrix.aqm, naqm_bits); + + mutex_lock(&matrix_dev.lock); + + if ((apid1 < napm_bits) && (apqi1 < naqm_bits)) { + for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, napm_bits) { + for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, + naqm_bits) { + n = sprintf(bufpos, "%02lx.%04lx\n", apid, + apqi); + bufpos += n; + nchars += n; + } + } + } else if (apid1 < napm_bits) { + for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, napm_bits) { + n = sprintf(bufpos, "%02lx.\n", apid); + bufpos += n; + nchars += n; + } + } else if (apqi1 < naqm_bits) { + for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, naqm_bits) { + n = sprintf(bufpos, ".%04lx\n", apqi); + bufpos += n; + nchars += n; + } + } + + mutex_unlock(&matrix_dev.lock); + + return nchars; +} +DEVICE_ATTR_RO(matrix); + + static struct attribute *vfio_ap_mdev_attrs[] = { &dev_attr_assign_adapter.attr, &dev_attr_unassign_adapter.attr, @@ -560,6 +611,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