[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190304140222.6d694479.cohuck@redhat.com>
Date: Mon, 4 Mar 2019 14:02:22 +0100
From: Cornelia Huck <cohuck@...hat.com>
To: Tony Krowiak <akrowiak@...ux.ibm.com>
Cc: Pierre Morel <pmorel@...ux.ibm.com>, borntraeger@...ibm.com,
alex.williamson@...hat.com, linux-kernel@...r.kernel.org,
linux-s390@...r.kernel.org, kvm@...r.kernel.org,
frankja@...ux.ibm.com, pasic@...ux.ibm.com, david@...hat.com,
schwidefsky@...ibm.com, heiko.carstens@...ibm.com,
freude@...ux.ibm.com, mimu@...ux.ibm.com
Subject: Re: [PATCH v4 6/7] s390: ap: Cleanup on removing the AP device
On Tue, 26 Feb 2019 13:27:57 -0500
Tony Krowiak <akrowiak@...ux.ibm.com> wrote:
> On 2/22/19 10:29 AM, Pierre Morel wrote:
> > When the device is remove, we must make sure to
> > clear the interruption and reset the AP device.
> >
> > We also need to clear the CRYCB of the guest.
> >
> > Signed-off-by: Pierre Morel <pmorel@...ux.ibm.com>
> > ---
> > drivers/s390/crypto/vfio_ap_drv.c | 35 +++++++++++++++++++++++++++++++++++
> > drivers/s390/crypto/vfio_ap_ops.c | 3 ++-
> > drivers/s390/crypto/vfio_ap_private.h | 3 +++
> > 3 files changed, 40 insertions(+), 1 deletion(-)
(...)
> > /**
> > + * vfio_ap_update_crycb
> > + * @q: A pointer to the queue being removed
> > + *
> > + * We clear the APID of the queue, making this queue unusable for the guest.
> > + * After this function we can reset the queue without to fear a race with
> > + * the guest to access the queue again.
> > + * We do not fear race with the host as we still get the device.
> > + */
> > +static void vfio_ap_update_crycb(struct vfio_ap_queue *q)
> > +{
> > + struct ap_matrix_mdev *matrix_mdev = q->matrix_mdev;
> > +
> > + if (!matrix_mdev)
> > + return;
> > +
> > + clear_bit_inv(AP_QID_CARD(q->apqn), matrix_mdev->matrix.apm);
> > +
> > + if (!matrix_mdev->kvm)
> > + return;
> > +
> > + kvm_arch_crypto_set_masks(matrix_mdev->kvm,
> > + matrix_mdev->matrix.apm,
> > + matrix_mdev->matrix.aqm,
> > + matrix_mdev->matrix.adm);
> > +}
> > +
> > +/**
> > * vfio_ap_queue_dev_remove:
> > *
> > * Free the associated vfio_ap_queue structure
> > @@ -70,6 +100,11 @@ static void vfio_ap_queue_dev_remove(struct ap_device *apdev)
> > struct vfio_ap_queue *q;
> >
> > q = dev_get_drvdata(&apdev->device);
> > + if (!q)
> > + return;
> > +
> > + vfio_ap_update_crycb(q);
> > + vfio_ap_mdev_reset_queue(q);
>
> The reset is unnecessary because once the card is removed from the
> CRYCB, the ZAPQ may fail with because the queue may not exist anymore.
> Besides, once the card is removed from the guest's CRYCB, the bus
> running in the guest will do a reset.
You cannot rely on whatever a sane guest would do, any needed cleanup
needs to be done by the host.
(No idea what actually needs to be done here :)
>
> > list_del(&q->list);
> > kfree(q);
> > }
Powered by blists - more mailing lists