@@ -861,15 +861,15 @@ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus,
861861 devfn += pdev -> phantom_stride ;
862862 if ( PCI_SLOT (devfn ) != PCI_SLOT (pdev -> devfn ) )
863863 break ;
864- ret = hd -> platform_ops -> reassign_device ( d , target , devfn ,
865- pci_to_dev (pdev ));
864+ ret = iommu_call ( hd -> platform_ops , reassign_device , d , target , devfn ,
865+ pci_to_dev (pdev ));
866866 if ( ret )
867867 goto out ;
868868 }
869869
870870 devfn = pdev -> devfn ;
871- ret = hd -> platform_ops -> reassign_device ( d , target , devfn ,
872- pci_to_dev (pdev ));
871+ ret = iommu_call ( hd -> platform_ops , reassign_device , d , target , devfn ,
872+ pci_to_dev (pdev ));
873873 if ( ret )
874874 goto out ;
875875
@@ -1300,7 +1300,7 @@ static int iommu_add_device(struct pci_dev *pdev)
13001300{
13011301 const struct domain_iommu * hd ;
13021302 int rc ;
1303- u8 devfn ;
1303+ unsigned int devfn = pdev -> devfn ;
13041304
13051305 if ( !pdev -> domain )
13061306 return - EINVAL ;
@@ -1311,16 +1311,16 @@ static int iommu_add_device(struct pci_dev *pdev)
13111311 if ( !is_iommu_enabled (pdev -> domain ) )
13121312 return 0 ;
13131313
1314- rc = hd -> platform_ops -> add_device ( pdev -> devfn , pci_to_dev (pdev ));
1314+ rc = iommu_call ( hd -> platform_ops , add_device , devfn , pci_to_dev (pdev ));
13151315 if ( rc || !pdev -> phantom_stride )
13161316 return rc ;
13171317
1318- for ( devfn = pdev -> devfn ; ; )
1318+ for ( ; ; )
13191319 {
13201320 devfn += pdev -> phantom_stride ;
13211321 if ( PCI_SLOT (devfn ) != PCI_SLOT (pdev -> devfn ) )
13221322 return 0 ;
1323- rc = hd -> platform_ops -> add_device ( devfn , pci_to_dev (pdev ));
1323+ rc = iommu_call ( hd -> platform_ops , add_device , devfn , pci_to_dev (pdev ));
13241324 if ( rc )
13251325 printk (XENLOG_WARNING "IOMMU: add %pp failed (%d)\n" ,
13261326 & pdev -> sbdf , rc );
@@ -1341,7 +1341,7 @@ static int iommu_enable_device(struct pci_dev *pdev)
13411341 !hd -> platform_ops -> enable_device )
13421342 return 0 ;
13431343
1344- return hd -> platform_ops -> enable_device ( pci_to_dev (pdev ));
1344+ return iommu_call ( hd -> platform_ops , enable_device , pci_to_dev (pdev ));
13451345}
13461346
13471347static int iommu_remove_device (struct pci_dev * pdev )
@@ -1363,15 +1363,18 @@ static int iommu_remove_device(struct pci_dev *pdev)
13631363 devfn += pdev -> phantom_stride ;
13641364 if ( PCI_SLOT (devfn ) != PCI_SLOT (pdev -> devfn ) )
13651365 break ;
1366- rc = hd -> platform_ops -> remove_device (devfn , pci_to_dev (pdev ));
1366+ rc = iommu_call (hd -> platform_ops , remove_device , devfn ,
1367+ pci_to_dev (pdev ));
13671368 if ( !rc )
13681369 continue ;
13691370
13701371 printk (XENLOG_ERR "IOMMU: remove %pp failed (%d)\n" , & pdev -> sbdf , rc );
13711372 return rc ;
13721373 }
13731374
1374- return hd -> platform_ops -> remove_device (pdev -> devfn , pci_to_dev (pdev ));
1375+ devfn = pdev -> devfn ;
1376+
1377+ return iommu_call (hd -> platform_ops , remove_device , devfn , pci_to_dev (pdev ));
13751378}
13761379
13771380static int device_assigned (u16 seg , u8 bus , u8 devfn )
@@ -1421,15 +1424,17 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
14211424
14221425 pdev -> fault .count = 0 ;
14231426
1424- if ( (rc = hd -> platform_ops -> assign_device (d , devfn , pci_to_dev (pdev ), flag )) )
1427+ if ( (rc = iommu_call (hd -> platform_ops , assign_device , d , devfn ,
1428+ pci_to_dev (pdev ), flag )) )
14251429 goto done ;
14261430
14271431 for ( ; pdev -> phantom_stride ; rc = 0 )
14281432 {
14291433 devfn += pdev -> phantom_stride ;
14301434 if ( PCI_SLOT (devfn ) != PCI_SLOT (pdev -> devfn ) )
14311435 break ;
1432- rc = hd -> platform_ops -> assign_device (d , devfn , pci_to_dev (pdev ), flag );
1436+ rc = iommu_call (hd -> platform_ops , assign_device , d , devfn ,
1437+ pci_to_dev (pdev ), flag );
14331438 }
14341439
14351440 done :
@@ -1457,24 +1462,24 @@ static int iommu_get_device_group(
14571462 if ( !is_iommu_enabled (d ) || !ops -> get_device_group_id )
14581463 return 0 ;
14591464
1460- group_id = ops -> get_device_group_id ( seg , bus , devfn );
1465+ group_id = iommu_call ( ops , get_device_group_id , seg , bus , devfn );
14611466
14621467 pcidevs_lock ();
14631468 for_each_pdev ( d , pdev )
14641469 {
1465- if ( (pdev -> seg != seg ) ||
1466- ((pdev -> bus == bus ) && (pdev -> devfn == devfn )) )
1470+ unsigned int b = pdev -> bus ;
1471+ unsigned int df = pdev -> devfn ;
1472+
1473+ if ( (pdev -> seg != seg ) || ((b == bus ) && (df == devfn )) )
14671474 continue ;
14681475
1469- if ( xsm_get_device_group (XSM_HOOK , (seg << 16 ) | (pdev -> bus << 8 ) | pdev -> devfn ) )
1476+ if ( xsm_get_device_group (XSM_HOOK , (seg << 16 ) | (b << 8 ) | df ) )
14701477 continue ;
14711478
1472- sdev_id = ops -> get_device_group_id ( seg , pdev -> bus , pdev -> devfn );
1479+ sdev_id = iommu_call ( ops , get_device_group_id , seg , b , df );
14731480 if ( (sdev_id == group_id ) && (i < max_sdevs ) )
14741481 {
1475- bdf = 0 ;
1476- bdf |= (pdev -> bus & 0xff ) << 16 ;
1477- bdf |= (pdev -> devfn & 0xff ) << 8 ;
1482+ bdf = (b << 16 ) | (df << 8 );
14781483
14791484 if ( unlikely (copy_to_guest_offset (buf , i , & bdf , 1 )) )
14801485 {
0 commit comments