diff options
author | Cornelia Huck <cohuck@redhat.com> | 2019-01-08 17:53:03 +0300 |
---|---|---|
committer | Cornelia Huck <cohuck@redhat.com> | 2019-04-24 15:18:51 +0300 |
commit | 4f76617378ee97c557b526cb58d3c61eb0a9c963 (patch) | |
tree | 42e9ac6864535d6d1ea1210790dfccf072eb73bb /drivers/s390/cio/vfio_ccw_drv.c | |
parent | 690f6a1581c7c08e85451f62bcbfe40f29072842 (diff) | |
download | linux-4f76617378ee97c557b526cb58d3c61eb0a9c963.tar.xz |
vfio-ccw: protect the I/O region
Introduce a mutex to disallow concurrent reads or writes to the
I/O region. This makes sure that the data the kernel or user
space see is always consistent.
The same mutex will be used to protect the async region as well.
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Diffstat (limited to 'drivers/s390/cio/vfio_ccw_drv.c')
-rw-r--r-- | drivers/s390/cio/vfio_ccw_drv.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c index 0b3b9de45c60..5ea0da1dd954 100644 --- a/drivers/s390/cio/vfio_ccw_drv.c +++ b/drivers/s390/cio/vfio_ccw_drv.c @@ -84,7 +84,9 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work) if (is_final) cp_free(&private->cp); } + mutex_lock(&private->io_mutex); memcpy(private->io_region->irb_area, irb, sizeof(*irb)); + mutex_unlock(&private->io_mutex); if (private->io_trigger) eventfd_signal(private->io_trigger, 1); @@ -129,6 +131,7 @@ static int vfio_ccw_sch_probe(struct subchannel *sch) private->sch = sch; dev_set_drvdata(&sch->dev, private); + mutex_init(&private->io_mutex); spin_lock_irq(sch->lock); private->state = VFIO_CCW_STATE_NOT_OPER; |