linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, freude@de.ibm.com, schwidefsky@de.ibm.com,
	heiko.carstens@de.ibm.com, borntraeger@de.ibm.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
Subject: Re: [PATCH v3 07/14] KVM: s390: interfaces to configure/deconfigure guest's AP matrix
Date: Tue, 3 Apr 2018 09:17:59 -0400	[thread overview]
Message-ID: <474b7d18-69ea-631f-214c-f9345119e537@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180403130758.43851026.cohuck@redhat.com>

On 04/03/2018 07:07 AM, Cornelia Huck wrote:
> On Wed, 14 Mar 2018 14:25:47 -0400
> Tony Krowiak <akrowiak@linux.vnet.ibm.com> wrote:
>
>> Provides interfaces to assign AP adapters, usage domains
>> and control domains to a KVM guest.
>>
>> A KVM guest is started by executing the Start Interpretive Execution (SIE)
>> instruction. The SIE state description is a control block that contains the
>> state information for a KVM guest and is supplied as input to the SIE
>> instruction. The SIE state description has a satellite structure called the
>> Crypto Control Block (CRYCB). The CRYCB contains three bitmask fields
>> identifying the adapters, queues (domains) and control domains assigned to
>> the KVM guest:
>>
>> * The AP Adapter Mask (APM) field identifies the AP adapters assigned to
>>    the KVM guest
>>
>> * The AP Queue Mask (AQM) field identifies the AP queues assigned to
>>    the KVM guest. Each AP queue is connected to a usage domain within
>>    an AP adapter.
>>
>> * The AP Domain Mask (ADM) field identifies the control domains
>>    assigned to the KVM guest.
>>
>> Each adapter, queue (usage domain) and control domain are identified by
>> a number from 0 to 255. The bits in each mask, from most significant to
>> least significant bit, correspond to the numbers 0-255. When a bit is
>> set, the corresponding adapter, queue (usage domain) or control domain
>> is assigned to the KVM guest.
>>
>> This patch will set the bits in the APM, AQM and ADM fields of the
>> CRYCB referenced by the KVM guest's SIE state description. The process
>> used is:
>>
>> 1. Verify that the bits to be set do not exceed the maximum bit
>>     number for the given mask.
>>
>> 2. Verify that the APQNs that can be derived from the intersection
>>     of the bits set in the APM and AQM fields of the KVM guest's CRYCB
>>     are not assigned to any other KVM guest running on the same linux
>>     host.
>>
>> 3. Set the APM, AQM and ADM in the CRYCB according to the matrix
>>     configured for the mediated matrix device via its sysfs
>>     adapter, domain and control domain attribute files respectively.
>>
>> Signed-off-by: Tony Krowiak <akrowiak@linux.vnet.ibm.com>
>> ---
>>   arch/s390/include/asm/kvm-ap.h        |   36 +++++
>>   arch/s390/kvm/kvm-ap.c                |  268 +++++++++++++++++++++++++++++++++
>>   drivers/s390/crypto/vfio_ap_ops.c     |   19 +++
>>   drivers/s390/crypto/vfio_ap_private.h |    4 +
>>   4 files changed, 327 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/s390/kvm/kvm-ap.c b/arch/s390/kvm/kvm-ap.c
>> index a2c6ad2..eb365e2 100644
>> --- a/arch/s390/kvm/kvm-ap.c
>> +++ b/arch/s390/kvm/kvm-ap.c
>> @@ -8,9 +8,129 @@
>>   
>>   #include <asm/kvm-ap.h>
>>   #include <asm/ap.h>
>> +#include <linux/bitops.h>
>>   
>>   #include "kvm-s390.h"
>>   
>> +static inline void kvm_ap_clear_crycb_masks(struct kvm *kvm)
>> +{
>> +	int crycb_fmt = kvm->arch.crypto.crycbd & CRYCB_FORMAT_MASK;
>> +
>> +	if (crycb_fmt == CRYCB_FORMAT2)
>> +		memset(&kvm->arch.crypto.crycb->apcb1, 0,
>> +		       sizeof(kvm->arch.crypto.crycb->apcb1));
>> +	else
>> +		memset(&kvm->arch.crypto.crycb->apcb0, 0,
>> +		       sizeof(kvm->arch.crypto.crycb->apcb0));
>> +}
> Should that rather be a switch/case? If there's a CRYCB_FORMAT3 in the
> future, I'd think that it's more likely that it uses apcb1 and not
> apcb0. Can't comment further without the architecture, obviously.
Maybe we should just clear both structures without regard to the CRYCB 
format.
>
> (...)
>
>> +static void kvm_ap_set_crycb_masks(struct kvm *kvm,
>> +				   struct kvm_ap_matrix *matrix)
>> +{
>> +	unsigned long *apm = kvm_ap_get_crycb_apm(kvm);
>> +	unsigned long *aqm = kvm_ap_get_crycb_aqm(kvm);
>> +	unsigned long *adm = kvm_ap_get_crycb_adm(kvm);
>> +
>> +	kvm_ap_clear_crycb_masks(kvm);
>> +	memcpy(apm, matrix->apm, KVM_AP_MASK_BYTES(matrix->apm_max));
>> +	memcpy(aqm, matrix->aqm, KVM_AP_MASK_BYTES(matrix->aqm_max));
>> +
>> +	/*
>> +	 * Merge the AQM and ADM since the ADM is a superset of the
>> +	 * AQM by architectural convention.
> Is this 'architectural convention' in the sense of 'there's a statement
> in the architecture that it always is like that', or in the sense of
> 'all real-life systems are like that'?
> [From my sketchy memory, this convention makes sense but is not
> enshrined; but I might misremember.]
The documentation states it is an agreed upon convention.
>
>> +	 */
>> +	bitmap_or(adm, adm, aqm, matrix->adm_max);
>> +}

  reply	other threads:[~2018-04-03 13:18 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-14 18:25 [PATCH v3 00/14] s390: vfio-ap: guest dedicated crypto adapters Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 01/14] KVM: s390: refactor crypto initialization Tony Krowiak
