linux-stable/drivers/s390/cio
Farhan Ali b49bdc8602 vfio-ccw: Release any channel program when releasing/removing vfio-ccw mdev
When releasing the vfio-ccw mdev, we currently do not release
any existing channel program and its pinned pages. This can
lead to the following warning:

[1038876.561565] WARNING: CPU: 2 PID: 144727 at drivers/vfio/vfio_iommu_type1.c:1494 vfio_sanity_check_pfn_list+0x40/0x70 [vfio_iommu_type1]

....

1038876.561921] Call Trace:
[1038876.561935] ([<00000009897fb870>] 0x9897fb870)
[1038876.561949]  [<000003ff8013bf62>] vfio_iommu_type1_detach_group+0xda/0x2f0 [vfio_iommu_type1]
[1038876.561965]  [<000003ff8007b634>] __vfio_group_unset_container+0x64/0x190 [vfio]
[1038876.561978]  [<000003ff8007b87e>] vfio_group_put_external_user+0x26/0x38 [vfio]
[1038876.562024]  [<000003ff806fc608>] kvm_vfio_group_put_external_user+0x40/0x60 [kvm]
[1038876.562045]  [<000003ff806fcb9e>] kvm_vfio_destroy+0x5e/0xd0 [kvm]
[1038876.562065]  [<000003ff806f63fc>] kvm_put_kvm+0x2a4/0x3d0 [kvm]
[1038876.562083]  [<000003ff806f655e>] kvm_vm_release+0x36/0x48 [kvm]
[1038876.562098]  [<00000000003c2dc4>] __fput+0x144/0x228
[1038876.562113]  [<000000000016ee82>] task_work_run+0x8a/0xd8
[1038876.562125]  [<000000000014c7a8>] do_exit+0x5d8/0xd90
[1038876.562140]  [<000000000014d084>] do_group_exit+0xc4/0xc8
[1038876.562155]  [<000000000015c046>] get_signal+0x9ae/0xa68
[1038876.562169]  [<0000000000108d66>] do_signal+0x66/0x768
[1038876.562185]  [<0000000000b9e37e>] system_call+0x1ea/0x2d8
[1038876.562195] 2 locks held by qemu-system-s39/144727:
[1038876.562205]  #0: 00000000537abaf9 (&container->group_lock){++++}, at: __vfio_group_unset_container+0x3c/0x190 [vfio]
[1038876.562230]  #1: 00000000670008b5 (&iommu->lock){+.+.}, at: vfio_iommu_type1_detach_group+0x36/0x2f0 [vfio_iommu_type1]
[1038876.562250] Last Breaking-Event-Address:
[1038876.562262]  [<000003ff8013aa24>] vfio_sanity_check_pfn_list+0x3c/0x70 [vfio_iommu_type1]
[1038876.562272] irq event stamp: 4236481
[1038876.562287] hardirqs last  enabled at (4236489): [<00000000001cee7a>] console_unlock+0x6d2/0x740
[1038876.562299] hardirqs last disabled at (4236496): [<00000000001ce87e>] console_unlock+0xd6/0x740
[1038876.562311] softirqs last  enabled at (4234162): [<0000000000b9fa1e>] __do_softirq+0x556/0x598
[1038876.562325] softirqs last disabled at (4234153): [<000000000014e4cc>] irq_exit+0xac/0x108
[1038876.562337] ---[ end trace 6c96d467b1c3ca06 ]---

