lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 18 Sep 2020 13:09:25 -0400
From:   Tony Krowiak <akrowiak@...ux.ibm.com>
To:     Cornelia Huck <cohuck@...hat.com>
Cc:     linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
        kvm@...r.kernel.org, freude@...ux.ibm.com, borntraeger@...ibm.com,
        mjrosato@...ux.ibm.com, pasic@...ux.ibm.com,
        alex.williamson@...hat.com, kwankhede@...dia.com,
        fiuczy@...ux.ibm.com, frankja@...ux.ibm.com, david@...hat.com,
        imbrenda@...ux.ibm.com, hca@...ux.ibm.com, gor@...ux.ibm.com
Subject: Re: [PATCH v10 07/16] s390/vfio-ap: sysfs attribute to display the
 guest's matrix



On 9/17/20 10:34 AM, Cornelia Huck wrote:
> On Fri, 21 Aug 2020 15:56:07 -0400
> Tony Krowiak <akrowiak@...ux.ibm.com> wrote:
>
>> The matrix of adapters and domains configured in a guest's CRYCB may
>> differ from the matrix of adapters and domains assigned to the matrix mdev,
>> so this patch introduces a sysfs attribute to display the matrix of a guest
>> using the matrix mdev. For a matrix mdev denoted by $uuid, the crycb for a
>> guest using the matrix mdev can be displayed as follows:
>>
>>     cat /sys/devices/vfio_ap/matrix/$uuid/guest_matrix
>>
>> If a guest is not using the matrix mdev at the time the crycb is displayed,
>> an error (ENODEV) will be returned.
>>
>> Signed-off-by: Tony Krowiak <akrowiak@...ux.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 efb229033f9e..30bf23734af6 100644
>> --- a/drivers/s390/crypto/vfio_ap_ops.c
>> +++ b/drivers/s390/crypto/vfio_ap_ops.c
>> @@ -1119,6 +1119,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_apcb.apm_max + 1;
>> +	unsigned long naqm_bits = matrix_mdev->shadow_apcb.aqm_max + 1;
>> +	int nchars = 0;
>> +	int n;
>> +
>> +	if (!vfio_ap_mdev_has_crycb(matrix_mdev))
>> +		return -ENODEV;
>> +
>> +	apid1 = find_first_bit_inv(matrix_mdev->shadow_apcb.apm, napm_bits);
>> +	apqi1 = find_first_bit_inv(matrix_mdev->shadow_apcb.aqm, naqm_bits);
>> +
>> +	mutex_lock(&matrix_dev->lock);
>> +
>> +	if ((apid1 < napm_bits) && (apqi1 < naqm_bits)) {
>> +		for_each_set_bit_inv(apid, matrix_mdev->shadow_apcb.apm,
>> +				     napm_bits) {
>> +			for_each_set_bit_inv(apqi,
>> +					     matrix_mdev->shadow_apcb.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_apcb.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_apcb.aqm,
>> +				     naqm_bits) {
>> +			n = sprintf(bufpos, ".%04lx\n", apqi);
>> +			bufpos += n;
>> +			nchars += n;
>> +		}
>> +	}
>> +
>> +	mutex_unlock(&matrix_dev->lock);
>> +
>> +	return nchars;
>> +}
> This basically looks like a version of matrix_show() operating on the
> shadow apcb. I'm wondering if we could consolidate these two functions
> by passing in the structure to operate on as a parameter? Might not be
> worth the effort, though.

We still need the two functions because they back the mdev's
sysfs matrix and guest_matrix attributes, but we could call a function.
I'm not sure it buys us much though.

>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