vfio: Introduce documentation for VFIO driver

Including rationale for design, example usage and API description.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
vfio: VFIO core header

This defines both the user and bus driver APIs.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
vfio: VFIO core group interface

This provides the base group management with conduits to the
IOMMU driver and VFIO bus drivers.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
vfio: VFIO core IOMMU mapping support

Backing for operations on the IOMMU object, including DMA
mapping and unmapping.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
vfio: VFIO core Kconfig and Makefile

Enable the base code.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
pci: export pci_user_read/write_config_*

When a module provides access for a user to do config accesses,
we'd like to route them through these existing routines.  Export
them so modules can call them.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
pci: Add some defines

This adds a few useful defines for parsing and bounding accesses
to PCI config space.  Original patch by Tom Lyon <pugs@ieee.org>.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
pci: Translate pcibios errors to standard errno

Several pci functions return PCIBIOS_* values (0/>0).  Not only are
we inconsistent in using this versus errno across architectures,
sometimes we want to return an error through non-PCI #defines.  Add
a simple inline function to replace the PCI specific error with the
most appropriate errno.  This is safe to call whether the error
value is already an errno or PCIBIOS_*.

Xen already has a function of the same name, but translates to a
Xen specific error value scheme.  Trivial rename for them to
avoid conflict.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
vfio: Add PCI device support

This adds VFIO backing for PCI device to be added and removed from
the VFIO framework and securely accessed from userspace.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
iommu: Include MSI susceptibility to DMA in creating iommu groups

IOMMU drivers should account for the platform's susceptibility to
DMA triggered MSI interrupts in creating IOMMU groups.  Skip
devices when the IOMMU can't isolate MSI from DMA, but allow
an iommu=group_unsafe_msi option for opt-in.  This removes the
leap in logic for users that IOMMU_CAP_INTR_REMAP is required for
interrupt security when they may be running on a non-x86 platform
that does not have this dependency.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Merge remote branch 'github-linux-vfio/vfio-linux-staging' into groups2

Conflicts:
	drivers/iommu/amd_iommu.c
	drivers/iommu/intel-iommu.c
vfio: update to new iommu groups

This is a first pass hack at updating vfio & vfio-pci to use the
new iommu group interface.  Much cleanup necessary.  The significant
change is that since vfio is no longer managing groups, we don't need
to expose all of the groups in the system.  Therefore rather than
vfio-pci registering every device with vfio at init, we now only
register vfio groups if one of the devices in the group is attached
to a vfio driver.  For example, initially /dev/vfio doesn't exist.
If device 0000:01:10.1 belongs to group 42 and I bind this device to
vfio-pci, /dev/vfio/42 appears.  We could enumerate every group, but
doing it on demand feels like the right way.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>