summaryrefslogtreecommitdiff
path: root/drivers/s390
diff options
context:
space:
mode:
authorCornelia Huck <cohuck@redhat.com>2019-03-11 10:59:53 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-03 06:26:21 +0200
commit0f273f0c3064dab95c82d6046b0f5ea2ababd304 (patch)
tree533af2322153b5a666711d33f28fd811b7c82544 /drivers/s390
parent92d4ee2e82767998f1300e6ac4fc9f95bf860b7c (diff)
downloadlinux-rpi3-0f273f0c3064dab95c82d6046b0f5ea2ababd304.tar.gz
linux-rpi3-0f273f0c3064dab95c82d6046b0f5ea2ababd304.tar.bz2
linux-rpi3-0f273f0c3064dab95c82d6046b0f5ea2ababd304.zip
vfio: ccw: only free cp on final interrupt
commit 50b7f1b7236bab08ebbbecf90521e84b068d7a17 upstream. When we get an interrupt for a channel program, it is not necessarily the final interrupt; for example, the issuing guest may request an intermediate interrupt by specifying the program-controlled-interrupt flag on a ccw. We must not switch the state to idle if the interrupt is not yet final; even more importantly, we must not free the translated channel program if the interrupt is not yet final, or the host can crash during cp rewind. Fixes: e5f84dbaea59 ("vfio: ccw: return I/O results asynchronously") Cc: stable@vger.kernel.org # v4.12+ Reviewed-by: Eric Farman <farman@linux.ibm.com> Signed-off-by: Cornelia Huck <cohuck@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/cio/vfio_ccw_drv.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
index f47d16b5810b..fabd9798e4c4 100644
--- a/drivers/s390/cio/vfio_ccw_drv.c
+++ b/drivers/s390/cio/vfio_ccw_drv.c
@@ -72,20 +72,24 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)
{
struct vfio_ccw_private *private;
struct irb *irb;
+ bool is_final;
private = container_of(work, struct vfio_ccw_private, io_work);
irb = &private->irb;
+ is_final = !(scsw_actl(&irb->scsw) &
+ (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT));
if (scsw_is_solicited(&irb->scsw)) {
cp_update_scsw(&private->cp, &irb->scsw);
- cp_free(&private->cp);
+ if (is_final)
+ cp_free(&private->cp);
}
memcpy(private->io_region->irb_area, irb, sizeof(*irb));
if (private->io_trigger)
eventfd_signal(private->io_trigger, 1);
- if (private->mdev)
+ if (private->mdev && is_final)
private->state = VFIO_CCW_STATE_IDLE;
}