linux/arch/powerpc/platforms/pseries
Haren Myneni b59c9dc4d9 powerpc/pseries/vas: Hold mmap_mutex after mmap lock during window close
Commit 8ef7b9e176 ("powerpc/pseries/vas: Close windows with DLPAR
core removal") unmaps the window paste address and issues HCALL to
close window in the hypervisor for migration or DLPAR core removal
events. So holds mmap_mutex and then mmap lock before unmap the
paste address. But if the user space issue mmap paste address at
the same time with the migration event, coproc_mmap() is called
after holding the mmap lock which can trigger deadlock when trying
to acquire mmap_mutex in coproc_mmap().

t1: mmap() call to mmap              t2: Migration event
    window paste address

do_mmap2()                           migration_store()
 ksys_mmap_pgoff()                    pseries_migrate_partition()
  vm_mmap_pgoff()                      vas_migration_handler()
    Acquire mmap lock                   reconfig_close_windows()
    do_mmap()                             lock mmap_mutex
     mmap_region()                        Acquire mmap lock
      call_mmap()                         //Wait for mmap lock
       coproc_mmap()                        unmap vma
         lock mmap_mutex                    update window status
         //wait for mmap_mutex            Release mmap lock
          mmap vma                        unlock mmap_mutex
          update window status
         unlock mmap_mutex
    ...
    Release mmap lock

Fix this deadlock issue by holding mmap lock first before mmap_mutex
in reconfig_close_windows().

Fixes: 8ef7b9e176 ("powerpc/pseries/vas: Close windows with DLPAR core removal")
Signed-off-by: Haren Myneni <haren@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230716100506.7833-1-haren@linux.ibm.com
2023-07-17 10:35:06 +10:00
..
cc_platform.c powerpc/pseries/svm: Add a powerpc version of cc_platform_has() 2021-10-04 11:46:33 +02:00
cmm.c mm: Convert all PageMovable users to movable_operations 2022-08-02 12:34:03 -04:00
dlpar.c powerpc, workqueue: Use alloc_ordered_workqueue() to create ordered workqueues 2023-05-08 13:52:27 -10:00
dtl.c powerpc/pseries: Fix CONFIG_DTL=n build 2022-10-13 22:30:07 +11:00
eeh_pseries.c powerpc/rtas: arch-wide function token lookup conversions 2023-02-13 22:35:03 +11:00
event_sources.c powerpc/pseries: Add __init attribute to eligible functions 2021-12-23 22:33:15 +11:00
firmware.c powerpc/pseries: Add FW_FEATURE_PLPKS feature flag 2023-04-20 13:21:46 +10:00
hotplug-cpu.c powerpc: Use of_property_present() for testing DT property presence 2023-03-30 23:36:35 +11:00
hotplug-memory.c powerpc: Use of_address_to_resource() 2023-04-04 22:11:03 +10:00
hvCall_inst.c powerpc/pseries: Make symbol '__pcpu_scope_hcall_stats' static 2021-04-14 23:04:17 +10:00
hvCall.S powerpc: add CFUNC assembly label annotation 2023-04-20 12:54:24 +10:00
hvconsole.c
hvcserver.c powerpc: move from strlcpy with unused retval to strscpy 2022-08-26 11:02:20 +10:00
ibmebus.c driver core: bus: mark the struct bus_type for sysfs callbacks as constant 2023-03-23 13:20:40 +01:00
io_event_irq.c powerpc/rtas: arch-wide function token lookup conversions 2023-02-13 22:35:03 +11:00
iommu.c powerpc/iommu: TCEs are incorrectly manipulated with DLPAR add/remove of memory 2023-06-26 14:57:31 +10:00
Kconfig powerc/mm: try VMA lock-based page fault handling first 2023-04-05 20:03:02 -07:00
kexec.c powerpc: Don't include asm/setup.h in asm/machdep.h 2022-06-20 11:29:49 +10:00
lpar.c powerpc/pseries/lpar: convert to papr_sysparm API 2023-02-13 22:35:03 +11:00
lparcfg.c powerpc/pseries/lparcfg: convert to papr_sysparm API 2023-02-13 22:35:03 +11:00
Makefile powerpc/pseries: PAPR system parameter API 2023-02-13 22:35:03 +11:00
mobility.c powerpc: Include asm/nmi.c in mobility.c for watchdog_hardlockup_set_timeout_pct() 2023-07-03 16:08:10 +10:00
msi.c powerpc/rtas: arch-wide function token lookup conversions 2023-02-13 22:35:03 +11:00
nvram.c powerpc/rtas: arch-wide function token lookup conversions 2023-02-13 22:35:03 +11:00
of_helpers.c powerpc/pseries: Fix of_read_drc_info_cell() to point at next record 2020-03-25 12:06:43 +11:00
of_helpers.h
papr_platform_attributes.c powerpc: Include asm/firmware.h in all users of firmware_has_feature() 2022-06-29 16:45:05 +10:00
papr_scm.c powerpc/papr_scm: Update the NUMA distance table for the target node 2023-04-04 22:08:35 +10:00
papr-sysparm.c powerpc/rtas: arch-wide function token lookup conversions 2023-02-13 22:35:03 +11:00
pci_dlpar.c powerpc/pseries: Fix use after free in remove_phb_dynamic() 2022-03-21 13:17:47 +11:00
pci.c PCI: Introduce pci_dev_for_each_resource() 2023-04-04 10:43:52 -05:00
plpks-secvar.c powerpc/pseries: Fix endianness issue when parsing PLPKS secvar flags 2023-02-16 21:16:22 +11:00
plpks.c powerpc/pseries: Add FW_FEATURE_PLPKS feature flag 2023-04-20 13:21:46 +10:00
pmem.c powerpc: Remove asm/prom.h from all files that don't need it 2022-05-08 22:15:04 +10:00
power.c powerpc: declare unmodified attribute_group usages const 2022-03-08 22:15:32 +11:00
pseries_energy.c powerpc/pseries: move to use bus_get_dev_root() 2023-03-17 15:29:38 +01:00
pseries.h powerpc/iommu: Add iommu_ops to report capabilities and allow blocking domains 2023-03-15 00:51:46 +11:00
ras.c powerpc/rtas: arch-wide function token lookup conversions 2023-02-13 22:35:03 +11:00
reconfig.c powerpc/pseries: block untrusted device tree changes when locked down 2022-09-28 19:22:14 +10:00
rng.c powerpc/pseries: wire up rng during setup_arch() 2022-06-18 10:19:10 +10:00
rtas-fadump.c powerpc: Add missing headers 2022-05-08 22:15:40 +10:00
rtas-fadump.h
rtas-work-area.c powerpc/rtas: arch-wide function token lookup conversions 2023-02-13 22:35:03 +11:00
setup.c powerpc: Make generic_calibrate_decr() the default 2023-03-16 08:56:48 +11:00
smp.c powerpc/rtas: arch-wide function token lookup conversions 2023-02-13 22:35:03 +11:00
suspend.c powerpc/pseries: move to use bus_get_dev_root() 2023-03-17 15:29:38 +01:00
svm.c swiotlb: add a SWIOTLB_ANY flag to lift the low memory restriction 2022-04-18 07:21:12 +02:00
vas-sysfs.c powerpc/pseries/vas: Call misc_deregister if sysfs init fails 2022-05-22 15:58:31 +10:00
vas.c powerpc/pseries/vas: Hold mmap_mutex after mmap lock during window close 2023-07-17 10:35:06 +10:00
vas.h powerpc/pseries: Use lparcfg to reconfig VAS windows for DLPAR CPU 2022-10-18 22:46:18 +11:00
vio.c powerpc updates for 6.4 2023-04-28 16:24:32 -07:00
vphn.c powerpc/vphn: Check for error from hcall_vphn 2020-03-04 22:44:30 +11:00