• Eric Farman's avatar
    s390/cio: Don't pin vfio pages for empty transfers · 5d87fbf7
    Eric Farman authored
    The skip flag of a CCW offers the possibility of data not being
    transferred, but is only meaningful for certain commands.
    Specifically, it is only applicable for a read, read backward, sense,
    or sense ID CCW and will be ignored for any other command code
    (SA22-7832-11 page 15-64, and figure 15-30 on page 15-75).
    
    (A sense ID is xE4, while a sense is x04 with possible modifiers in the
    upper four bits.  So we will cover the whole "family" of sense CCWs.)
    
    For those scenarios, since there is no requirement for the target
    address to be valid, we should skip the call to vfio_pin_pages() and
    rely on the IDAL address we have allocated/built for the channel
    program.  The fact that the individual IDAWs within the IDAL are
    invalid is fine, since they aren't actually checked in these cases.
    
    Set pa_nr to zero when skipping the pfn_array_pin() call, since it is
    defined as the number of pages pinned and is used to determine
    whether to call vfio_unpin_pages() upon cleanup.
    
    The pfn_array_pin() routine returns the number of pages that were
    pinned, but now might be skipped for some CCWs.  Thus we need to
    calculate the expected number of pages ourselves such that we are
    guaranteed to allocate a reasonable number of IDAWs, which will
    provide a valid address in CCW.CDA regardless of whether the IDAWs
    are filled in with pinned/translated addresses or not.
    Signed-off-by: default avatarEric Farman <farman@linux.ibm.com>
    Message-Id: <20190516161403.79053-2-farman@linux.ibm.com>
    Acked-by: default avatarFarhan Ali <alifm@linux.ibm.com>
    Signed-off-by: default avatarCornelia Huck <cohuck@redhat.com>
    5d87fbf7
vfio_ccw_cp.c 23.8 KB