Re: [RFC PATCH v3 3/5] PCI: Add host bridge attribute to indicate filtering of MSIs is supported

From: Alex Williamson
Date: Thu Jan 28 2016 - 17:46:37 EST


On Fri, 2016-01-15 at 15:06 +0800, Yongji Xie wrote:
> MSI-X tables are not allowed to be mmapped in vfio-pci
> driver in case that user get to touch this directly.
> This will cause some performance issues when when PCI
> adapters have critical registers in the same page as
> the MSI-X table.
>Â
> However, some kind of PCI host bridge such as IODA bridge
> on Power support filtering of MSIs, which can ensure that a
> given pci device can only shoot the MSIs assigned for it.
> So we think it's safe to expose the MSI-X table to userspace
> if filtering of MSIs is supported because the exposed MSI-X
> table can't be used to do harm to other memory space.
>Â
> To support this case, this patch adds a pci_host_bridge
> attribute to indicate if this PCI host bridge supports
> filtering of MSIs.
>Â
> Signed-off-by: Yongji Xie <xyjxie@xxxxxxxxxxxxxxxxxx>
> ---
> Âdrivers/pci/host-bridge.c |ÂÂÂÂ6 ++++++
> Âinclude/linux/pci.hÂÂÂÂÂÂÂ|ÂÂÂÂ3 +++
> Â2 files changed, 9 insertions(+)
>Â
> diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
> index 5f4a2e0..c029267 100644
> --- a/drivers/pci/host-bridge.c
> +++ b/drivers/pci/host-bridge.c
> @@ -96,3 +96,9 @@ void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
> Â res->end = region->end + offset;
> Â}
> ÂEXPORT_SYMBOL(pcibios_bus_to_resource);
> +
> +bool pci_host_bridge_msi_filtered_enabled(struct pci_dev *pdev)
> +{
> + return pci_find_host_bridge(pdev->bus)->msi_filtered;
> +}
> +EXPORT_SYMBOL_GPL(pci_host_bridge_msi_filtered_enabled);
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index b640d65..b952b78 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -412,6 +412,7 @@ struct pci_host_bridge {
> Â void (*release_fn)(struct pci_host_bridge *);
> Â void *release_data;
> Â unsigned int ignore_reset_delay:1; /* for entire hierarchy */
> + unsigned int msi_filtered:1; /* support filtering of MSIs */
> Â /* Resource alignment requirements */
> Â resource_size_t (*align_resource)(struct pci_dev *dev,
> Â const struct resource *res,
> @@ -430,6 +431,8 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
> Â
> Âint pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
> Â
> +bool pci_host_bridge_msi_filtered_enabled(struct pci_dev *pdev);
> +
> Â/*
> Â * The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
> Â * to P2P or CardBus bridge windows) go in a table.ÂÂAdditional ones (for

Don't we already have a flag for this in the IOMMU space?

enum iommu_cap {
ÂÂÂÂÂÂÂÂIOMMU_CAP_CACHE_COHERENCY,ÂÂÂÂÂÂ/* IOMMU can enforce cache coherent DMA
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂtransactions */
--->ÂÂÂÂIOMMU_CAP_INTR_REMAP,ÂÂÂÂÂÂÂÂÂÂÂ/* IOMMU supports interrupt isolation */
ÂÂÂÂÂÂÂÂIOMMU_CAP_NOEXEC,ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ/* IOMMU_NOEXEC flag */
};