From: Brian King <brking@linux.vnet.ibm.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Alex Williamson <alex.williamson@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
Matthew Wilcox <matthew@wil.cx>
Subject: Re: Broken pci_block_user_cfg_access interface
Date: Wed, 24 Aug 2011 10:02:48 -0500 [thread overview]
Message-ID: <4E551298.2000302@linux.vnet.ibm.com> (raw)
In-Reply-To: <4E54D5D7.8050807@siemens.com>
On 08/24/2011 05:43 AM, Jan Kiszka wrote:
> 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?
The ipr driver calls pci_block/unblock_user_cfg_access from interrupt
context, so a mutex won't work. When the pci_block/unblock API was
originally added, it did not have the checking it has today to detect
if it is being called nested. This was added some time later. The
API that works best for the ipr driver is to allow for many block calls,
but a single unblock call unblocks access. It seems like what might
work well in the case above is a block count. Each call to pci_block
increments a count. Each pci_unblock decrements the count and only
actually do the unblock if the count drops to zero. It should be reasonably
simple for ipr to use that sort of an API as well.
-Brian
--
Brian King
Linux on Power Virtualization
IBM Linux Technology Center
next prev parent reply other threads:[~2011-08-24 15:03 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-24 10:43 Broken pci_block_user_cfg_access interface Jan Kiszka
2011-08-24 15:02 ` Brian King [this message]
2011-08-25 9:19 ` Jan Kiszka
2011-08-25 9:40 ` Michael S. Tsirkin
2011-08-25 10:34 ` Jan Kiszka
2011-08-25 13:06 ` Brian King
2011-08-25 13:12 ` Brian King
2011-08-25 13:16 ` Jan Kiszka
2011-08-25 13:24 ` Brian King
2011-08-25 18:16 ` Michael S. Tsirkin
2011-08-25 13:02 ` Brian King
2011-08-25 13:06 ` Jan Kiszka
2011-08-25 18:19 ` Michael S. Tsirkin
2011-08-25 18:52 ` Jan Kiszka
2011-08-25 19:07 ` Michael S. Tsirkin
2011-08-25 19:26 ` Jan Kiszka
2011-08-29 15:05 ` Michael S. Tsirkin
2011-08-29 15:42 ` Jan Kiszka
2011-08-29 15:58 ` Michael S. Tsirkin
2011-08-29 16:14 ` Jan Kiszka
2011-08-29 16:23 ` Michael S. Tsirkin
2011-08-29 16:26 ` Jan Kiszka
2011-08-29 18:47 ` Jan Kiszka
2011-08-29 19:18 ` Michael S. Tsirkin
2011-08-30 16:30 ` Brian King
2011-08-30 18:01 ` Michael S. Tsirkin
2011-08-30 19:41 ` Brian King
2011-09-02 7:48 ` [RFC] pci: Rework config space blocking services Jan Kiszka
2011-09-06 7:00 ` Michael S. Tsirkin
2011-09-06 7:18 ` Jan Kiszka
2011-09-06 8:04 ` Michael S. Tsirkin
2011-09-06 8:27 ` Jan Kiszka
2011-09-06 8:47 ` Michael S. Tsirkin
2011-09-06 8:48 ` Jan Kiszka
2011-09-07 13:46 ` Brian King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E551298.2000302@linux.vnet.ibm.com \
--to=brking@linux.vnet.ibm.com \
--cc=alex.williamson@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=jbarnes@virtuousgeek.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=matthew@wil.cx \
--cc=mst@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox