From: Jacob Keller <jacob.e.keller@intel.com>
To: linux-pci@vger.kernel.org
Cc: Jacob Keller <jacob.e.keller@intel.com>,
Alex Williamson <alex.williamson@redhat.com>,
Kay Sievers <kay.sievers@vrfy.org>,
"Rafael J . Wysocki" <rjw@sisk.pl>,
Alan Stern <stern@rowland.harvard.edu>,
Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] don't allow vfio drivers to bind on driver_attach
Date: Tue, 12 Jan 2016 13:33:09 -0800 [thread overview]
Message-ID: <1452634390-17729-1-git-send-email-jacob.e.keller@intel.com> (raw)
This patch is an attempt to resolve an issue which can occur when using
vfio-pci (and vfio-platform) with IOMMU direct assignment.
When attempting to directly assign a device to a virtual machine, the
normal flow is something like the following:
echo <pci address> > /sys/bus/pci/drivers/<old driver>/unbind
echo <device id> > /sys/bus/pci/drivers/vfio-pci/new_id
echo <pci address> > /sys/bus/pci/drivers/vfio-pci/bind
This process results in the device being bound to the vfio-pci stub
driver, and then this device can be safely given to a virtual machine.
The issue can occur, that if <device id> doesn't currently have a driver
loaded, (like say the module was removed), the process of adding
<new_id> can result in *all* devices which match that id being bound to
vfio-pci. This may not seem like a problem, but it can be confusing when
you have a dual-port device, such as a networking card. In some use
cases, you only want to assign a single port to a VM and not all the
ports. If you happen to not have the driver loaded already, the result
is that even loading the driver later will not gain control of the 2nd
port, because the device is already bound to vfio-pci. The solution (if
you know this is the case) would be to unbind that particular device
from vfio and bind it to the real driver.
This patch fixes the issue by instead requiring vfio-pci and
vfio-platform to only bind to devices given via the sysfs bind route,
and prevents bind to any devices in other scenarios. The result is that
vfio-pci will never bind a device unless explicitly requested. Given the
nature of what vfio-pci does, I think this is a much better solution.
I've tried to Cc several people who've made changes to this area of th
kernel for more feedback.
Jacob Keller (1):
driver: add manual_bind_only option for virtual stub drivers
drivers/base/dd.c | 6 ++++++
drivers/vfio/pci/vfio_pci.c | 3 +++
drivers/vfio/platform/vfio_platform.c | 1 +
include/linux/device.h | 1 +
4 files changed, 11 insertions(+)
--
2.6.3.505.g5cc1fd1
next reply other threads:[~2016-01-12 21:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-12 21:33 Jacob Keller [this message]
2016-01-12 21:33 ` [PATCH] driver: add manual_bind_only option for virtual stub drivers Jacob Keller
2016-01-12 21:53 ` kbuild test robot
2016-01-13 0:02 ` kbuild test robot
2016-01-12 22:06 ` [PATCH] don't allow vfio drivers to bind on driver_attach Alex Williamson
2016-01-12 22:25 ` Keller, Jacob E
2016-01-12 22:43 ` Alex Williamson
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=1452634390-17729-1-git-send-email-jacob.e.keller@intel.com \
--to=jacob.e.keller@intel.com \
--cc=alex.williamson@redhat.com \
--cc=arjan@linux.intel.com \
--cc=kay.sievers@vrfy.org \
--cc=linux-pci@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=stern@rowland.harvard.edu \
/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;
as well as URLs for NNTP newsgroup(s).