PCI multi-seg: add new physdevop-s
PATCH 2/7 PCI multi-seg: add new physdevop-s
The new PHYSDEVOP_pci_device_add is intended to be extensible, with a first extension (to pass the proximity domain of a device) added right away.
A couple of directly related functions at once get adjusted to account for the segment number.
Should we deprecate the PHYSDEVOP_manage_pci_* sub-hypercalls?
xen/arch/ia64/xen/hypercall.c +3 -3
@@ -665,7 +665,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HAif (copy_from_guest (&manage_pci, arg,1 ) !=0 )break ; - ret =pci_add_device (manage_pci.bus, manage_pci.devfn,NULL ); + ret =pci_add_device (0 , manage_pci.bus, manage_pci.devfn,NULL );break ; }
@@ -678,7 +678,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HAif (copy_from_guest (&manage_pci, arg,1 ) !=0 )break ; - ret =pci_remove_device (manage_pci.bus, manage_pci.devfn); + ret =pci_remove_device (0 , manage_pci.bus, manage_pci.devfn);break ; }
@@ -698,7 +698,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HA pdev_info.is_virtfn = manage_pci_ext.is_virtfn; pdev_info.physfn.bus = manage_pci_ext.physfn.bus; pdev_info.physfn.devfn = manage_pci_ext.physfn.devfn; - ret =pci_add_device (manage_pci_ext.bus, + ret =pci_add_device (0 , manage_pci_ext.bus, manage_pci_ext.devfn, &pdev_info);break ;
xen/arch/x86/irq.c +1 -1
@@ -1715,7 +1715,7 @@ int map_domain_pirq(if ( !cpu_has_apic ) goto done; - pdev =pci_get_pdev (msi->bus, msi->devfn); + pdev =pci_get_pdev (msi->seg, msi->bus, msi->devfn); ret =pci_enable_msi (msi, &msi_desc);if ( ret ) goto done;
xen/arch/x86/msi.c +13 -9
@@ -528,7 +528,7 @@ static u64 read_pci_mem_bar(u8 bus, u8 sif ( vf >=0 ) { -struct pci_dev *pdev =pci_get_pdev (bus,PCI_DEVFN (slot, func)); +struct pci_dev *pdev =pci_get_pdev (0 , bus,PCI_DEVFN (slot, func));unsigned int pos =pci_find_ext_capability (0 , bus,PCI_DEVFN (slot, func),PCI_EXT_CAP_ID_SRIOV );
@@ -767,7 +767,7 @@ static int __pci_enable_msi(struct msi_istruct msi_desc *old_desc;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev (msi->bus, msi->devfn); + pdev =pci_get_pdev (msi->seg, msi->bus, msi->devfn);if ( !pdev )return -ENODEV ;
@@ -775,7 +775,8 @@ static int __pci_enable_msi(struct msi_iif ( old_desc ) {dprintk (XENLOG_WARNING ,"irq %d has already mapped to MSI on " -"device %02x:%02x.%01x.\n" , msi->irq, msi->bus, +"device %04x:%02x:%02x.%01x\n" , + msi->irq, msi->seg, msi->bus,PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn)); *desc = old_desc;return 0 ;
@@ -785,7 +786,7 @@ static int __pci_enable_msi(struct msi_iif ( old_desc ) {dprintk (XENLOG_WARNING ,"MSI-X is already in use on " -"device %02x:%02x.%01x\n" , msi->bus, +"device %04x:%02x:%02x.%01x\n" , msi->seg, msi->bus,PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn));pci_disable_msi (old_desc); }
@@ -830,7 +831,7 @@ static int __pci_enable_msix(struct msi_struct msi_desc *old_desc;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev (msi->bus, msi->devfn); + pdev =pci_get_pdev (msi->seg, msi->bus, msi->devfn);if ( !pdev )return -ENODEV ;
@@ -844,7 +845,8 @@ static int __pci_enable_msix(struct msi_if ( old_desc ) {dprintk (XENLOG_WARNING ,"irq %d has already mapped to MSIX on " -"device %02x:%02x.%01x.\n" , msi->irq, msi->bus, +"device %04x:%02x:%02x.%01x\n" , + msi->irq, msi->seg, msi->bus,PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn)); *desc = old_desc;return 0 ;
@@ -854,7 +856,7 @@ static int __pci_enable_msix(struct msi_if ( old_desc ) {dprintk (XENLOG_WARNING ,"MSI is already in use on " -"device %02x:%02x.%01x\n" , msi->bus, +"device %04x:%02x:%02x.%01x\n" , msi->seg, msi->bus,PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn));pci_disable_msi (old_desc);
@@ -962,8 +964,10 @@ int pci_restore_msi_state(struct pci_devif (desc->msi_desc != entry) { -dprintk (XENLOG_ERR ,"Restore MSI for dev %x:%x not set before?\n" , - pdev->bus, pdev->devfn); +dprintk (XENLOG_ERR , +"Restore MSI for dev %04x:%02x:%02x:%x not set before?\n" , + pdev->seg, pdev->bus,PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn));spin_unlock_irqrestore (&desc->lock, flags);return -EINVAL ; }
xen/arch/x86/physdev.c +73 -4
116 lines not on this page · raw message
xen/arch/x86/x86_64/physdev.c +8 -0
@@ -67,6 +67,14 @@ CHECK_physdev_get_free_pirq; CHECK_physdev_pci_mmcfg_reserved;#undef xen_physdev_pci_mmcfg_reserved +#define xen_physdev_pci_device_add physdev_pci_device_add +CHECK_physdev_pci_device_add +#undef xen_physdev_pci_device_add + +#define xen_physdev_pci_device physdev_pci_device +CHECK_physdev_pci_device +#undef xen_physdev_pci_device +#define COMPAT #undef guest_handle_okay#define guest_handle_okay compat_handle_okay
xen/drivers/passthrough/amd/pci_amd_iommu.c +2 -2
@@ -131,7 +131,7 @@ static void __init amd_iommu_setup_dom0_ {for ( devfn =0 ; devfn <256 ; devfn++ ) { - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if ( !pdev )continue ;
@@ -313,7 +313,7 @@ static int reassign_device( struct domaistruct hvm_iommu *t =domain_hvm_iommu (target);ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev_by_domain (source, bus, devfn); + pdev =pci_get_pdev_by_domain (source,0 , bus, devfn);if ( !pdev )return -ENODEV ;
xen/drivers/passthrough/iommu.c +1 -1
@@ -282,7 +282,7 @@ int deassign_device(struct domain *d, u8return -EINVAL ;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if ( !pdev )return -ENODEV ;
xen/drivers/passthrough/pci.c +66 -41
200 lines not on this page · raw message
xen/drivers/passthrough/vtd/iommu.c +9 -9
@@ -280,7 +280,7 @@ static u64 addr_to_dma_page_maddr(struct* just get any passthrough device in the domainr - assume user * assigns only devices from same node to a given guest. */ - pdev =pci_get_pdev_by_domain (domain,-1 ,-1 ); + pdev =pci_get_pdev_by_domain (domain,-1 ,-1 ,-1 ); drhd =acpi_find_matched_drhd_unit (pdev);if ( !alloc || ((hd->pgd_maddr =alloc_pgtable_maddr (drhd,1 )) ==0 ) ) goto out;
@@ -297,7 +297,7 @@ static u64 addr_to_dma_page_maddr(structif ( !alloc )break ; - pdev =pci_get_pdev_by_domain (domain,-1 ,-1 ); + pdev =pci_get_pdev_by_domain (domain,-1 ,-1 ,-1 ); drhd =acpi_find_matched_drhd_unit (pdev); maddr =alloc_pgtable_maddr (drhd,1 );if ( !maddr )
@@ -1273,7 +1273,7 @@ int domain_context_mapping_one(/* First try to get domain ownership from device structure. If that's * not available, try to read it from the context itself. */ - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if ( pdev ) {if ( pdev->domain != domain )
@@ -1396,7 +1396,7 @@ static int domain_context_mapping(structint ret =0 ;u32 type;u8 secbus; -struct pci_dev *pdev =pci_get_pdev (bus, devfn); +struct pci_dev *pdev =pci_get_pdev (0 , bus, devfn); drhd =acpi_find_matched_drhd_unit (pdev);if ( !drhd )
@@ -1521,7 +1521,7 @@ static int domain_context_unmap(struct dint ret =0 ;u32 type;u8 tmp_bus, tmp_devfn, secbus; -struct pci_dev *pdev =pci_get_pdev (bus, devfn); +struct pci_dev *pdev =pci_get_pdev (0 , bus, devfn);int found =0 ;BUG_ON (!pdev);
@@ -1632,7 +1632,7 @@ static int reassign_device_ownership(int ret;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev_by_domain (source, bus, devfn); + pdev =pci_get_pdev_by_domain (source,0 , bus, devfn);if (!pdev)return -ENODEV ;
@@ -1941,7 +1941,7 @@ static void __init setup_dom0_devices(st {for ( devfn =0 ; devfn <256 ; devfn++ ) { - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if ( !pdev )continue ;
@@ -2175,7 +2175,7 @@ int device_assigned(u8 bus, u8 devfn)struct pci_dev *pdev;spin_lock (&pcidevs_lock); - pdev =pci_get_pdev_by_domain (dom0, bus, devfn); + pdev =pci_get_pdev_by_domain (dom0,0 , bus, devfn);if (!pdev) {spin_unlock (&pcidevs_lock);
@@ -2197,7 +2197,7 @@ static int intel_iommu_assign_device(strreturn -ENODEV ;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if (!pdev)return -ENODEV ;
xen/drivers/passthrough/vtd/quirks.c +1 -1
@@ -286,7 +286,7 @@ static void map_me_phantom_function(strustruct pci_dev *pdev;/* find ME VT-d engine base on a real ME device */ - pdev =pci_get_pdev (0 ,PCI_DEVFN (dev,0 )); + pdev =pci_get_pdev (0 ,0 ,PCI_DEVFN (dev,0 )); drhd =acpi_find_matched_drhd_unit (pdev);/* map or unmap ME phantom function */
xen/drivers/passthrough/vtd/x86/ats.c +15 -9
@@ -37,6 +37,7 @@ static LIST_HEAD(ats_dev_drhd_units);struct pci_ats_dev {struct list_head list; +u16 seg;u8 bus;u8 devfn;u16 ats_queue_depth;/* ATS device invalidation queue depth */
@@ -91,7 +92,7 @@ int ats_device(int seg, int bus, int devif ( !ats_enabled || !iommu_qinval )return 0 ; - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (seg, bus, devfn);if ( !pdev )return 0 ;
@@ -130,8 +131,9 @@ int enable_ats_device(int seg, int bus,BUG_ON (!pos);if ( iommu_verbose ) - dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS capability found\n", - bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); + dprintk(XENLOG_INFO VTDPREFIX, +"%04x:%02x:%02x.%u: ATS capability found\n" , + seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn));/* BUGBUG: add back seg when multi-seg platform support is enabled */ value = pci_conf_read16(bus, PCI_SLOT(devfn),
@@ -140,7 +142,7 @@ int enable_ats_device(int seg, int bus, { list_for_each_entry ( pdev, &ats_devices, list ) { -if ( pdev->bus == bus && pdev->devfn == devfn ) +if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn ) { pos =0 ;break ;
@@ -161,6 +163,7 @@ int enable_ats_device(int seg, int bus,if ( pos ) { + pdev->seg = seg; pdev->bus = bus; pdev->devfn = devfn; value = pci_conf_read16(bus, PCI_SLOT(devfn),
@@ -170,8 +173,10 @@ int enable_ats_device(int seg, int bus, }if ( iommu_verbose ) - dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS %s enabled\n", - bus,PCI_SLOT (devfn),PCI_FUNC (devfn), pos ?"is" :"was" ); + dprintk(XENLOG_INFO VTDPREFIX, +"%04x:%02x:%02x.%u: ATS %s enabled\n" , + seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn), + pos ?"is" :"was" );return pos; }
@@ -194,7 +199,7 @@ void disable_ats_device(int seg, int bus list_for_each_entry ( pdev, &ats_devices, list ) { -if ( pdev->bus == bus && pdev->devfn == devfn ) +if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn ) {list_del (&pdev->list);xfree (pdev);
@@ -203,8 +208,9 @@ void disable_ats_device(int seg, int bus }if ( iommu_verbose ) - dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS is disabled\n", - bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); + dprintk(XENLOG_INFO VTDPREFIX, +"%04x:%02x:%02x.%u: ATS is disabled\n" , + seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); }
xen/include/asm-x86/msi.h +3 -2
@@ -59,8 +59,9 @@#endif struct msi_info { -int bus; -int devfn; +u16 seg; +u8 bus; +u8 devfn;int irq;int entry_nr;uint64_t table_base;
xen/include/public/physdev.h +37 -1
@@ -142,6 +142,7 @@ DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);#define MAP_PIRQ_TYPE_MSI 0x0#define MAP_PIRQ_TYPE_GSI 0x1#define MAP_PIRQ_TYPE_UNKNOWN 0x2 +#define MAP_PIRQ_TYPE_MSI_SEG 0x3#define PHYSDEVOP_map_pirq 13struct physdev_map_pirq {
@@ -152,7 +153,7 @@ struct physdev_map_pirq {int index;/* IN or OUT */ int pirq; -/* IN */ +/* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */ int bus;/* IN */ int devfn;
@@ -268,6 +269,41 @@ struct physdev_pci_mmcfg_reserved {typedef struct physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved_t ;DEFINE_XEN_GUEST_HANDLE (physdev_pci_mmcfg_reserved_t); +#define XEN_PCI_DEV_EXTFN 0x1 +#define XEN_PCI_DEV_VIRTFN 0x2 +#define XEN_PCI_DEV_PXM 0x4 + +#define PHYSDEVOP_pci_device_add 25 +struct physdev_pci_device_add { +/* IN */ +uint16_t seg; +uint8_t bus; +uint8_t devfn; +uint32_t flags; +struct { +uint8_t bus; +uint8_t devfn; + } physfn; +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >=199901L +uint32_t optarr[]; +#elif defined(__GNUC__) +uint32_t optarr[0 ]; +#endif +}; +typedef struct physdev_pci_device_add physdev_pci_device_add_t ; +DEFINE_XEN_GUEST_HANDLE (physdev_pci_device_add_t); + +#define PHYSDEVOP_pci_device_remove 26 +#define PHYSDEVOP_restore_msi_ext 27 +struct physdev_pci_device { +/* IN */ +uint16_t seg; +uint8_t bus; +uint8_t devfn; +}; +typedef struct physdev_pci_device physdev_pci_device_t ; +DEFINE_XEN_GUEST_HANDLE (physdev_pci_device_t); +/* * Notify that some PIRQ-bound event channels have been unmasked. * ** This command is obsolete since interface version 0x00030202 and is **
xen/include/xen/pci.h +6 -4
@@ -56,6 +56,7 @@ struct pci_dev {spinlock_t msix_table_lock;struct domain *domain; +const u16 seg;const u8 bus;const u8 devfn;struct pci_dev_info info;
@@ -90,10 +91,11 @@ struct pci_dev *pci_lock_domain_pdev(strvoid pci_release_devices (struct domain *d);int pci_add_segment (u16 seg); -int pci_add_device (u8 bus,u8 devfn,const struct pci_dev_info *); -int pci_remove_device (u8 bus,u8 devfn); -struct pci_dev *pci_get_pdev (int bus,int devfn); -struct pci_dev *pci_get_pdev_by_domain (struct domain *d,int bus,int devfn); +int pci_add_device (u16 seg,u8 bus,u8 devfn,const struct pci_dev_info *); +int pci_remove_device (u16 seg,u8 bus,u8 devfn); +struct pci_dev *pci_get_pdev (int seg,int bus,int devfn); +struct pci_dev *pci_get_pdev_by_domain ( +struct domain *,int seg,int bus,int devfn);void disconnect_pci_devices (void );
xen/include/xlat.lst +2 -0
@@ -65,6 +65,8 @@ ? physdev_irq_status_query physdev.h ? physdev_manage_pci physdev.h ? physdev_manage_pci_ext physdev.h +? physdev_pci_device physdev.h +? physdev_pci_device_add physdev.h ? physdev_pci_mmcfg_reserved physdev.h ? physdev_unmap_pirq physdev.h ? physdev_restore_msi physdev.h
The new PHYSDEVOP_pci_device_add is intended to be extensible, with a first extension (to pass the proximity domain of a device) added right away.
A couple of directly related functions at once get adjusted to account for the segment number.
Should we deprecate the PHYSDEVOP_manage_pci_* sub-hypercalls?
xen/arch/ia64/xen/hypercall.c +3 -3
@@ -665,7 +665,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HAif (copy_from_guest (&manage_pci, arg,1 ) !=0 )break ; - ret =pci_add_device (manage_pci.bus, manage_pci.devfn,NULL ); + ret =pci_add_device (0 , manage_pci.bus, manage_pci.devfn,NULL );break ; }
@@ -678,7 +678,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HAif (copy_from_guest (&manage_pci, arg,1 ) !=0 )break ; - ret =pci_remove_device (manage_pci.bus, manage_pci.devfn); + ret =pci_remove_device (0 , manage_pci.bus, manage_pci.devfn);break ; }
@@ -698,7 +698,7 @@ long do_physdev_op(int cmd, XEN_GUEST_HA pdev_info.is_virtfn = manage_pci_ext.is_virtfn; pdev_info.physfn.bus = manage_pci_ext.physfn.bus; pdev_info.physfn.devfn = manage_pci_ext.physfn.devfn; - ret =pci_add_device (manage_pci_ext.bus, + ret =pci_add_device (0 , manage_pci_ext.bus, manage_pci_ext.devfn, &pdev_info);break ;
xen/arch/x86/irq.c +1 -1
@@ -1715,7 +1715,7 @@ int map_domain_pirq(if ( !cpu_has_apic ) goto done; - pdev =pci_get_pdev (msi->bus, msi->devfn); + pdev =pci_get_pdev (msi->seg, msi->bus, msi->devfn); ret =pci_enable_msi (msi, &msi_desc);if ( ret ) goto done;
xen/arch/x86/msi.c +13 -9
@@ -528,7 +528,7 @@ static u64 read_pci_mem_bar(u8 bus, u8 sif ( vf >=0 ) { -struct pci_dev *pdev =pci_get_pdev (bus,PCI_DEVFN (slot, func)); +struct pci_dev *pdev =pci_get_pdev (0 , bus,PCI_DEVFN (slot, func));unsigned int pos =pci_find_ext_capability (0 , bus,PCI_DEVFN (slot, func),PCI_EXT_CAP_ID_SRIOV );
@@ -767,7 +767,7 @@ static int __pci_enable_msi(struct msi_istruct msi_desc *old_desc;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev (msi->bus, msi->devfn); + pdev =pci_get_pdev (msi->seg, msi->bus, msi->devfn);if ( !pdev )return -ENODEV ;
@@ -775,7 +775,8 @@ static int __pci_enable_msi(struct msi_iif ( old_desc ) {dprintk (XENLOG_WARNING ,"irq %d has already mapped to MSI on " -"device %02x:%02x.%01x.\n" , msi->irq, msi->bus, +"device %04x:%02x:%02x.%01x\n" , + msi->irq, msi->seg, msi->bus,PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn)); *desc = old_desc;return 0 ;
@@ -785,7 +786,7 @@ static int __pci_enable_msi(struct msi_iif ( old_desc ) {dprintk (XENLOG_WARNING ,"MSI-X is already in use on " -"device %02x:%02x.%01x\n" , msi->bus, +"device %04x:%02x:%02x.%01x\n" , msi->seg, msi->bus,PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn));pci_disable_msi (old_desc); }
@@ -830,7 +831,7 @@ static int __pci_enable_msix(struct msi_struct msi_desc *old_desc;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev (msi->bus, msi->devfn); + pdev =pci_get_pdev (msi->seg, msi->bus, msi->devfn);if ( !pdev )return -ENODEV ;
@@ -844,7 +845,8 @@ static int __pci_enable_msix(struct msi_if ( old_desc ) {dprintk (XENLOG_WARNING ,"irq %d has already mapped to MSIX on " -"device %02x:%02x.%01x.\n" , msi->irq, msi->bus, +"device %04x:%02x:%02x.%01x\n" , + msi->irq, msi->seg, msi->bus,PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn)); *desc = old_desc;return 0 ;
@@ -854,7 +856,7 @@ static int __pci_enable_msix(struct msi_if ( old_desc ) {dprintk (XENLOG_WARNING ,"MSI is already in use on " -"device %02x:%02x.%01x\n" , msi->bus, +"device %04x:%02x:%02x.%01x\n" , msi->seg, msi->bus,PCI_SLOT (msi->devfn),PCI_FUNC (msi->devfn));pci_disable_msi (old_desc);
@@ -962,8 +964,10 @@ int pci_restore_msi_state(struct pci_devif (desc->msi_desc != entry) { -dprintk (XENLOG_ERR ,"Restore MSI for dev %x:%x not set before?\n" , - pdev->bus, pdev->devfn); +dprintk (XENLOG_ERR , +"Restore MSI for dev %04x:%02x:%02x:%x not set before?\n" , + pdev->seg, pdev->bus,PCI_SLOT (pdev->devfn), +PCI_FUNC (pdev->devfn));spin_unlock_irqrestore (&desc->lock, flags);return -EINVAL ; }
xen/arch/x86/physdev.c +73 -4
116 lines not on this page · raw message
xen/arch/x86/x86_64/physdev.c +8 -0
@@ -67,6 +67,14 @@ CHECK_physdev_get_free_pirq; CHECK_physdev_pci_mmcfg_reserved;#undef xen_physdev_pci_mmcfg_reserved +#define xen_physdev_pci_device_add physdev_pci_device_add +CHECK_physdev_pci_device_add +#undef xen_physdev_pci_device_add + +#define xen_physdev_pci_device physdev_pci_device +CHECK_physdev_pci_device +#undef xen_physdev_pci_device +#define COMPAT #undef guest_handle_okay#define guest_handle_okay compat_handle_okay
xen/drivers/passthrough/amd/pci_amd_iommu.c +2 -2
@@ -131,7 +131,7 @@ static void __init amd_iommu_setup_dom0_ {for ( devfn =0 ; devfn <256 ; devfn++ ) { - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if ( !pdev )continue ;
@@ -313,7 +313,7 @@ static int reassign_device( struct domaistruct hvm_iommu *t =domain_hvm_iommu (target);ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev_by_domain (source, bus, devfn); + pdev =pci_get_pdev_by_domain (source,0 , bus, devfn);if ( !pdev )return -ENODEV ;
xen/drivers/passthrough/iommu.c +1 -1
@@ -282,7 +282,7 @@ int deassign_device(struct domain *d, u8return -EINVAL ;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if ( !pdev )return -ENODEV ;
xen/drivers/passthrough/pci.c +66 -41
200 lines not on this page · raw message
xen/drivers/passthrough/vtd/iommu.c +9 -9
@@ -280,7 +280,7 @@ static u64 addr_to_dma_page_maddr(struct* just get any passthrough device in the domainr - assume user * assigns only devices from same node to a given guest. */ - pdev =pci_get_pdev_by_domain (domain,-1 ,-1 ); + pdev =pci_get_pdev_by_domain (domain,-1 ,-1 ,-1 ); drhd =acpi_find_matched_drhd_unit (pdev);if ( !alloc || ((hd->pgd_maddr =alloc_pgtable_maddr (drhd,1 )) ==0 ) ) goto out;
@@ -297,7 +297,7 @@ static u64 addr_to_dma_page_maddr(structif ( !alloc )break ; - pdev =pci_get_pdev_by_domain (domain,-1 ,-1 ); + pdev =pci_get_pdev_by_domain (domain,-1 ,-1 ,-1 ); drhd =acpi_find_matched_drhd_unit (pdev); maddr =alloc_pgtable_maddr (drhd,1 );if ( !maddr )
@@ -1273,7 +1273,7 @@ int domain_context_mapping_one(/* First try to get domain ownership from device structure. If that's * not available, try to read it from the context itself. */ - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if ( pdev ) {if ( pdev->domain != domain )
@@ -1396,7 +1396,7 @@ static int domain_context_mapping(structint ret =0 ;u32 type;u8 secbus; -struct pci_dev *pdev =pci_get_pdev (bus, devfn); +struct pci_dev *pdev =pci_get_pdev (0 , bus, devfn); drhd =acpi_find_matched_drhd_unit (pdev);if ( !drhd )
@@ -1521,7 +1521,7 @@ static int domain_context_unmap(struct dint ret =0 ;u32 type;u8 tmp_bus, tmp_devfn, secbus; -struct pci_dev *pdev =pci_get_pdev (bus, devfn); +struct pci_dev *pdev =pci_get_pdev (0 , bus, devfn);int found =0 ;BUG_ON (!pdev);
@@ -1632,7 +1632,7 @@ static int reassign_device_ownership(int ret;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev_by_domain (source, bus, devfn); + pdev =pci_get_pdev_by_domain (source,0 , bus, devfn);if (!pdev)return -ENODEV ;
@@ -1941,7 +1941,7 @@ static void __init setup_dom0_devices(st {for ( devfn =0 ; devfn <256 ; devfn++ ) { - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if ( !pdev )continue ;
@@ -2175,7 +2175,7 @@ int device_assigned(u8 bus, u8 devfn)struct pci_dev *pdev;spin_lock (&pcidevs_lock); - pdev =pci_get_pdev_by_domain (dom0, bus, devfn); + pdev =pci_get_pdev_by_domain (dom0,0 , bus, devfn);if (!pdev) {spin_unlock (&pcidevs_lock);
@@ -2197,7 +2197,7 @@ static int intel_iommu_assign_device(strreturn -ENODEV ;ASSERT (spin_is_locked (&pcidevs_lock)); - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (0 , bus, devfn);if (!pdev)return -ENODEV ;
xen/drivers/passthrough/vtd/quirks.c +1 -1
@@ -286,7 +286,7 @@ static void map_me_phantom_function(strustruct pci_dev *pdev;/* find ME VT-d engine base on a real ME device */ - pdev =pci_get_pdev (0 ,PCI_DEVFN (dev,0 )); + pdev =pci_get_pdev (0 ,0 ,PCI_DEVFN (dev,0 )); drhd =acpi_find_matched_drhd_unit (pdev);/* map or unmap ME phantom function */
xen/drivers/passthrough/vtd/x86/ats.c +15 -9
@@ -37,6 +37,7 @@ static LIST_HEAD(ats_dev_drhd_units);struct pci_ats_dev {struct list_head list; +u16 seg;u8 bus;u8 devfn;u16 ats_queue_depth;/* ATS device invalidation queue depth */
@@ -91,7 +92,7 @@ int ats_device(int seg, int bus, int devif ( !ats_enabled || !iommu_qinval )return 0 ; - pdev =pci_get_pdev (bus, devfn); + pdev =pci_get_pdev (seg, bus, devfn);if ( !pdev )return 0 ;
@@ -130,8 +131,9 @@ int enable_ats_device(int seg, int bus,BUG_ON (!pos);if ( iommu_verbose ) - dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS capability found\n", - bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); + dprintk(XENLOG_INFO VTDPREFIX, +"%04x:%02x:%02x.%u: ATS capability found\n" , + seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn));/* BUGBUG: add back seg when multi-seg platform support is enabled */ value = pci_conf_read16(bus, PCI_SLOT(devfn),
@@ -140,7 +142,7 @@ int enable_ats_device(int seg, int bus, { list_for_each_entry ( pdev, &ats_devices, list ) { -if ( pdev->bus == bus && pdev->devfn == devfn ) +if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn ) { pos =0 ;break ;
@@ -161,6 +163,7 @@ int enable_ats_device(int seg, int bus,if ( pos ) { + pdev->seg = seg; pdev->bus = bus; pdev->devfn = devfn; value = pci_conf_read16(bus, PCI_SLOT(devfn),
@@ -170,8 +173,10 @@ int enable_ats_device(int seg, int bus, }if ( iommu_verbose ) - dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS %s enabled\n", - bus,PCI_SLOT (devfn),PCI_FUNC (devfn), pos ?"is" :"was" ); + dprintk(XENLOG_INFO VTDPREFIX, +"%04x:%02x:%02x.%u: ATS %s enabled\n" , + seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn), + pos ?"is" :"was" );return pos; }
@@ -194,7 +199,7 @@ void disable_ats_device(int seg, int bus list_for_each_entry ( pdev, &ats_devices, list ) { -if ( pdev->bus == bus && pdev->devfn == devfn ) +if ( pdev->seg == seg && pdev->bus == bus && pdev->devfn == devfn ) {list_del (&pdev->list);xfree (pdev);
@@ -203,8 +208,9 @@ void disable_ats_device(int seg, int bus }if ( iommu_verbose ) - dprintk(XENLOG_INFO VTDPREFIX, "%x:%x.%x: ATS is disabled\n", - bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); + dprintk(XENLOG_INFO VTDPREFIX, +"%04x:%02x:%02x.%u: ATS is disabled\n" , + seg, bus,PCI_SLOT (devfn),PCI_FUNC (devfn)); }
xen/include/asm-x86/msi.h +3 -2
@@ -59,8 +59,9 @@#endif struct msi_info { -int bus; -int devfn; +u16 seg; +u8 bus; +u8 devfn;int irq;int entry_nr;uint64_t table_base;
xen/include/public/physdev.h +37 -1
@@ -142,6 +142,7 @@ DEFINE_XEN_GUEST_HANDLE(physdev_irq_t);#define MAP_PIRQ_TYPE_MSI 0x0#define MAP_PIRQ_TYPE_GSI 0x1#define MAP_PIRQ_TYPE_UNKNOWN 0x2 +#define MAP_PIRQ_TYPE_MSI_SEG 0x3#define PHYSDEVOP_map_pirq 13struct physdev_map_pirq {
@@ -152,7 +153,7 @@ struct physdev_map_pirq {int index;/* IN or OUT */ int pirq; -/* IN */ +/* IN - high 16 bits hold segment for MAP_PIRQ_TYPE_MSI_SEG */ int bus;/* IN */ int devfn;
@@ -268,6 +269,41 @@ struct physdev_pci_mmcfg_reserved {typedef struct physdev_pci_mmcfg_reserved physdev_pci_mmcfg_reserved_t ;DEFINE_XEN_GUEST_HANDLE (physdev_pci_mmcfg_reserved_t); +#define XEN_PCI_DEV_EXTFN 0x1 +#define XEN_PCI_DEV_VIRTFN 0x2 +#define XEN_PCI_DEV_PXM 0x4 + +#define PHYSDEVOP_pci_device_add 25 +struct physdev_pci_device_add { +/* IN */ +uint16_t seg; +uint8_t bus; +uint8_t devfn; +uint32_t flags; +struct { +uint8_t bus; +uint8_t devfn; + } physfn; +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >=199901L +uint32_t optarr[]; +#elif defined(__GNUC__) +uint32_t optarr[0 ]; +#endif +}; +typedef struct physdev_pci_device_add physdev_pci_device_add_t ; +DEFINE_XEN_GUEST_HANDLE (physdev_pci_device_add_t); + +#define PHYSDEVOP_pci_device_remove 26 +#define PHYSDEVOP_restore_msi_ext 27 +struct physdev_pci_device { +/* IN */ +uint16_t seg; +uint8_t bus; +uint8_t devfn; +}; +typedef struct physdev_pci_device physdev_pci_device_t ; +DEFINE_XEN_GUEST_HANDLE (physdev_pci_device_t); +/* * Notify that some PIRQ-bound event channels have been unmasked. * ** This command is obsolete since interface version 0x00030202 and is **
xen/include/xen/pci.h +6 -4
@@ -56,6 +56,7 @@ struct pci_dev {spinlock_t msix_table_lock;struct domain *domain; +const u16 seg;const u8 bus;const u8 devfn;struct pci_dev_info info;
@@ -90,10 +91,11 @@ struct pci_dev *pci_lock_domain_pdev(strvoid pci_release_devices (struct domain *d);int pci_add_segment (u16 seg); -int pci_add_device (u8 bus,u8 devfn,const struct pci_dev_info *); -int pci_remove_device (u8 bus,u8 devfn); -struct pci_dev *pci_get_pdev (int bus,int devfn); -struct pci_dev *pci_get_pdev_by_domain (struct domain *d,int bus,int devfn); +int pci_add_device (u16 seg,u8 bus,u8 devfn,const struct pci_dev_info *); +int pci_remove_device (u16 seg,u8 bus,u8 devfn); +struct pci_dev *pci_get_pdev (int seg,int bus,int devfn); +struct pci_dev *pci_get_pdev_by_domain ( +struct domain *,int seg,int bus,int devfn);void disconnect_pci_devices (void );
xen/include/xlat.lst +2 -0
@@ -65,6 +65,8 @@ ? physdev_irq_status_query physdev.h ? physdev_manage_pci physdev.h ? physdev_manage_pci_ext physdev.h +? physdev_pci_device physdev.h +? physdev_pci_device_add physdev.h ? physdev_pci_mmcfg_reserved physdev.h ? physdev_unmap_pirq physdev.h ? physdev_restore_msi physdev.h
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel