[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH for-4.15 1/4] xen/iommu: Check if the IOMMU was initialized before tearing down
On 22.12.2020 16:43, Julien Grall wrote: > --- a/xen/drivers/passthrough/iommu.c > +++ b/xen/drivers/passthrough/iommu.c > @@ -226,7 +226,15 @@ static void iommu_teardown(struct domain *d) > > void iommu_domain_destroy(struct domain *d) > { > - if ( !is_iommu_enabled(d) ) > + struct domain_iommu *hd = dom_iommu(d); > + > + /* > + * In case of failure during the domain construction, it would be > + * possible to reach this function with the IOMMU enabled but not > + * yet initialized. We assume that hd->platforms will be non-NULL as > + * soon as we start to initialize the IOMMU. > + */ > + if ( !is_iommu_enabled(d) || !hd->platform_ops ) > return; >From your description I'd rather say is_iommu_enabled() is the wrong predicate to use here. IOW I'd rather see it be replaced. A couple of additional nits: "hd" isn't really necessary to have as a local variable, but if you insist on introducing it despite being used just once, it should be pointer-to-const. Plus the comment would better spell correctly the field it talks about. But I consider this comment excessive anyway, as the check of ->platform_ops is quite clear by itself. And finally "we assume" is in at least latent conflict with ->platform_ops getting set only after arch_iommu_domain_init() was called. Right now neither x86'es nor Arm's do anything that would need undoing, but I'd still suggest to replace "assume" here (if you want to keep the comment in the first place) and move the assignment up a few lines (right after the is_iommu_enabled() check there). Jan
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |