mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tony Krowiak <akrowiak@linux.ibm.com>
To: Harald Freudenberger <freude@linux.ibm.com>,
	Pierre Morel <pmorel@linux.ibm.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org
Cc: borntraeger@de.ibm.com, cohuck@redhat.com,
	mjrosato@linux.ibm.com, pasic@linux.ibm.com,
	alex.williamson@redhat.com, kwankhede@nvidia.com,
	jjherne@linux.ibm.com, fiuczy@linux.ibm.com
Subject: Re: [PATCH v7 03/15] s390/zcrypt: driver callback to indicate resource in use
Date: Tue, 28 Apr 2020 10:37:00 -0400	[thread overview]
Message-ID: <10913b5e-e6e2-81f5-5d4c-56ab01a8b5f4@linux.ibm.com> (raw)
In-Reply-To: <8646519e-a04d-341d-8197-944bf0a1ca4d@linux.ibm.com>



On 4/28/20 7:07 AM, Harald Freudenberger wrote:
> On 28.04.20 00:24, Tony Krowiak wrote:
>>
>> On 4/27/20 4:20 AM, Pierre Morel wrote:
>>>
>>> On 2020-04-07 21:20, Tony Krowiak wrote:
>>>> Introduces a new driver callback to prevent a root user from unbinding
>>>> an AP queue from its device driver if the queue is in use. The intent of
>>>> this callback is to provide a driver with the means to prevent a root user
>>>> from inadvertently taking a queue away from a guest and giving it to the
>>>> host while the guest is still using it.
>>> How can we know, at this point if the guest uses or not the queue?
>> The struct ap_matrix_mdev has a field, struct kvm *kvm, which holds a pointer to KVM when
>> the matrix mdev is in use by a guest. This patch series also introduces a shadow_crycb (soon to
>> be shadow_apcb) which holds the AP configuration for the guest. Between those two things,
>> the driver can detect when a queue is in use by a guest.
>>
>>> Do you want to say that this prevents to take away a queue when it is currently assigned to a VFIO device?
>>> and with a guest currently using this VFIO device?
>> No, I do not. The intent here is to enforce the proper procedure for giving up a queue so it is done
>> deliberately. Before taking a queue away from the matrix mdev, its APQN should be unassigned
>> from the matrix mdev. That is not to say that if there are major objections to this that we can't
>> base in_use upon the queue being in use by a guest at the time. Maybe that is preferable to
>> the community. I'll leave it to them to state their case.
>>
>>>> The callback will
>>>> be invoked whenever a change to the AP bus's sysfs apmask or aqmask
>>>> attributes would result in one or more AP queues being removed from its
>>>> driver. If the callback responds in the affirmative for any driver
>>>> queried, the change to the apmask or aqmask will be rejected with a device
>>>> in use error.
>>> AFAIU you mean that Linux's driver's binding and unbinding mechanism is not sufficient to avoid this issue because unbind can not be refused by the driver.
>> Correct!
>>
>>>
>>> The reason why we do not want a single queue to be removed from the VFIO driver is because the VFIO drivers works on a matrix, not on queues, and for the matrix to be consistent it needs to acquire all queues defined by the cross product of all APID and AQID assigned to the matrix.
>> Not correct. The reason why is because we do not want a queue to be surreptitiously removed
>> without the guest administrator being aware of its removal.
>>
>>> This functionality is valid for the host as for the guests and is handled automatically by the firmware with the CRYCB.
>>> The AP bus uses QCI to retrieve the host CRYCB and build the hosts AP queues.
>>>
>>> If instead to mix VFIO CRYCB matrix handling and queues at the same level inside the AP bus we separate these different firmware entities in two different software entities.
>>>
>>> If we make the AP bus sit above a CRYCB/Matrix bus, and in the way virtualize the QCI and test AP queue instructions:
>>> - we can directly pass a matrix device to the guest though a VFIO matrix device
>>> - the consistence will be automatic
>>> - the VFIO device and parent device will be of the same kind which would make the design much more clearer.
>>> - there will be no need for these callback because the consistence of the matrix will be guaranteed by firmware
>> As stated in my response above, the issue here is not consistency. While the design you describe
>> may be reasonable, it is a major departure from what is out in the field. In other words, that ship
>> has sailed.
>>
>>>
>>>> For this patch, only non-default drivers will be queried. Currently,
>>>> there is only one non-default driver, the vfio_ap device driver.
>>> You mean that the admin may take queues away from the "default driver", while the queue is in use, to give it to an other driver?
>>> Why is it to avoid in one way and not in the other way?
>> Because the default drivers have direct control over the queues and can ensure they are empty
>> and reset before giving up control. The vfio driver does not have direct control over the queues
>> because they have been passed through to the guest.
> No, that's not true. The 'default' drivers have no change to do anything with an APQN when it is removed
> from the driver. They get the very same notification which is the remove() callback as the vfio dd gets
> and have the very same change to do something here. The more interesting thing here is, that the remove()
> callback invocation is usually because a hardware HAS BEEN GONE AWAY. Neither the 'default' drivers
> nor the vfio dd can do a reset on a not-any-more existing APQN.
> And it is also not true that the vfio dd has no direct control over the queue because they have been passed
> through to the guest. It's the job of the vfio dd to modify the guest's APM, AQM, ADM masks to disable
> the guest's access to the APQN and then the vfio can (try to) do a reset.

