21 May, 2019

1 commit


19 Apr, 2019

1 commit

  • Make the anon_inodes facility unconditional so that it can be used by core
    VFS code and pidfd code.

    Signed-off-by: David Howells
    Signed-off-by: Al Viro
    [christian@brauner.io: adapt commit message to mention pidfds]
    Signed-off-by: Christian Brauner

    David Howells
     

26 Sep, 2018

1 commit

  • Currently the type-1 IOMMU instantiation depends on "ARM_SMMU ||
    ARM_SMMU_V3", while it applies to other ARM/ARM64 platforms with an
    IOMMU (e.g. Renesas VMSA-compatible IPMMUs).

    Instead of extending the list of IOMMU types on ARM platforms, replace
    the list by "ARM || ARM64", like other architectures do. The feature is
    still restricted to ARM/ARM64 platforms with an IOMMU by the dependency
    on IOMMU_API.

    Signed-off-by: Geert Uytterhoeven
    Reviewed-by: Robin Murphy
    Reviewed-by: Simon Horman
    Signed-off-by: Alex Williamson

    Geert Uytterhoeven
     

09 Feb, 2017

1 commit

  • Currently the kconfig logic for VFIO_IOMMU_SPAPR_TCE and VFIO_SPAPR_EEH
    is broken when SPAPR_TCE_IOMMU=n. Leading to:

    warning: (VFIO) selects VFIO_IOMMU_SPAPR_TCE which has unmet direct dependencies (VFIO && SPAPR_TCE_IOMMU)
    warning: (VFIO) selects VFIO_IOMMU_SPAPR_TCE which has unmet direct dependencies (VFIO && SPAPR_TCE_IOMMU)
    drivers/vfio/vfio_iommu_spapr_tce.c:113:8: error: implicit declaration of function 'mm_iommu_find'

    This stems from the fact that VFIO selects VFIO_IOMMU_SPAPR_TCE, and
    although it has an if clause, the condition is not correct.

    We could fix it by doing select VFIO_IOMMU_SPAPR_TCE if SPAPR_TCE_IOMMU,
    but the cleaner fix is to drop the selects and tie VFIO_IOMMU_SPAPR_TCE
    to the value of VFIO, and express the dependencies in only once place.

    Do the same for VFIO_SPAPR_EEH.

    The end result is that the values of VFIO_IOMMU_SPAPR_TCE and
    VFIO_SPAPR_EEH follow the value of VFIO, except when SPAPR_TCE_IOMMU=n
    and/or EEH=n. Which is exactly what we want to happen.

    Signed-off-by: Michael Ellerman
    Signed-off-by: Alex Williamson

    Michael Ellerman
     

17 Nov, 2016

