|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] VT-d/ATS: tidy device_in_domain()
commit fa8f9792befc6ca4982d191b8b1e32f70087ee9d
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Sep 5 10:02:11 2019 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Sep 5 10:02:11 2019 +0200
VT-d/ATS: tidy device_in_domain()
Use appropriate types. Drop unnecessary casts. Check for failures which
can (at least in theory because of non-obvious breakage elsewhere)
occur, instead of ones which really can't (map_domain_page() won't
return NULL).
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
---
xen/drivers/passthrough/vtd/x86/ats.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/xen/drivers/passthrough/vtd/x86/ats.c
b/xen/drivers/passthrough/vtd/x86/ats.c
index 1a3adb4acb..59722a751e 100644
--- a/xen/drivers/passthrough/vtd/x86/ats.c
+++ b/xen/drivers/passthrough/vtd/x86/ats.c
@@ -71,23 +71,25 @@ int ats_device(const struct pci_dev *pdev, const struct
acpi_drhd_unit *drhd)
return pos;
}
-static int device_in_domain(const struct iommu *iommu,
- const struct pci_dev *pdev, u16 did)
+static bool device_in_domain(const struct iommu *iommu,
+ const struct pci_dev *pdev, uint16_t did)
{
- struct root_entry *root_entry = NULL;
+ struct root_entry *root_entry;
struct context_entry *ctxt_entry = NULL;
- int tt, found = 0;
+ unsigned int tt;
+ bool found = false;
- root_entry = (struct root_entry *) map_vtd_domain_page(iommu->root_maddr);
- if ( !root_entry || !root_present(root_entry[pdev->bus]) )
- goto out;
-
- ctxt_entry = (struct context_entry *)
- map_vtd_domain_page(root_entry[pdev->bus].val);
+ if ( unlikely(!iommu->root_maddr) )
+ {
+ ASSERT_UNREACHABLE();
+ return false;
+ }
- if ( ctxt_entry == NULL )
+ root_entry = map_vtd_domain_page(iommu->root_maddr);
+ if ( !root_present(root_entry[pdev->bus]) )
goto out;
+ ctxt_entry = map_vtd_domain_page(root_entry[pdev->bus].val);
if ( context_domain_id(ctxt_entry[pdev->devfn]) != did )
goto out;
@@ -95,7 +97,7 @@ static int device_in_domain(const struct iommu *iommu,
if ( tt != CONTEXT_TT_DEV_IOTLB )
goto out;
- found = 1;
+ found = true;
out:
if ( root_entry )
unmap_vtd_domain_page(root_entry);
--
generated by git-patchbot for /home/xen/git/xen.git#staging
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |