Messages in this thread | | | Date | Wed, 24 Aug 2011 12:43:35 +0200 | From | Jan Kiszka <> | Subject | Broken pci_block_user_cfg_access interface |
| |
Hi,
trying to port the generic device interrupt masking pattern of uio_pci_generic to KVM's device assignment code, I stumbled over some fundamental problem with the current pci_block/unblock_user_cfg_access interface: it does not provide any synchronization between blocking sides. This allows user space to trigger a kernel BUG, just run two
while true; do echo 1 > /sys/bus/pci/devices/<some-device>/reset; done
loops in parallel and watch the kernel oops.
Instead of some funky open-coded locking mechanism, we would rather need a plain mutex across both the user space access (via sysfs) and the sections guarded by pci_block/unblock_user_cfg_access so far. But I'm not sure which of them already allow sleeping, specifically if the IPR driver would be fine with such a change. Can someone in the CC list comment on this?
uio_pci_generic would definitely not be able to sleep as it takes the lock from (potentially hard) IRQ context. This particular use case, RMW of command/status word, requires a separate mechanism. I'm considering to introduce a dedicated raw spinlock with IRQ protection for that words, maybe also a PCI core service to abstract INTx testing and masking.
Any further thoughts on how to resolve this issue?
Thanks, Jan
-- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux
| |