1 commit

  • Design for Mediated Device Driver:
    Main purpose of this driver is to provide a common interface for mediated
    device management that can be used by different drivers of different
    devices.

    This module provides a generic interface to create the device, add it to
    mediated bus, add device to IOMMU group and then add it to vfio group.

    Below is the high Level block diagram, with Nvidia, Intel and IBM devices
    as example, since these are the devices which are going to actively use
    this module as of now.

    +---------------+
    | |
    | +-----------+ | mdev_register_driver() +--------------+
    | | | ++ | VFIO user
    | | driver | | probe()/remove() | vfio_mdev.ko | APIs
    | | | | | |
    | +-----------+ | +--------------+
    | |
    | MDEV CORE |
    | MODULE |
    | mdev.ko |
    | +-----------+ | mdev_register_device() +--------------+
    | | | + physical
    | | | +------------------------>+ | device
    | | | | callback +--------------+
    | | Physical | |
    | | device | | mdev_register_device() +--------------+
    | | interface | | physical
    | | | +------------------------>+ | device
    | | | | callback +--------------+
    | | | |
    | | | | mdev_register_device() +--------------+
    | | | + physical
    | | | +------------------------>+ | device
    | | | | callback +--------------+
    | +-----------+ |
    +---------------+

    Core driver provides two types of registration interfaces:
    1. Registration interface for mediated bus driver:

    /**
    * struct mdev_driver - Mediated device's driver
    * @name: driver name
    * @probe: called when new device created
    * @remove:called when device removed
    * @driver:device driver structure
    *
    **/
    struct mdev_driver {
    const char *name;
    int (*probe) (struct device *dev);
    void (*remove) (struct device *dev);
    struct device_driver driver;
    };

    Mediated bus driver for mdev device should use this interface to register
    and unregister with core driver respectively:

    int mdev_register_driver(struct mdev_driver *drv, struct module *owner);
    void mdev_unregister_driver(struct mdev_driver *drv);

    Mediated bus driver is responsible to add/delete mediated devices to/from
    VFIO group when devices are bound and unbound to the driver.

    2. Physical device driver interface
    This interface provides vendor driver the set APIs to manage physical
    device related work in its driver. APIs are :

    * dev_attr_groups: attributes of the parent device.
    * mdev_attr_groups: attributes of the mediated device.
    * supported_type_groups: attributes to define supported type. This is
    mandatory field.
    * create: to allocate basic resources in vendor driver for a mediated
    device. This is mandatory to be provided by vendor driver.
    * remove: to free resources in vendor driver when mediated device is
    destroyed. This is mandatory to be provided by vendor driver.
    * open: open callback of mediated device
    * release: release callback of mediated device
    * read : read emulation callback.
    * write: write emulation callback.
    * ioctl: ioctl callback.
    * mmap: mmap emulation callback.

    Drivers should use these interfaces to register and unregister device to
    mdev core driver respectively:

    extern int mdev_register_device(struct device *dev,
    const struct parent_ops *ops);
    extern void mdev_unregister_device(struct device *dev);

    There are no locks to serialize above callbacks in mdev driver and
    vfio_mdev driver. If required, vendor driver can have locks to serialize
    above APIs in their driver.

    Signed-off-by: Kirti Wankhede
    Signed-off-by: Neo Jia
    Reviewed-by: Jike Song
    Reviewed-by: Dong Jia Shi
    Signed-off-by: Alex Williamson

    Kirti Wankhede
     

22 Dec, 2015

1 commit

  • There is really no way to safely give a user full access to a DMA
    capable device without an IOMMU to protect the host system. There is
    also no way to provide DMA translation, for use cases such as device
    assignment to virtual machines. However, there are still those users
    that want userspace drivers even under those conditions. The UIO
    driver exists for this use case, but does not provide the degree of
    device access and programming that VFIO has. In an effort to avoid
    code duplication, this introduces a No-IOMMU mode for VFIO.

    This mode requires building VFIO with CONFIG_VFIO_NOIOMMU and enabling
    the "enable_unsafe_noiommu_mode" option on the vfio driver. This
    should make it very clear that this mode is not safe. Additionally,
    CAP_SYS_RAWIO privileges are necessary to work with groups and
    containers using this mode. Groups making use of this support are
    named /dev/vfio/noiommu-$GROUP and can only make use of the special
    VFIO_NOIOMMU_IOMMU for the container. Use of this mode, specifically
    binding a device without a native IOMMU group to a VFIO bus driver
    will taint the kernel and should therefore not be considered
    supported. This patch includes no-iommu support for the vfio-pci bus
    driver only.

    Signed-off-by: Alex Williamson
    Acked-by: Michael S. Tsirkin

    Alex Williamson
     

04 Dec, 2015

1 commit

  • Revert commit 033291eccbdb ("vfio: Include No-IOMMU mode") due to lack
    of a user. This was originally intended to fill a need for the DPDK
    driver, but uptake has been slow so rather than support an unproven
    kernel interface revert it and revisit when userspace catches up.

    Signed-off-by: Alex Williamson

    Alex Williamson
     

14 Nov, 2015

1 commit

  • Pull VFIO updates from Alex Williamson:
    - Use kernel interfaces for VPD emulation (Alex Williamson)
    - Platform fix for releasing IRQs (Eric Auger)
    - Type1 IOMMU always advertises PAGE_SIZE support when smaller mapping
    sizes are available (Eric Auger)
    - Platform fixes for incorrectly using copies of structures rather than
    pointers to structures (James Morse)
    - Rework platform reset modules, fix leak, and add AMD xgbe reset
    module (Eric Auger)
    - Fix vfio_device_get_from_name() return value (Joerg Roedel)
    - No-IOMMU interface (Alex Williamson)
    - Fix potential out of bounds array access in PCI config handling (Dan
    Carpenter)

    * tag 'vfio-v4.4-rc1' of git://github.com/awilliam/linux-vfio:
    vfio/pci: make an array larger
    vfio: Include No-IOMMU mode
    vfio: Fix bug in vfio_device_get_from_name()
    VFIO: platform: reset: AMD xgbe reset module
    vfio: platform: reset: calxedaxgmac: fix ioaddr leak
    vfio: platform: add dev_info on device reset
    vfio: platform: use list of registered reset function
    vfio: platform: add compat in vfio_platform_device
    vfio: platform: reset: calxedaxgmac: add reset function registration
    vfio: platform: introduce module_vfio_reset_handler macro
    vfio: platform: add capability to register a reset function
    vfio: platform: introduce vfio-platform-base module
    vfio/platform: store mapped memory in region, instead of an on-stack copy
    vfio/type1: handle case where IOMMU does not support PAGE_SIZE size
    VFIO: platform: clear IRQ_NOAUTOEN when de-assigning the IRQ
    vfio/pci: Use kernel VPD access functions
    vfio: Whitelist PCI bridges

    Linus Torvalds
     

05 Nov, 2015

1 commit

  • There is really no way to safely give a user full access to a DMA
    capable device without an IOMMU to protect the host system. There is
    also no way to provide DMA translation, for use cases such as device
    assignment to virtual machines. However, there are still those users
    that want userspace drivers even under those conditions. The UIO
    driver exists for this use case, but does not provide the degree of
    device access and programming that VFIO has. In an effort to avoid
    code duplication, this introduces a No-IOMMU mode for VFIO.

    This mode requires building VFIO with CONFIG_VFIO_NOIOMMU and enabling
    the "enable_unsafe_noiommu_mode" option on the vfio driver. This
    should make it very clear that this mode is not safe. Additionally,
    CAP_SYS_RAWIO privileges are necessary to work with groups and
    containers using this mode. Groups making use of this support are
    named /dev/vfio/noiommu-$GROUP and can only make use of the special
    VFIO_NOIOMMU_IOMMU for the container. Use of this mode, specifically
    binding a device without a native IOMMU group to a VFIO bus driver
    will taint the kernel and should therefore not be considered
    supported. This patch includes no-iommu support for the vfio-pci bus
    driver only.

    Signed-off-by: Alex Williamson
    Acked-by: Michael S. Tsirkin

    Alex Williamson
     

01 Oct, 2015

1 commit


29 May, 2015

1 commit


17 Mar, 2015