2018-03-15 12:26   ` Pierre Morel
2018-03-15 14:48     ` Tony Krowiak
2018-03-15 14:55       ` Pierre Morel
2018-03-26  8:44         ` Cornelia Huck
2018-03-29 18:57           ` Tony Krowiak
2018-04-03 11:26             ` Cornelia Huck
2018-04-05 10:42   ` Christian Borntraeger
2018-04-05 10:45     ` Christian Borntraeger
2018-04-05 13:16       ` Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 02/14] s390: zcrypt: externalize AP instructions available function Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 03/14] KVM: s390: CPU model support for AP virtualization Tony Krowiak
2018-03-27 10:59   ` Cornelia Huck
2018-03-27 11:22     ` Pierre Morel
2018-03-27 11:30       ` Cornelia Huck
2018-03-14 18:25 ` [PATCH v3 04/14] KVM: s390: device attribute to set AP interpretive execution Tony Krowiak
2018-03-14 21:57   ` Halil Pasic
2018-03-15 13:00     ` Pierre Morel
2018-03-15 15:26       ` Tony Krowiak
2018-03-15 15:45         ` Pierre Morel
2018-03-15 17:21           ` Tony Krowiak
2018-03-15 17:56             ` Pierre Morel
2018-03-15 23:39               ` Tony Krowiak
2018-03-16  7:51                 ` Pierre Morel
2018-03-16 16:09                   ` Tony Krowiak
2018-03-20 17:58                   ` Tony Krowiak
2018-03-20 22:48                     ` Halil Pasic
2018-04-02 18:55                       ` Tony Krowiak
2018-03-15 15:23     ` Tony Krowiak
2018-03-15 16:00       ` Pierre Morel
2018-03-15 23:37         ` Tony Krowiak
2018-03-15 16:25       ` Halil Pasic
2018-03-14 18:25 ` [PATCH v3 05/14] s390: vfio-ap: base implementation of VFIO AP device driver Tony Krowiak
2018-03-15 13:25   ` Pierre Morel
2018-03-15 17:25     ` Tony Krowiak
2018-03-27 11:17       ` Cornelia Huck
2018-03-27 14:45         ` Pierre Morel
2018-04-03  9:56           ` Cornelia Huck
2018-04-03 10:57   ` Cornelia Huck
2018-04-03 13:02     ` Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 06/14] s390: vfio-ap: register matrix device with VFIO mdev framework Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 07/14] KVM: s390: interfaces to configure/deconfigure guest's AP matrix Tony Krowiak
2018-04-03 11:07   ` Cornelia Huck
2018-04-03 13:17     ` Tony Krowiak [this message]
2018-04-03 13:38       ` Cornelia Huck
2018-03-14 18:25 ` [PATCH v3 08/14] s390: vfio-ap: sysfs interfaces to configure adapters Tony Krowiak
2018-04-03 11:10   ` Cornelia Huck
2018-04-03 13:33     ` Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 09/14] s390: vfio-ap: sysfs interfaces to configure domains Tony Krowiak
2018-04-03 11:17   ` Cornelia Huck
     [not found]     ` <1860430c-df59-6d58-77f9-b36c51595b4b@linux.vnet.ibm.com>
2018-04-03 15:19       ` Cornelia Huck
2018-04-03 15:42         ` Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 10/14] s390: vfio-ap: sysfs interfaces to configure control domains Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 11/14] s390: vfio-ap: sysfs interface to view matrix mdev matrix Tony Krowiak
2018-03-15  9:42   ` Pierre Morel
2018-03-15 14:52     ` Tony Krowiak
2018-03-15 15:35       ` Pierre Morel
2018-03-27 11:19     ` Cornelia Huck
2018-03-14 18:25 ` [PATCH v3 12/14] KVM: s390: configure the guest's AP devices Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 13/14] s390: vfio-ap: implement VFIO_DEVICE_GET_INFO ioctl Tony Krowiak
2018-03-14 18:25 ` [PATCH v3 14/14] s390: doc: detailed specifications for AP virtualization 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=474b7d18-69ea-631f-214c-f9345119e537@linux.vnet.ibm.com \
    --to=akrowiak@linux.vnet.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=alifm@linux.vnet.ibm.com \
    --cc=berrange@redhat.com \
    --cc=bjsdjshi@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=buendgen@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=fiuczy@linux.vnet.ibm.com \
    --cc=freude@de.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=jjherne@linux.vnet.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.vnet.ibm.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=pbonzini@redhat.com \
    --cc=pmorel@linux.vnet.ibm.com \
    --cc=schwidefsky@de.ibm.com \
    --cc=thuth@redhat.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;
as well as URLs for NNTP newsgroup(s).