Similarly we do not free the channel program when we are removing
the vfio-ccw device. Let's fix this by resetting the device and freeing
the channel program and pinned pages in the release path. For the remove
path we can just quiesce the device, since in the remove path the mediated
device is going away for good and so we don't need to do a full reset.

Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
Message-Id: <ae9f20dc8873f2027f7b3c5d2aaa0bdfe06850b8.1554756534.git.alifm@linux.ibm.com>
Acked-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2019-04-24 14:18:51 +02:00
..
airq.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
blacklist.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
blacklist.h s390: add a few more SPDX identifiers 2017-12-05 07:51:09 +01:00
ccwgroup.c s390/ccwgroup: add get_ccwgroupdev_by_busid() 2018-10-08 09:09:59 +02:00
ccwreq.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
chp.c s390/cio: ensure that a chpid is registered only once 2018-07-17 07:27:51 +02:00
chp.h s390/chsc: query utility strings via fmt3 channel path descriptor 2018-03-26 16:13:16 +02:00
chsc.c s390 update with improvements and bug fixes for 5.1-rc2 2019-03-28 08:35:32 -07:00
chsc.h s390/cio: add function chsc_sgib() 2019-02-05 14:29:23 +01:00
chsc_sch.c compat: Move compat_timespec/ timeval to compat_time.h 2018-04-19 13:29:54 +02:00
chsc_sch.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cio.c s390/css: reduce stsch calls 2018-07-17 07:27:55 +02:00
cio.h s390: cio: fix cio_irb declaration 2019-04-10 17:48:33 +02:00
cio_debug.h Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2017-11-13 11:47:01 -08:00
cmf.c mm: remove include/linux/bootmem.h 2018-10-31 08:54:16 -07:00
crw.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
css.c s390/css: reduce stsch calls 2018-07-17 07:27:55 +02:00
css.h s390/css: reduce stsch calls 2018-07-17 07:27:55 +02:00
device.c s390/cio: fix unbind of io_subchannel_driver 2018-03-26 16:13:06 +02:00
device.h s390/cio: Convert timers to use timer_setup() 2017-11-14 11:01:36 +01:00
device_fsm.c s390/cio: clear timer when terminating driver I/O 2018-02-22 10:09:27 +01:00
device_id.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
device_ops.c s390/cio: add helper to query utility strings per given ccw device 2018-05-23 08:06:56 +02:00
device_pgid.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
device_status.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
eadm_sch.c s390: cio: add SPDX identifiers to the remaining files 2017-11-24 14:28:41 +01:00
eadm_sch.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
fcx.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
idset.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
idset.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
io_sch.h s390/cio: fix return code after missing interrupt 2018-02-22 10:09:25 +01:00
ioasm.c s390/cio: export hsch to modules 2019-04-24 14:18:51 +02:00
ioasm.h s390: assume diag308 set always works 2018-04-10 07:38:59 +02:00
isc.c s390: cio: add SPDX identifiers to the remaining files 2017-11-24 14:28:41 +01:00
itcw.c s390/cio: fix kernel-doc usage 2018-02-05 07:34:52 +01:00
Makefile vfio-ccw: add handling for async channel instructions 2019-04-24 14:18:51 +02:00
orb.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
qdio.h s390/qdio: eliminate queue's last_move cursor 2019-04-10 17:47:26 +02:00
qdio_debug.c s390/qdio: eliminate queue's last_move cursor 2019-04-10 17:47:26 +02:00
qdio_debug.h Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2017-11-13 11:47:01 -08:00
qdio_main.c s390/qdio: consolidate index tracking for queue scan 2019-04-18 10:10:32 +02:00
qdio_setup.c s390/qdio: clean up pci_out_supported() 2019-03-29 07:23:49 +01:00
qdio_thinint.c treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
scm.c s390: cio: add SPDX identifiers to the remaining files 2017-11-24 14:28:41 +01:00
trace.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace.h s390 cio: Rewrite trace point class s390_class_schib 2018-07-23 13:49:56 +02:00
vfio_ccw_async.c vfio-ccw: add handling for async channel instructions 2019-04-24 14:18:51 +02:00
vfio_ccw_cp.c vfio-ccw: make it safe to access channel programs 2019-04-24 14:18:51 +02:00
vfio_ccw_cp.h vfio-ccw: make it safe to access channel programs 2019-04-24 14:18:51 +02:00
vfio_ccw_drv.c vfio-ccw: Do not call flush_workqueue while holding the spinlock 2019-04-24 14:18:51 +02:00
vfio_ccw_fsm.c vfio-ccw: add handling for async channel instructions 2019-04-24 14:18:51 +02:00
vfio_ccw_ops.c vfio-ccw: Release any channel program when releasing/removing vfio-ccw mdev 2019-04-24 14:18:51 +02:00
vfio_ccw_private.h vfio-ccw: add handling for async channel instructions 2019-04-24 14:18:51 +02:00
vfio_ccw_trace.h vfio: ccw: add tracepoints for interesting error paths 2018-05-29 09:27:42 +02:00