linux/drivers
Alex Williamson 6a45ece4c9 vfio/pci: Handle concurrent vma faults
io_remap_pfn_range() will trigger a BUG_ON if it encounters a
populated pte within the mapping range.  This can occur because we map
the entire vma on fault and multiple faults can be blocked behind the
vma_lock.  This leads to traces like the one reported below.

We can use our vma_list to test whether a given vma is mapped to avoid
this issue.

[ 1591.733256] kernel BUG at mm/memory.c:2177!
[ 1591.739515] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
[ 1591.747381] Modules linked in: vfio_iommu_type1 vfio_pci vfio_virqfd vfio pv680_mii(O)
[ 1591.760536] CPU: 2 PID: 227 Comm: lcore-worker-2 Tainted: G O 5.11.0-rc3+ #1
[ 1591.770735] Hardware name:  , BIOS HixxxxFPGA 1P B600 V121-1
[ 1591.778872] pstate: 40400009 (nZcv daif +PAN -UAO -TCO BTYPE=--)
[ 1591.786134] pc : remap_pfn_range+0x214/0x340
[ 1591.793564] lr : remap_pfn_range+0x1b8/0x340
[ 1591.799117] sp : ffff80001068bbd0
[ 1591.803476] x29: ffff80001068bbd0 x28: 0000042eff6f0000
[ 1591.810404] x27: 0000001100910000 x26: 0000001300910000
[ 1591.817457] x25: 0068000000000fd3 x24: ffffa92f1338e358
[ 1591.825144] x23: 0000001140000000 x22: 0000000000000041
[ 1591.832506] x21: 0000001300910000 x20: ffffa92f141a4000
[ 1591.839520] x19: 0000001100a00000 x18: 0000000000000000
[ 1591.846108] x17: 0000000000000000 x16: ffffa92f11844540
[ 1591.853570] x15: 0000000000000000 x14: 0000000000000000
[ 1591.860768] x13: fffffc0000000000 x12: 0000000000000880
[ 1591.868053] x11: ffff0821bf3d01d0 x10: ffff5ef2abd89000
[ 1591.875932] x9 : ffffa92f12ab0064 x8 : ffffa92f136471c0
[ 1591.883208] x7 : 0000001140910000 x6 : 0000000200000000
[ 1591.890177] x5 : 0000000000000001 x4 : 0000000000000001
[ 1591.896656] x3 : 0000000000000000 x2 : 0168044000000fd3
[ 1591.903215] x1 : ffff082126261880 x0 : fffffc2084989868
[ 1591.910234] Call trace:
[ 1591.914837]  remap_pfn_range+0x214/0x340
[ 1591.921765]  vfio_pci_mmap_fault+0xac/0x130 [vfio_pci]
[ 1591.931200]  __do_fault+0x44/0x12c
[ 1591.937031]  handle_mm_fault+0xcc8/0x1230
[ 1591.942475]  do_page_fault+0x16c/0x484
[ 1591.948635]  do_translation_fault+0xbc/0xd8
[ 1591.954171]  do_mem_abort+0x4c/0xc0
[ 1591.960316]  el0_da+0x40/0x80
[ 1591.965585]  el0_sync_handler+0x168/0x1b0
[ 1591.971608]  el0_sync+0x174/0x180
[ 1591.978312] Code: eb1b027f 540000c0 f9400022 b4fffe02 (d4210000)