The context here is when a sysadmin deliberately takes one or more 
queues away from a
guest by changing the apmask or aqmask; we are not talking about the the 
case where an
adapter is deconfigured or disappears. The idea here is to prevent a 
sysadmin for the host
from taking a queue away from a KVM guest that is using it. IMHO, control
over that queue should belong to the guest until such time as the guest 
gives it up or the
guest is terminated. Since the zcrypt drivers are directly responsible 
for their AP queues,
it is not necessary to implement this callback, although there is 
nothing precluding that.

>>>> The
>>>> vfio_ap device driver manages AP queues passed through to one or more
>>>> guests
>>> I read this as if a queue may be passed to several guest...
>>> please, rephrase or explain.
>> AP queues is plural, so it is true that AP queues can be passed through
>> to more than one guest. I see your point, however, so I'll reword that
>> to be more clear.
>>
>>>> and we don't want to unexpectedly take AP resources away from
>>>> guests which are most likely independently administered.
>>> When you say "independently administered", you mean as a second admin inside the host, don't you?
>> I mean that a guest can be administered by a different person than the host administrator.
>> Again, I'll try to clarify this.
>>
>>>
>>> Regards,
>>> Pierre
>>>


  reply	other threads:[~2020-04-28 14:37 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07 19:20 [PATCH v7 00/15] s390/vfio-ap: dynamic configuration support Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 01/15] s390/vfio-ap: store queue struct in hash table for quick access Tony Krowiak
2020-04-08 10:48   ` Cornelia Huck
2020-04-08 15:38     ` Tony Krowiak
2020-04-08 16:27       ` Cornelia Huck
2020-04-08 16:34         ` Tony Krowiak
2020-04-24  3:57   ` Halil Pasic
2020-04-27 13:05     ` Harald Freudenberger
2020-04-27 15:17       ` Halil Pasic
2020-04-27 21:48         ` Tony Krowiak
2020-04-28 10:07           ` Halil Pasic
2020-04-28 10:57             ` Harald Freudenberger
2020-04-28 22:30               ` Tony Krowiak
2020-04-29  7:56                 ` Harald Freudenberger
2020-04-29 11:30               ` Halil Pasic
2020-04-28 10:46         ` Harald Freudenberger
2020-04-07 19:20 ` [PATCH v7 02/15] s390/vfio-ap: manage link between queue struct and matrix mdev Tony Krowiak
2020-04-09 15:06   ` Cornelia Huck
2020-04-10 15:32     ` Tony Krowiak
2020-04-10 15:41     ` Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 03/15] s390/zcrypt: driver callback to indicate resource in use Tony Krowiak
2020-04-14 12:08   ` Cornelia Huck
2020-04-15 17:10     ` Tony Krowiak
2020-04-16 10:05       ` Cornelia Huck
2020-04-16 14:35         ` Tony Krowiak
2020-04-14 12:58   ` Cornelia Huck
2020-04-15  6:08     ` Harald Freudenberger
2020-04-16  9:33       ` Cornelia Huck
2020-04-17 13:54         ` Harald Freudenberger
2020-04-15 17:10     ` Tony Krowiak
2020-04-16  9:37       ` Cornelia Huck
2020-04-24  3:33         ` Halil Pasic
2020-04-24 17:07           ` Tony Krowiak
2020-04-24 18:23             ` Halil Pasic
2020-04-27 21:36               ` Tony Krowiak
2020-04-27  8:20   ` Pierre Morel
2020-04-27 22:24     ` Tony Krowiak
2020-04-28  8:09       ` Pierre Morel
2020-04-28 11:07       ` Harald Freudenberger
2020-04-28 14:37         ` Tony Krowiak [this message]
2020-04-07 19:20 ` [PATCH v7 04/15] s390/vfio-ap: implement in-use callback for vfio_ap driver Tony Krowiak
2020-04-16 11:18   ` Cornelia Huck
2020-04-16 14:45     ` Tony Krowiak
2020-04-17 11:23       ` Pierre Morel
2020-04-24  3:13       ` Halil Pasic
2020-04-24 16:58         ` Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 05/15] s390/vfio-ap: introduce shadow CRYCB Tony Krowiak
2020-04-16 11:58   ` Cornelia Huck
2020-04-21 21:39     ` Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 06/15] s390/vfio-ap: sysfs attribute to display the guest CRYCB Tony Krowiak
2020-04-08 10:33   ` Cornelia Huck
2020-04-08 16:38     ` Tony Krowiak
2020-04-08 16:46       ` Cornelia Huck
2020-04-09 14:18         ` Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 07/15] s390/vfio-ap: filter CRYCB bits for unavailable queue devices Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 08/15] s390/vfio_ap: add qlink from ap_matrix_mdev struct to vfio_ap_queue struct Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 09/15] s390/vfio-ap: allow assignment of unavailable AP queues to mdev device Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 10/15] s390/vfio-ap: allow configuration of matrix mdev in use by a KVM guest Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 11/15] s390/vfio-ap: allow hot plug/unplug of AP resources using mdev device Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 12/15] s390/zcrypt: Notify driver on config changed and scan complete callbacks Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 13/15] s390/vfio-ap: handle host AP config change notification Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 14/15] s390/vfio-ap: handle AP bus scan completed notification Tony Krowiak
2020-04-07 19:20 ` [PATCH v7 15/15] s390/vfio-ap: handle probe/remove not due to host AP config changes Tony Krowiak
2020-05-07 15:03 ` [PATCH v7 03/15] s390/zcrypt: driver callback to indicate resource in use 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=10913b5e-e6e2-81f5-5d4c-56ab01a8b5f4@linux.ibm.com \
    --to=akrowiak@linux.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=fiuczy@linux.ibm.com \
    --cc=freude@linux.ibm.com \
    --cc=jjherne@linux.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.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=pmorel@linux.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

Powered by JetHome