- 23 2月, 2016 8 次提交
-
-
由 Alex Williamson 提交于
Provide read-only access to PCI config space of the PCI host bridge and LPC bridge through device specific regions. This may be used to configure a VM with matching register contents to satisfy driver requirements. Providing this through the vfio file descriptor removes an additional userspace requirement for access through pci-sysfs and removes the CAP_SYS_ADMIN requirement that doesn't appear to apply to the specific devices we're accessing. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Alex Williamson 提交于
This is the first consumer of vfio device specific resource support, providing read-only access to the OpRegion for Intel graphics devices. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Alex Williamson 提交于
Typically config space for a device is mapped out into capability specific handlers and unassigned space. The latter allows direct read/write access to config space. Sometimes we know about registers living in this void space and would like an easy way to virtualize them, similar to how BAR registers are managed. To do this, create one more pseudo (fake) PCI capability to be handled as purely virtual space. Reads and writes are serviced entirely from virtual config space. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Alex Williamson 提交于
Add support for additional regions with indexes started after the already defined fixed regions. Device specific code can register these regions with the new vfio_pci_register_dev_region() function. The ops structure per region currently only includes read/write access and a release function, allowing automatic cleanup when the device is closed. mmap support is only missing here because it's not needed by the first user queued for this support. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Alex Williamson 提交于
vfio-pci has never allowed the user to directly mmap the MSI-X vector table, but we've always relied on implicit knowledge of the user that they cannot do this. Now that we have capability chains that we can expose in the region info ioctl and a sparse mmap capability that represents the sub-areas within the region that can be mmap'd, we can make the mmap constraints more explicit. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Alex Williamson 提交于
Allow sub-modules to easily reallocate a buffer for managing capability chains for info ioctls. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Alex Williamson 提交于
Consider an IOMMU to be an API rather than an implementation, we might have multiple implementations supporting the same API, so try another if one fails. The expectation here is that we'll really only have one implementation per device type. For instance the existing type1 driver works with any PCI device where the IOMMU API is available. A vGPU vendor may have a virtual PCI device which provides DMA isolation and mapping through other mechanisms, but can re-use userspaces that make use of the type1 VFIO IOMMU API. This allows that to work. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Alex Williamson 提交于
Signed versus unsigned comparisons are implicitly cast to unsigned, which result in a couple possible overflows. For instance (start + count) might overflow and wrap, getting through our validation test. Also when unwinding setup, -1 being compared as unsigned doesn't produce the intended stop condition. Fix both of these and also fix vfio_msi_set_vector_signal() to validate parameters before using the vector index, though none of the callers should pass bad indexes anymore. Reported-by: NEric Auger <eric.auger@linaro.org> Reviewed-by: NEric Auger <eric.auger@linaro.org> Tested-by: NEric Auger <eric.auger@linaro.org> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 28 1月, 2016 1 次提交
-
-
由 Alex Williamson 提交于
Using iommu_present() to determine whether an IOMMU group is real or fake has some problems. First, apparently Power systems don't register an IOMMU on the device bus, so the groups and containers get marked as noiommu and then won't bind to their actual IOMMU driver. Second, I expect we'll run into the same issue as we try to support vGPUs through vfio, since they're likely to emulate this behavior of creating an IOMMU group on a virtual device and then providing a vfio IOMMU backend tailored to the sort of isolation they provide, which won't necessarily be fully compatible with the IOMMU API. The solution here is to use the existing iommudata interface to IOMMU groups, which allows us to easily identify the fake groups we've created for noiommu purposes. The iommudata we set is purely arbitrary since we're only comparing the address, so we use the address of the noiommu switch itself. Reported-by: NAlexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: NAlexey Kardashevskiy <aik@ozlabs.ru> Tested-by: NAlexey Kardashevskiy <aik@ozlabs.ru> Tested-by: NAnatoly Burakov <anatoly.burakov@intel.com> Tested-by: NSantosh Shukla <sshukla@mvista.com> Fixes: 03a76b60 ("vfio: Include No-IOMMU mode") Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 05 1月, 2016 1 次提交
-
-
由 Pierre Morel 提交于
The flags entry is there to tell the user that some optional information is available. Since we report the iova_pgsizes signal it to the user by setting the flags to VFIO_IOMMU_INFO_PGSIZES. Signed-off-by: NPierre Morel <pmorel@linux.vnet.ibm.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 22 12月, 2015 2 次提交
-
-
由 Alex Williamson 提交于
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: NAlex Williamson <alex.williamson@redhat.com> Acked-by: NMichael S. Tsirkin <mst@redhat.com>
-
由 Dan Carpenter 提交于
This loop ends with count set to -1 and not zero so the warning message isn't printed when it should be. I've fixed this by change the postop to a preop. Fixes: 0990822c ('VFIO: platform: reset: AMD xgbe reset module') Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com> Reviewed-by: NEric Auger <eric.auger@linaro.org> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 04 12月, 2015 1 次提交
-
-
由 Alex Williamson 提交于
Revert commit 033291ec ("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: NAlex Williamson <alex.williamson@redhat.com>
-
- 21 11月, 2015 2 次提交
-
-
由 Dan Carpenter 提交于
The first argument to the WARN() macro has to be a condition. I'm sort of disappointed that this code doesn't generate a compiler warning. I guess -Wformat-extra-args doesn't work in the kernel. Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Kees Cook 提交于
request_module already takes format strings, so no need to duplicate the effort. Signed-off-by: NKees Cook <keescook@chromium.org> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 20 11月, 2015 2 次提交
-
-
由 Julia Lawall 提交于
This pci_error_handlers structure is never modified, like all the other pci_error_handlers structures, so declare it as const. Done with the help of Coccinelle. Signed-off-by: NJulia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Krzysztof Kozlowski 提交于
platform_driver does not need to set an owner because platform_driver_register() will set it. Signed-off-by: NKrzysztof Kozlowski <k.kozlowski@samsung.com> Acked-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 09 11月, 2015 1 次提交
-
-
由 Dan Carpenter 提交于
Smatch complains about a possible out of bounds error: drivers/vfio/pci/vfio_pci_config.c:1241 vfio_cap_init() error: buffer overflow 'pci_cap_length' 20 <= 20 The problem is that pci_cap_length[] was defined as large enough to hold "PCI_CAP_ID_AF + 1" elements. The code in vfio_cap_init() assumes it has PCI_CAP_ID_MAX + 1 elements. Originally, PCI_CAP_ID_AF and PCI_CAP_ID_MAX were the same but then we introduced PCI_CAP_ID_EA in commit f80b0ba9 ("PCI: Add Enhanced Allocation register entries") so now the array is too small. Let's fix this by making the array size PCI_CAP_ID_MAX + 1. And let's make a similar change to pci_ext_cap_length[] for consistency. Also both these arrays can be made const. Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 05 11月, 2015 2 次提交
-
-
由 Alex Williamson 提交于
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: NAlex Williamson <alex.williamson@redhat.com> Acked-by: NMichael S. Tsirkin <mst@redhat.com>
-
由 Joerg Roedel 提交于
The vfio_device_get_from_name() function might return a non-NULL pointer, when called with a device name that is not found in the list. This causes undefined behavior, in my case calling an invalid function pointer later on: kernel tried to execute NX-protected page - exploit attempt? (uid: 0) BUG: unable to handle kernel paging request at ffff8800cb3ddc08 [...] Call Trace: [<ffffffffa03bd733>] ? vfio_group_fops_unl_ioctl+0x253/0x410 [vfio] [<ffffffff811efc4d>] do_vfs_ioctl+0x2cd/0x4c0 [<ffffffff811f9657>] ? __fget+0x77/0xb0 [<ffffffff811efeb9>] SyS_ioctl+0x79/0x90 [<ffffffff81001bb0>] ? syscall_return_slowpath+0x50/0x130 [<ffffffff8167f776>] entry_SYSCALL_64_fastpath+0x16/0x75 Fix the issue by returning NULL when there is no device with the requested name in the list. Cc: stable@vger.kernel.org # v4.2+ Fixes: 4bc94d5d ("vfio: Fix lockdep issue") Signed-off-by: NJoerg Roedel <jroedel@suse.de> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 04 11月, 2015 11 次提交
-
-
由 Eric Auger 提交于
This patch introduces a module that registers and implements a low-level reset function for the AMD XGBE device. it performs the following actions: - reset the PHY - disable auto-negotiation - disable & clear auto-negotiation IRQ - soft-reset the MAC Those tiny pieces of code are inherited from the native xgbe driver. Signed-off-by: NEric Auger <eric.auger@linaro.org> Reviewed-by: NArnd Bergmann <arnd@arndb.de> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
In the current code the vfio_platform_region is copied on the stack. As a consequence the ioaddr address is not iounmapped in the vfio platform driver (vfio_platform_regions_cleanup). The patch uses the pointer to the region instead. Signed-off-by: NEric Auger <eric.auger@linaro.org> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
It might be helpful for the end-user to check the device reset function was found by the vfio platform reset framework. Lets store a pointer to the struct device in vfio_platform_device and trace when the reset function is called or not found. Signed-off-by: NEric Auger <eric.auger@linaro.org> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
Remove the static lookup table and use the dynamic list of registered reset functions instead. Also load the reset module through its alias. The reset struct module pointer is stored in vfio_platform_device. We also remove the useless struct device pointer parameter in vfio_platform_get_reset. This patch fixes the issue related to the usage of __symbol_get, which besides from being moot, prevented compilation with CONFIG_MODULES disabled. Also usage of MODULE_ALIAS makes possible to add a new reset module without needing to update the framework. This was suggested by Arnd. Signed-off-by: NEric Auger <eric.auger@linaro.org> Reported-by: NArnd Bergmann <arnd@arndb.de> Reviewed-by: NArnd Bergmann <arnd@arndb.de> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
Let's retrieve the compatibility string on probe and store it in the vfio_platform_device struct Signed-off-by: NEric Auger <eric.auger@linaro.org> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
This patch adds the reset function registration/unregistration. This is handled through the module_vfio_reset_handler macro. This latter also defines a MODULE_ALIAS which simplifies the load from vfio-platform. Signed-off-by: NEric Auger <eric.auger@linaro.org> Reviewed-by: NArnd Bergmann <arnd@arndb.de> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
The module_vfio_reset_handler macro - define a module alias - implement module init/exit function which respectively registers and unregisters the reset function. Signed-off-by: NEric Auger <eric.auger@linaro.org> Reviewed-by: NArnd Bergmann <arnd@arndb.de> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
In preparation for subsequent changes in reset function lookup, lets introduce a dynamic list of reset combos (compat string, reset module, reset function). The list can be populated/voided with vfio_platform_register/unregister_reset. Those are not yet used in this patch. Signed-off-by: NEric Auger <eric.auger@linaro.org> Reviewed-by: NArnd Bergmann <arnd@arndb.de> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
To prepare for vfio platform reset rework let's build vfio_platform_common.c and vfio_platform_irq.c in a separate module from vfio-platform and vfio-amba. This makes possible to have separate module inits and works around a race between platform driver init and vfio reset module init: that way we make sure symbols exported by base are available when vfio-platform driver gets probed. The open/release being implemented in the base module, the ref count is applied to the parent module instead. Signed-off-by: NEric Auger <eric.auger@linaro.org> Suggested-by: NArnd Bergmann <arnd@arndb.de> Reviewed-by: NArnd Bergmann <arnd@arndb.de> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 James Morse 提交于
vfio_platform_{read,write}_mmio() call ioremap_nocache() to map a region of io memory, which they store in struct vfio_platform_region to be eventually re-used, or unmapped by vfio_platform_regions_cleanup(). These functions receive a copy of their struct vfio_platform_region argument on the stack - so these mapped areas are always allocated, and always leaked. Pass this argument as a pointer instead. Fixes: 6e3f2645 "vfio/platform: read and write support for the device fd" Signed-off-by: NJames Morse <james.morse@arm.com> Acked-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Tested-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
Current vfio_pgsize_bitmap code hides the supported IOMMU page sizes smaller than PAGE_SIZE. As a result, in case the IOMMU does not support PAGE_SIZE page, the alignment check on map/unmap is done with larger page sizes, if any. This can fail although mapping could be done with pages smaller than PAGE_SIZE. This patch modifies vfio_pgsize_bitmap implementation so that, in case the IOMMU supports page sizes smaller than PAGE_SIZE we pretend PAGE_SIZE is supported and hide sub-PAGE_SIZE sizes. That way the user will be able to map/unmap buffers whose size/ start address is aligned with PAGE_SIZE. Pinning code uses that granularity while iommu driver can use the sub-PAGE_SIZE size to map the buffer. Signed-off-by: NEric Auger <eric.auger@linaro.org> Acked-by: NWill Deacon <will.deacon@arm.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 28 10月, 2015 3 次提交
-
-
由 Eric Auger 提交于
The vfio platform driver currently sets the IRQ_NOAUTOEN before doing the request_irq to properly handle the user masking. However it does not clear it when de-assigning the IRQ. This brings issues when loading the native driver again which may not explicitly enable the IRQ. This problem was observed with xgbe driver. Signed-off-by: NEric Auger <eric.auger@linaro.org> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Alex Williamson 提交于
The PCI VPD capability operates on a set of window registers in PCI config space. Writing to the address register triggers either a read or write, depending on the setting of the PCI_VPD_ADDR_F bit within the address register. The data register provides either the source for writes or the target for reads. This model is susceptible to being broken by concurrent access, for which the kernel has adopted a set of access functions to serialize these registers. Additionally, commits like 932c435c ("PCI: Add dev_flags bit to access VPD through function 0") and 7aa6ca4d ("PCI: Add VPD function 0 quirk for Intel Ethernet devices") indicate that VPD registers can be shared between functions on multifunction devices creating dependencies between otherwise independent devices. Fortunately it's quite easy to emulate the VPD registers, simply storing copies of the address and data registers in memory and triggering a VPD read or write on writes to the address register. This allows vfio users to avoid seeing spurious register changes from accesses on other devices and enables the use of shared quirks in the host kernel. We can theoretically still race with access through sysfs, but the window of opportunity is much smaller. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com> Acked-by: NMark Rustad <mark.d.rustad@intel.com>
-
由 Alex Williamson 提交于
When determining whether a group is viable, we already allow devices bound to pcieport. Generalize this to include any PCI bridge device. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
- 01 10月, 2015 1 次提交
-
-
由 Feng Wu 提交于
This patch adds the registration/unregistration of an irq_bypass_producer for MSI/MSIx on vfio pci devices. Acked-by: NAlex Williamson <alex.williamson@redhat.com> Signed-off-by: NFeng Wu <feng.wu@intel.com> Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
-
- 25 7月, 2015 1 次提交
-
-
由 Alex Williamson 提交于
When we open a device file descriptor, we currently have the following: vfio_group_get_device_fd() mutex_lock(&group->device_lock); open() ... if (ret) release() If we hit that error case, we call the backend driver release path, which for vfio-pci looks like this: vfio_pci_release() vfio_pci_disable() vfio_pci_try_bus_reset() vfio_pci_get_devs() vfio_device_get_from_dev() vfio_group_get_device() mutex_lock(&group->device_lock); Whoops, we've stumbled back onto group.device_lock and created a deadlock. There's a low likelihood of ever seeing this play out, but obviously it needs to be fixed. To do that we can use a reference to the vfio_device for vfio_group_get_device_fd() rather than holding the lock. There was a loop in this function, theoretically allowing multiple devices with the same name, but in practice we don't expect such a thing to happen and the code is already aborting from the loop with break on any sort of error rather than continuing and only parsing the first match anyway, so the loop was effectively unused already. Signed-off-by: NAlex Williamson <alex.williamson@redhat.com> Fixes: 20f30017 ("vfio/pci: Fix racy vfio_device_get_from_dev() call") Reported-by: NJoerg Roedel <joro@8bytes.org> Tested-by: NJoerg Roedel <jroedel@suse.de>
-
- 22 6月, 2015 4 次提交
-
-
由 Eric Auger 提交于
This patch enables building VFIO platform and derivatives on ARM64. Signed-off-by: NEric Auger <eric.auger@linaro.org> Acked-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Tested-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
This patch introduces a module that registers and implements a basic reset function for the Calxeda xgmac device. This latter basically disables interrupts and stops DMA transfers. The reset function code is inherited from the native calxeda xgmac driver. Signed-off-by: NEric Auger <eric.auger@linaro.org> Acked-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Tested-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
The reset function lookup happens on vfio-platform probe. The reset module load is requested and a reference to the function symbol is hold. The reference is released on vfio-platform remove. Signed-off-by: NEric Auger <eric.auger@linaro.org> Acked-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Tested-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-
由 Eric Auger 提交于
A new reset callback is introduced. If this callback is populated, the reset is invoked on device first open/last close or upon userspace ioctl. The modality is exposed on VFIO_DEVICE_GET_INFO. Signed-off-by: NEric Auger <eric.auger@linaro.org> Acked-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Tested-by: NBaptiste Reynal <b.reynal@virtualopensystems.com> Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
-