linux/drivers/misc/cxl
Andrew Donnellan 171ed0fcd8 cxl: fix nested locking hang during EEH hotplug
Commit 14a3ae34bf ("cxl: Prevent read/write to AFU config space while AFU
not configured") introduced a rwsem to fix an invalid memory access that
occurred when someone attempts to access the config space of an AFU on a
vPHB whilst the AFU is deconfigured, such as during EEH recovery.

It turns out that it's possible to run into a nested locking issue when EEH
recovery fails and a full device hotplug is required.
cxl_pci_error_detected() deconfigures the AFU, taking a writer lock on
configured_rwsem. When EEH recovery fails, the EEH code calls
pci_hp_remove_devices() to remove the device, which in turn calls
cxl_remove() -> cxl_pci_remove_afu() -> pci_deconfigure_afu(), which tries
to grab the writer lock that's already held.

Standard rwsem semantics don't express what we really want to do here and
don't allow for nested locking. Fix this by replacing the rwsem with an
atomic_t which we can control more finely. Allow the AFU to be locked
multiple times so long as there are no readers.

Fixes: 14a3ae34bf ("cxl: Prevent read/write to AFU config space while AFU not configured")
Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-02-21 21:32:52 +11:00
..
api.c cxl: Drop unused header asm/pnv-pci.h 2017-01-25 13:34:23 +11:00
base.c cxl: Add support for interrupts on the Mellanox CX4 2016-07-14 20:27:08 +10:00
context.c powerpc updates for 4.10 2016-12-16 09:26:42 -08:00
cxl.h cxl: fix nested locking hang during EEH hotplug 2017-02-21 21:32:52 +11:00
debugfs.c cxl: Fix coccinelle warnings 2016-11-23 22:57:49 +11:00
fault.c powerpc/mm: Replace _PAGE_USER with _PAGE_PRIVILEGED 2016-05-01 18:32:26 +10:00
file.c cxl: Fix coredump generation when cxl_get_fd() is used 2016-11-18 23:02:17 +11:00
flash.c cxl: static-ify variables to fix sparse warnings 2016-06-16 22:49:27 +10:00
guest.c cxl: Fix coccinelle warnings 2016-11-23 22:57:49 +11:00
hcalls.c cxl: Add tracepoints around the cxl hcall 2016-03-09 23:40:01 +11:00
hcalls.h cxl: Add guest-specific code 2016-03-09 23:36:52 +11:00
irq.c cxl: Fix coccinelle warnings 2016-11-23 22:57:49 +11:00
Kconfig cxl: remove dead Kconfig options 2016-07-19 20:12:29 +10:00
main.c cxl: fix nested locking hang during EEH hotplug 2017-02-21 21:32:52 +11:00
Makefile cxl: Fix build when CONFIG_DEBUG_FS=n 2017-02-03 21:59:26 +11:00
native.c cxl: drop duplicate header sched.h 2016-11-25 14:07:50 +11:00
of.c cxl: replace loop with for_each_child_of_node(), remove unneeded of_node_put() 2016-10-04 16:19:23 +11:00
pci.c cxl: fix nested locking hang during EEH hotplug 2017-02-21 21:32:52 +11:00
phb.c cxl: Fix error handling in _cxl_pci_associate_default_context() 2016-11-18 22:41:08 +11:00
sysfs.c cxl: Prevent adapter reset if an active context exists 2016-10-19 20:35:39 +11:00
trace.c cxl: Add tracepoints 2015-01-22 17:31:51 +11:00
trace.h cxl: Add tracepoints around the cxl hcall 2016-03-09 23:40:01 +11:00
vphb.c cxl: fix nested locking hang during EEH hotplug 2017-02-21 21:32:52 +11:00