Fixes: 11c4cd07ba ("vfio-pci: Fault mmaps to enable vma tracking")
Reported-by: Zeng Tao <prime.zeng@hisilicon.com>
Suggested-by: Zeng Tao <prime.zeng@hisilicon.com>
Link: https://lore.kernel.org/r/162497742783.3883260.3282953006487785034.stgit@omen
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2021-06-30 13:55:53 -06:00
..
accessibility
acpi Merge branch 'acpi-bus' 2021-06-11 17:57:24 +02:00
amba
android binder: Return EFAULT if we fail BINDER_ENABLE_ONEWAY_SPAM_DETECTION 2021-05-13 20:35:26 +02:00
ata pci-v5.13-changes 2021-05-05 13:24:11 -07:00
atm atm: firestream: Use fallthrough pseudo-keyword 2021-05-07 16:01:08 -07:00
auxdisplay treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
base driver core: Export device_driver_attach() 2021-06-21 15:29:24 -06:00
bcma
block block-5.13-2021-06-12 2021-06-12 11:59:58 -07:00
bluetooth Networking fixes for 5.13-rc5, including fixes from bpf, wireless, 2021-06-04 18:25:39 -07:00
bus Char/Misc driver fixes for 5.13-rc6 2021-06-12 12:13:55 -07:00
cdrom cdrom: gdrom: initialize global variable at init time 2021-05-13 18:58:44 +02:00
char Char/misc driver fixes for 5.13-rc3 2021-05-20 06:31:52 -10:00
clk clk: Skip clk provider registration when np is NULL 2021-05-11 08:47:25 +02:00
clocksource clocksource/drivers/hyper-v: Re-enable VDSO_CLOCKMODE_HVCLOCK on X86 2021-05-14 14:55:13 +02:00
comedi
connector
counter
cpufreq Fix an idle CPU selection bug, and an AMD Ryzen maximum frequency enumeration bug. 2021-05-15 10:24:48 -07:00
cpuidle
crypto Revert "crypto: cavium/nitrox - add an error message to explain the failure of pci_request_mem_regions" 2021-05-13 17:23:05 +02:00
cxl
dax
dca
devfreq
dio
dma dmaengine: idxd: Use cpu_feature_enabled() 2021-06-03 16:32:59 +02:00
dma-buf dma-buf: fix unintended pin/unpin warnings 2021-05-20 14:02:27 +02:00
edac x86/msr: Rename MSR_K8_SYSCFG to MSR_AMD64_SYSCFG 2021-05-10 07:51:38 +02:00
eisa
extcon
firewire
firmware EFI fixes for v5.13-rc 2021-05-23 11:39:02 +02:00
fpga
fsi
gnss
gpio gpio: wcd934x: Fix shift-out-of-bounds error 2021-05-27 09:51:35 +02:00
gpu vfio/mdev: Remove CONFIG_VFIO_MDEV_DEVICE 2021-06-21 15:29:25 -06:00
greybus
hid HID: asus: Cleanup Asus T101HA keyboard-dock handling 2021-05-27 15:40:35 +02:00
hsi
hv
hwmon hwmon: (tps23861) correct shunt LSB values 2021-06-10 08:40:09 -07:00
hwspinlock
hwtracing
i2c i2c: qcom-geni: Suspend and resume the bus during SYSTEM_SLEEP_PM ops 2021-06-04 22:32:58 +02:00
i3c
ide
idle
iio iio: adc: ad7793: Add missing error code in ad7793_setup() 2021-05-22 08:32:36 +01:00
infiniband IB/mlx5: Fix initializing CQ fragments buffer 2021-06-10 08:59:34 -03:00
input Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2021-05-06 23:37:55 -07:00
interconnect interconnect: qcom: Add missing MODULE_DEVICE_TABLE 2021-05-11 07:26:31 +03:00
iommu iommu/vt-d: Fix sysfs leak in alloc_iommu() 2021-05-27 16:07:08 +02:00
ipack
irqchip irqchip: Remove redundant error printing 2021-05-16 13:07:18 +01:00
isdn Networking fixes for 5.13-rc4, including fixes from bpf, netfilter, 2021-05-26 17:44:49 -10:00
leds leds: lp5523: check return value of lp5xx_read and jump to cleanup code 2021-05-13 17:30:15 +02:00
lightnvm
macintosh
mailbox
mcb
md block-5.13-2021-06-12 2021-06-12 11:59:58 -07:00
media media: gspca: properly check for errors in po1030_probe() 2021-05-13 18:58:32 +02:00
memory
memstick
message
mfd
misc misc: rtsx: separate aspm mode into MODE_REG and MODE_CFG 2021-06-09 19:10:22 +02:00
mmc mmc: renesas_sdhi: Fix HS400 on R-Car M3-W+ 2021-06-08 14:56:54 +02:00
most
mtd mtd: parsers: ofpart: fix parsing subpartitions 2021-05-10 18:34:30 +02:00
mux
net RDMA second v5.13 rc Pull Request 2021-06-10 10:53:04 -07:00
nfc NFC: nfcmrvl: fix kernel-doc syntax in file headers 2021-05-23 17:26:38 -07:00
ntb
nubus
nvdimm include: remove pagemap.h from blkdev.h 2021-05-06 19:24:11 -07:00
nvme nvmet: fix freeing unallocated p2pmem 2021-06-02 10:10:38 +03:00
nvmem
of
opp
parisc
parport treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
pci PCI: Export pci_dev_trylock() and pci_dev_unlock() 2021-06-24 13:32:31 -06:00
pcmcia
perf
phy phy: Sparx5 Eth SerDes: check return value after calling platform_get_resource() 2021-06-03 11:18:19 +05:30
pinctrl pinctrl: qcom: Make it possible to select SC8180x TLMM 2021-06-09 13:15:20 +02:00
platform platform/mellanox: mlxreg-hotplug: Revert "move to use request_irq by IRQF_NO_AUTOEN flag" 2021-06-04 22:03:13 +02:00
pnp
power
powercap
pps
ps3
ptp ptp: ocp: Fix a resource leak in an error handling path 2021-05-12 14:06:33 -07:00
pwm pwm: Changes for v5.13-rc1 2021-05-05 12:53:16 -07:00
rapidio rapidio: handle create_workqueue() failure 2021-05-13 18:32:19 +02:00
ras
regulator regulator: Fixes for v5.14 2021-06-08 09:41:16 -07:00
remoteproc
reset pci-v5.13-changes 2021-05-05 13:24:11 -07:00
rpmsg
rtc
s390 - Fix races in vfio-ccw request handling. 2021-05-29 05:51:53 -10:00
sbus
scsi SCSI fixes on 20210613 2021-06-13 12:25:33 -07:00
sh
siox
slimbus
soc soc: amlogic: meson-clk-measure: remove redundant dev_err call in meson_msr_probe() 2021-05-31 09:26:58 +02:00
soundwire soundwire: qcom: fix handling of qcom,ports-block-pack-mode 2021-05-13 11:14:13 +05:30
spi spi: stm32-qspi: Always wait BUSY bit to be cleared in stm32_qspi_wait_cmd() 2021-06-03 13:55:36 +01:00
spmi
ssb
staging staging: ralink-gdma: Remove incorrect author information 2021-06-09 12:07:52 +02:00
target scsi: target: core: Fix warning on realtime kernels 2021-05-31 22:59:13 -04:00
tc
tee OP-TEE use export_uuid() to copy UUID 2021-06-05 15:43:11 -07:00
thermal - Fix out-of-spec hardware (1st gen Hygon) which does not implement 2021-06-06 12:25:43 -07:00
thunderbolt thunderbolt: usb4: Fix NVM read buffer bounds and offset issue 2021-05-20 11:52:58 +03:00
tty serial: 8250_exar: Avoid NULL pointer dereference at ->exit() 2021-06-09 14:40:48 +02:00
uio uio_hv_generic: Fix another memory leak in error handling paths 2021-05-14 13:26:04 +02:00
usb USB-serial fixes for 5.13-rc6 2021-06-11 12:32:49 +02:00
vdpa {net,vdpa}/mlx5: Configure interface MAC into mpfs L2 table 2021-05-18 23:01:48 -07:00
vfio vfio/pci: Handle concurrent vma faults 2021-06-30 13:55:53 -06:00
vhost virtio,vhost,vdpa: features, fixes 2021-05-05 13:31:39 -07:00
video Revert "fb_defio: Remove custom address_space_operations" 2021-06-01 17:38:40 +02:00
virt
virtio
visorbus
vlynq
vme
w1
watchdog
xen xen-pciback: reconfigure also from backend watch handler 2021-05-21 09:55:16 +02:00
zorro
Kconfig
Makefile virtio,vhost,vdpa: features, fixes 2021-05-05 13:31:39 -07:00