2 commits

  • An unintended consequence of commit 42ac9bd18d4f ("vfio: initialize
    the virqfd workqueue in VFIO generic code") is that the vfio module
    is renamed to vfio_core so that it can include both vfio and virqfd.
    That's a user visible change that may break module loading scritps
    and it imposes eventfd support as a dependency on the core vfio code,
    which it's really not. virqfd is intended to be provided as a service
    to vfio bus drivers, so instead of wrapping it into vfio.ko, we can
    make it a stand-alone module toggled by vfio bus drivers. This has
    the additional benefit of removing initialization and exit from the
    core vfio code.

    Signed-off-by: Alex Williamson

    Alex Williamson
     
  • Enable building the VFIO PLATFORM driver that allows to use Linux platform
    devices with VFIO.

    Signed-off-by: Antonios Motakis
    Signed-off-by: Baptiste Reynal
    Reviewed-by: Eric Auger
    Tested-by: Eric Auger
    Signed-off-by: Alex Williamson

    Antonios Motakis
     

15 Nov, 2014

1 commit


08 Nov, 2014

1 commit


09 Aug, 2014

1 commit

  • The VFIO related components could be built as dynamic modules.
    Unfortunately, CONFIG_EEH can't be configured to "m". The patch
    fixes the build errors when configuring VFIO related components
    as dynamic modules as follows:

    CC [M] drivers/vfio/vfio_iommu_spapr_tce.o
    In file included from drivers/vfio/vfio.c:33:0:
    include/linux/vfio.h:101:43: warning: ‘struct pci_dev’ declared \
    inside parameter list [enabled by default]
    :
    WRAP arch/powerpc/boot/zImage.pseries
    WRAP arch/powerpc/boot/zImage.maple
    WRAP arch/powerpc/boot/zImage.pmac
    WRAP arch/powerpc/boot/zImage.epapr
    MODPOST 1818 modules
    ERROR: ".vfio_spapr_iommu_eeh_ioctl" [drivers/vfio/vfio_iommu_spapr_tce.ko]\
    undefined!
    ERROR: ".vfio_spapr_pci_eeh_open" [drivers/vfio/pci/vfio-pci.ko] undefined!
    ERROR: ".vfio_spapr_pci_eeh_release" [drivers/vfio/pci/vfio-pci.ko] undefined!

    Reported-by: Alexey Kardashevskiy
    Signed-off-by: Gavin Shan
    Signed-off-by: Alexey Kardashevskiy
    Signed-off-by: Alex Williamson

    Gavin Shan
     

28 Mar, 2014

1 commit


20 Jun, 2013

2 commits

  • The enables VFIO on the pSeries platform, enabling user space
    programs to access PCI devices directly.

    Signed-off-by: Alexey Kardashevskiy
    Cc: David Gibson
    Signed-off-by: Paul Mackerras
    Acked-by: Alex Williamson
    Signed-off-by: Benjamin Herrenschmidt

    Alexey Kardashevskiy
     
  • VFIO implements platform independent stuff such as
    a PCI driver, BAR access (via read/write on a file descriptor
    or direct mapping when possible) and IRQ signaling.

    The platform dependent part includes IOMMU initialization
    and handling. This implements an IOMMU driver for VFIO
    which does mapping/unmapping pages for the guest IO and
    provides information about DMA window (required by a POWER
    guest).

    Cc: David Gibson
    Signed-off-by: Alexey Kardashevskiy
    Signed-off-by: Paul Mackerras
    Acked-by: Alex Williamson
    Signed-off-by: Benjamin Herrenschmidt

    Alexey Kardashevskiy
     

31 Jul, 2012

3 commits

  • Add PCI device support for VFIO. PCI devices expose regions
    for accessing config space, I/O port space, and MMIO areas
    of the device. PCI config access is virtualized in the kernel,
    allowing us to ensure the integrity of the system, by preventing
    various accesses while reducing duplicate support across various
    userspace drivers. I/O port supports read/write access while
    MMIO also supports mmap of sufficiently sized regions. Support
    for INTx, MSI, and MSI-X interrupts are provided using eventfds to
    userspace.

    Signed-off-by: Alex Williamson

    Alex Williamson
     
  • This VFIO IOMMU backend is designed primarily for AMD-Vi and Intel
    VT-d hardware, but is potentially usable by anything supporting
    similar mapping functionality. We arbitrarily call this a Type1
    backend for lack of a better name. This backend has no IOVA
    or host memory mapping restrictions for the user and is optimized
    for relatively static mappings. Mapped areas are pinned into system
    memory.

    Signed-off-by: Alex Williamson

    Alex Williamson
     
  • VFIO is a secure user level driver for use with both virtual machines
    and user level drivers. VFIO makes use of IOMMU groups to ensure the
    isolation of devices in use, allowing unprivileged user access. It's
    intended that VFIO will replace KVM device assignment and UIO drivers
    (in cases where the target platform includes a sufficiently capable
    IOMMU).

    New in this version of VFIO is support for IOMMU groups managed
    through the IOMMU core as well as a rework of the API, removing the
    group merge interface. We now go back to a model more similar to
    original VFIO with UIOMMU support where the file descriptor obtained
    from /dev/vfio/vfio allows access to the IOMMU, but only after a
    group is added, avoiding the previous privilege issues with this type
    of model. IOMMU support is also now fully modular as IOMMUs have
    vastly different interface requirements on different platforms. VFIO
    users are able to query and initialize the IOMMU model of their
    choice.

    Please see the follow-on Documentation commit for further description
    and usage example.

    Signed-off-by: Alex Williamson

    Alex Williamson