linux/drivers/dma/idxd
Fenghua Yu f221033f5c dmaengine: idxd: Fix oops during rmmod on single-CPU platforms
During the removal of the idxd driver, registered offline callback is
invoked as part of the clean up process. However, on systems with only
one CPU online, no valid target is available to migrate the
perf context, resulting in a kernel oops:

    BUG: unable to handle page fault for address: 000000000002a2b8
    #PF: supervisor write access in kernel mode
    #PF: error_code(0x0002) - not-present page
    PGD 1470e1067 P4D 0
    Oops: 0002 [#1] PREEMPT SMP NOPTI
    CPU: 0 PID: 20 Comm: cpuhp/0 Not tainted 6.8.0-rc6-dsa+ #57
    Hardware name: Intel Corporation AvenueCity/AvenueCity, BIOS BHSDCRB1.86B.2492.D03.2307181620 07/18/2023
    RIP: 0010:mutex_lock+0x2e/0x50
    ...
    Call Trace:
    <TASK>
    __die+0x24/0x70
    page_fault_oops+0x82/0x160
    do_user_addr_fault+0x65/0x6b0
    __pfx___rdmsr_safe_on_cpu+0x10/0x10
    exc_page_fault+0x7d/0x170
    asm_exc_page_fault+0x26/0x30
    mutex_lock+0x2e/0x50
    mutex_lock+0x1e/0x50
    perf_pmu_migrate_context+0x87/0x1f0
    perf_event_cpu_offline+0x76/0x90 [idxd]
    cpuhp_invoke_callback+0xa2/0x4f0
    __pfx_perf_event_cpu_offline+0x10/0x10 [idxd]
    cpuhp_thread_fun+0x98/0x150
    smpboot_thread_fn+0x27/0x260
    smpboot_thread_fn+0x1af/0x260
    __pfx_smpboot_thread_fn+0x10/0x10
    kthread+0x103/0x140
    __pfx_kthread+0x10/0x10
    ret_from_fork+0x31/0x50
    __pfx_kthread+0x10/0x10
    ret_from_fork_asm+0x1b/0x30
    <TASK>

Fix the issue by preventing the migration of the perf context to an
invalid target.

Fixes: 81dd4d4d61 ("dmaengine: idxd: Add IDXD performance monitor support")
Reported-by: Terrence Xu <terrence.xu@intel.com>
Tested-by: Terrence Xu <terrence.xu@intel.com>
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Link: https://lore.kernel.org/r/20240313214031.1658045-1-fenghua.yu@intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
2024-04-07 17:56:06 +05:30
..
bus.c dmaengine: idxd: make dsa_bus_type const 2024-02-16 17:47:37 +05:30
cdev.c dmaengine: idxd: Convert spinlock to mutex to lock evl workqueue 2024-04-07 13:31:44 +05:30
compat.c dmaengine: idxd: use const struct bus_type * 2023-03-23 13:21:42 +01:00
debugfs.c dmaengine: idxd: Convert spinlock to mutex to lock evl workqueue 2024-04-07 13:31:44 +05:30
defaults.c dmaengine: idxd: Add support for device/wq defaults 2023-12-15 17:52:53 +08:00
device.c dmaengine: idxd: Convert spinlock to mutex to lock evl workqueue 2024-04-07 13:31:44 +05:30
dma.c dmaengine: idxd: add callback support for iaa crypto 2023-12-15 17:52:53 +08:00
idxd.h dmaengine: idxd: Convert spinlock to mutex to lock evl workqueue 2024-04-07 13:31:44 +05:30
init.c dmaengine: idxd: Convert spinlock to mutex to lock evl workqueue 2024-04-07 13:31:44 +05:30
irq.c dmaengine: idxd: Convert spinlock to mutex to lock evl workqueue 2024-04-07 13:31:44 +05:30
Makefile dmaengine: idxd: Add support for device/wq defaults 2023-12-15 17:52:53 +08:00
perfmon.c dmaengine: idxd: Fix oops during rmmod on single-CPU platforms 2024-04-07 17:56:06 +05:30
perfmon.h dmaengine: idxd: Add IDXD performance monitor support 2021-04-25 21:46:12 +05:30
registers.h dmaengine: idxd: Fix incorrect descriptions for GRPCFG register 2023-12-11 11:52:16 +05:30
submit.c This update includes the following changes: 2024-01-10 12:23:43 -08:00
sysfs.c dmaengine: idxd: constify the struct device_type usage 2024-02-22 19:29:31 +05:30