From: Tony Krowiak <akrowiak@linux.ibm.com>
To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org
Cc: freude@linux.ibm.com, borntraeger@de.ibm.com, cohuck@redhat.com,
frankja@linux.ibm.com, david@redhat.com, schwidefsky@de.ibm.com,
heiko.carstens@de.ibm.com, pmorel@linux.ibm.com,
pasic@linux.ibm.com, alex.williamson@redhat.com,
kwankhede@nvidia.com, Tony Krowiak <akrowiak@linux.ibm.com>
Subject: [PATCH v2 2/8] s390: vfio-ap: sysfs interface to display guest CRYCB
Date: Sat, 20 Apr 2019 17:49:34 -0400 [thread overview]
Message-ID: <1555796980-27920-3-git-send-email-akrowiak@linux.ibm.com> (raw)
In-Reply-To: <1555796980-27920-1-git-send-email-akrowiak@linux.ibm.com>
Introduces a sysfs interface on the matrix mdev device to display the
contents of the shadow of the guest's CRYCB
Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
---
drivers/s390/crypto/vfio_ap_ops.c | 58 +++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index b0453e6c20d0..eae4ee24460a 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -750,6 +750,63 @@ static ssize_t matrix_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(matrix);
+static ssize_t guest_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->shadow_crycb->apm_max + 1;
+ unsigned long naqm_bits = matrix_mdev->shadow_crycb->aqm_max + 1;
+ int nchars = 0;
+ int n;
+
+ if (!matrix_mdev->shadow_crycb)
+ return -ENODEV;
+
+ apid1 = find_first_bit_inv(matrix_mdev->shadow_crycb->apm, napm_bits);
+ apqi1 = find_first_bit_inv(matrix_mdev->shadow_crycb->aqm, naqm_bits);
+
+ mutex_lock(&matrix_dev->lock);
+
+ if ((apid1 < napm_bits) && (apqi1 < naqm_bits)) {
+ for_each_set_bit_inv(apid, matrix_mdev->shadow_crycb->apm,
+ napm_bits) {
+ for_each_set_bit_inv(apqi,
+ matrix_mdev->shadow_crycb->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->shadow_crycb->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->shadow_crycb->aqm,
+ naqm_bits) {
+ n = sprintf(bufpos, ".%04lx\n", apqi);
+ bufpos += n;
+ nchars += n;
+ }
+ }
+
+ mutex_unlock(&matrix_dev->lock);
+
+ return nchars;
+}
+static DEVICE_ATTR_RO(guest_matrix);
+
static struct attribute *vfio_ap_mdev_attrs[] = {
&dev_attr_assign_adapter.attr,
&dev_attr_unassign_adapter.attr,
@@ -759,6 +816,7 @@ static struct attribute *vfio_ap_mdev_attrs[] = {
&dev_attr_unassign_control_domain.attr,
&dev_attr_control_domains.attr,
&dev_attr_matrix.attr,
+ &dev_attr_guest_matrix.attr,
NULL,
};
--
2.7.4
next prev parent reply other threads:[~2019-04-20 21:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-20 21:49 [PATCH v2 0/8] s390: vfio-ap: dynamic configuration support Tony Krowiak
2019-04-20 21:49 ` [PATCH v2 1/8] s390: vfio-ap: maintain a shadow of the CRYCB in use by a guest Tony Krowiak
2019-04-20 21:49 ` Tony Krowiak [this message]
2019-04-20 21:49 ` [PATCH v2 3/8] s390: vfio-ap: allow assignment of unavailable AP resources to mdev device Tony Krowiak
2019-04-23 12:46 ` Pierre Morel
2019-04-23 13:19 ` Tony Krowiak
2019-04-20 21:49 ` [PATCH v2 4/8] s390: vfio-ap: allow hot plug/unplug of AP resources using " Tony Krowiak
2019-04-20 21:49 ` [PATCH v2 5/8] s390: vfio-ap: wait for queue empty on queue reset Tony Krowiak
2019-04-23 12:50 ` Pierre Morel
2019-04-23 13:28 ` Tony Krowiak
2019-04-20 21:49 ` [PATCH v2 6/8] s390: kvm: test CRYCB masks before setting them Tony Krowiak
2019-04-20 21:49 ` [PATCH v2 7/8] s390: vfio-ap: handle bind and unbind of AP queue device Tony Krowiak
2019-04-23 13:08 ` Pierre Morel
2019-04-23 13:36 ` Tony Krowiak
2019-04-23 13:38 ` Pierre Morel
2019-04-23 14:53 ` Tony Krowiak
2019-04-23 13:54 ` Halil Pasic
2019-04-23 15:27 ` Tony Krowiak
2019-04-20 21:49 ` [PATCH v2 8/8] s390: vfio-ap: update documentation Tony Krowiak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1555796980-27920-3-git-send-email-akrowiak@linux.ibm.com \
--to=akrowiak@linux.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=freude@linux.ibm.com \
--cc=heiko.carstens@de.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@linux.ibm.com \
--cc=pmorel@linux.ibm.com \
--cc=schwidefsky@de.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox