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]
Message-ID: <20210114035009.375c5496.pasic@linux.ibm.com>
Date:   Thu, 14 Jan 2021 03:50:09 +0100
From:   Halil Pasic <pasic@...ux.ibm.com>
To:     Tony Krowiak <akrowiak@...ux.ibm.com>
Cc:     linux-s390@...r.kernel.org, linux-kernel@...r.kernel.org,
        kvm@...r.kernel.org, freude@...ux.ibm.com, borntraeger@...ibm.com,
        cohuck@...hat.com, mjrosato@...ux.ibm.com,
        alex.williamson@...hat.com, kwankhede@...dia.com,
        fiuczy@...ux.ibm.com, frankja@...ux.ibm.com, david@...hat.com,
        hca@...ux.ibm.com, gor@...ux.ibm.com
Subject: Re: [PATCH v13 05/15] s390/vfio-ap: manage link between queue
 struct and matrix mdev

On Wed, 13 Jan 2021 16:41:27 -0500
Tony Krowiak <akrowiak@...ux.ibm.com> wrote:

> On 1/11/21 2:17 PM, Halil Pasic wrote:
> > On Tue, 22 Dec 2020 20:15:56 -0500
> > Tony Krowiak <akrowiak@...ux.ibm.com> wrote:
> >  
> >> Let's create links between each queue device bound to the vfio_ap device
> >> driver and the matrix mdev to which the queue's APQN is assigned. The idea
> >> is to facilitate efficient retrieval of the objects representing the queue
> >> devices and matrix mdevs as well as to verify that a queue assigned to
> >> a matrix mdev is bound to the driver.
> >>
> >> The links will be created as follows:
> >>
> >>     * When the queue device is probed, if its APQN is assigned to a matrix
> >>       mdev, the structures representing the queue device and the matrix mdev
> >>       will be linked.
> >>
> >>     * When an adapter or domain is assigned to a matrix mdev, for each new
> >>       APQN assigned that references a queue device bound to the vfio_ap
> >>       device driver, the structures representing the queue device and the
> >>       matrix mdev will be linked.
> >>
> >> The links will be removed as follows:
> >>
> >>     * When the queue device is removed, if its APQN is assigned to a matrix
> >>       mdev, the structures representing the queue device and the matrix mdev
> >>       will be unlinked.
> >>
> >>     * When an adapter or domain is unassigned from a matrix mdev, for each
> >>       APQN unassigned that references a queue device bound to the vfio_ap
> >>       device driver, the structures representing the queue device and the
> >>       matrix mdev will be unlinked.
> >>
> >> Signed-off-by: Tony Krowiak <akrowiak@...ux.ibm.com>  
> > Reviewed-by: Halil Pasic <pasic@...ux.ibm.com>
> >  

[..]

> >> +
> >>   int vfio_ap_mdev_probe_queue(struct ap_device *apdev)
> >>   {
> >>   	struct vfio_ap_queue *q;
> >> @@ -1324,9 +1404,13 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev)
> >>   	q = kzalloc(sizeof(*q), GFP_KERNEL);
> >>   	if (!q)
> >>   		return -ENOMEM;
> >> +	mutex_lock(&matrix_dev->lock);
> >>   	dev_set_drvdata(&apdev->device, q);
> >>   	q->apqn = to_ap_queue(&apdev->device)->qid;
> >>   	q->saved_isc = VFIO_AP_ISC_INVALID;
> >> +	vfio_ap_queue_link_mdev(q);
> >> +	mutex_unlock(&matrix_dev->lock);
> >> +  
> > Does the critical section have to include more than just
> > vfio_ap_queue_link_mdev()? Did we need the critical section
> > before this patch?  
> 
> We did not need the critical section before this patch because
> the only function that retrieved the vfio_ap_queue via the queue
> device's drvdata was the remove callback. I included the initialization
> of the vfio_ap_queue object under lock because the
> vfio_ap_find_queue() function retrieves the vfio_ap_queue object from
> the queue device's drvdata so it might be advantageous to initialize
> it under the mdev lock. On the other hand, I can't come up with a good
> argument to change this.
> 
> 

I was asking out of curiosity, not because I want it changed. I was
also wondering if somebody could see a partially initialized device:
we even first call dev_set_drvdata() and only then finish the
initialization. Before 's390/vfio-ap: use new AP bus interface to search
for queue devices', which is the previous patch, we had the klist code
in between, which uses spinlocks, which I think ensure, that all
effects of probe are seen when we get the queue from
vfio_ap_find_queue(). But with patch 4 in place that is not the case any
more. Or am I wrong?

Regards,
Halil

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