• Tony Krowiak's avatar
    s390/vfio-ap: bypass unnecessary processing of AP resources · 1918f2b2
    Tony Krowiak authored
    It is not necessary to go through the process of validation, linking of
    queues to mdev and vice versa and filtering the APQNs assigned to the
    matrix mdev to build an AP configuration for a guest if an adapter or
    domain being assigned is already assigned to the matrix mdev. Likewise, it
    is not necessary to proceed through the process the unassignment of an
    adapter, domain or control domain if it is not assigned to the matrix mdev.
    
    Since it is not necessary to process assignment of a resource already
    assigned or process unassignment of a resource that is been assigned,
    this patch will bypass all assignment/unassignment operations for an
    adapter, domain or control domain under these circumstances.
    
    Not only is assignment of a duplicate adapter or domain unnecessary, it
    will also cause a hang situation when removing the matrix mdev to which it is
    assigned. The reason is because the same vfio_ap_queue objects with an
    APQN containing the APID of the adapter or APQI of the domain being
    assigned will get added multiple times to the hashtable that holds them.
    This results in the pprev and next pointers of the hlist_node (mdev_qnode
    field in the vfio_ap_queue object) pointing to the queue object itself
    resulting in an interminable loop when the mdev is removed and the queue
    table is iterated to reset the queues.
    
    Cc: stable@vger.kernel.org
    Fixes: 11cb2419 ("s390/vfio-ap: manage link between queue struct and matrix mdev")
    Reported-by: default avatarMatthew Rosato <mjrosato@linux.ibm.com>
    Signed-off-by: default avatarTony Krowiak <akrowiak@linux.ibm.com>
    Reviewed-by: default avatarHalil Pasic <pasic@linux.ibm.com>
    Signed-off-by: default avatarHalil Pasic <pasic@linux.ibm.com>
    Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
    1918f2b2
vfio_ap_ops.c 64.7 KB