[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH ats_vtd v5 10/22] pci: add IOMMU operations to get address spaces
From: |
CLEMENT MATHIEU--DRIF |
Subject: |
[PATCH ats_vtd v5 10/22] pci: add IOMMU operations to get address spaces and memory regions with PASID |
Date: |
Tue, 2 Jul 2024 05:52:38 +0000 |
From: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
Signed-off-by: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
---
hw/pci/pci.c | 19 +++++++++++++++++++
include/hw/pci/pci.h | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 51feede3cf..3fe47d4002 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -2747,6 +2747,25 @@ AddressSpace *pci_device_iommu_address_space(PCIDevice
*dev)
return &address_space_memory;
}
+AddressSpace *pci_device_iommu_address_space_pasid(PCIDevice *dev,
+ uint32_t pasid)
+{
+ PCIBus *bus;
+ PCIBus *iommu_bus;
+ int devfn;
+
+ if (!dev->is_master || !pcie_pasid_enabled(dev) || pasid == PCI_NO_PASID) {
+ return NULL;
+ }
+
+ pci_device_get_iommu_bus_devfn(dev, &bus, &iommu_bus, &devfn);
+ if (iommu_bus && iommu_bus->iommu_ops->get_address_space_pasid) {
+ return iommu_bus->iommu_ops->get_address_space_pasid(bus,
+ iommu_bus->iommu_opaque, devfn, pasid);
+ }
+ return NULL;
+}
+
bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod,
Error **errp)
{
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index eb26cac810..ad7bd2ade5 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -385,6 +385,38 @@ typedef struct PCIIOMMUOps {
* @devfn: device and function number
*/
AddressSpace * (*get_address_space)(PCIBus *bus, void *opaque, int devfn);
+ /**
+ * @get_address_space_pasid: same as get_address_space but returns an
+ * address space with the requested PASID
+ *
+ * This callback is required for PASID-based operations
+ *
+ * @bus: the #PCIBus being accessed.
+ *
+ * @opaque: the data passed to pci_setup_iommu().
+ *
+ * @devfn: device and function number
+ *
+ * @pasid: the pasid associated with the requested memory region
+ */
+ AddressSpace * (*get_address_space_pasid)(PCIBus *bus, void *opaque,
+ int devfn, uint32_t pasid);
+ /**
+ * @get_memory_region_pasid: get the iommu memory region for a given
+ * device and pasid
+ *
+ * @bus: the #PCIBus being accessed.
+ *
+ * @opaque: the data passed to pci_setup_iommu().
+ *
+ * @devfn: device and function number
+ *
+ * @pasid: the pasid associated with the requested memory region
+ */
+ IOMMUMemoryRegion * (*get_memory_region_pasid)(PCIBus *bus,
+ void *opaque,
+ int devfn,
+ uint32_t pasid);
/**
* @set_iommu_device: attach a HostIOMMUDevice to a vIOMMU
*
@@ -420,6 +452,8 @@ typedef struct PCIIOMMUOps {
} PCIIOMMUOps;
AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
+AddressSpace *pci_device_iommu_address_space_pasid(PCIDevice *dev,
+ uint32_t pasid);
bool pci_device_set_iommu_device(PCIDevice *dev, HostIOMMUDevice *hiod,
Error **errp);
void pci_device_unset_iommu_device(PCIDevice *dev);
--
2.45.2
- Re: [PATCH ats_vtd v5 04/22] intel_iommu: do not consider wait_desc as an invalid descriptor, (continued)
- [PATCH ats_vtd v5 09/22] pci: cache the bus mastering status in the device, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 05/22] memory: add permissions in IOMMUAccessFlags, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 15/22] memory: Allow to store the PASID in IOMMUTLBEntry, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 16/22] intel_iommu: fill the PASID field when creating an instance of IOMMUTLBEntry, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 14/22] intel_iommu: implement the get_memory_region_pasid iommu operation, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 10/22] pci: add IOMMU operations to get address spaces and memory regions with PASID,
CLEMENT MATHIEU--DRIF <=
- [PATCH ats_vtd v5 12/22] pci: add a pci-level initialization function for iommu notifiers, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 11/22] memory: store user data pointer in the IOMMU notifiers, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 17/22] atc: generic ATC that can be used by PCIe devices that support SVM, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 02/22] intel_iommu: make types match, CLEMENT MATHIEU--DRIF, 2024/07/02
- [PATCH ats_vtd v5 20/22] pci: add a pci-level API for ATS, CLEMENT MATHIEU--DRIF, 2024/07/02