git: da33f6d76b9d - main - iommu_gas: Tidy up
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 26 Jun 2022 06:02:54 UTC
The branch main has been updated by alc: URL: https://cgit.FreeBSD.org/src/commit/?id=da33f6d76b9d0c00649c692f6cb2b3b33bf5af30 commit da33f6d76b9d0c00649c692f6cb2b3b33bf5af30 Author: Alan Cox <alc@FreeBSD.org> AuthorDate: 2022-06-26 05:44:47 +0000 Commit: Alan Cox <alc@FreeBSD.org> CommitDate: 2022-06-26 06:01:49 +0000 iommu_gas: Tidy up Move a comment to the code that it describes. Improve the wording. Style fixes. MFC after: 2 weeks --- sys/dev/iommu/iommu_gas.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c index a9c4caa30dd8..2647c2ce6612 100644 --- a/sys/dev/iommu/iommu_gas.c +++ b/sys/dev/iommu/iommu_gas.c @@ -197,8 +197,7 @@ iommu_gas_rb_insert(struct iommu_domain *domain, struct iommu_map_entry *entry) { struct iommu_map_entry *found; - found = RB_INSERT(iommu_gas_entries_tree, - &domain->rb_root, entry); + found = RB_INSERT(iommu_gas_entries_tree, &domain->rb_root, entry); return (found == NULL); } @@ -303,6 +302,13 @@ iommu_gas_match_one(struct iommu_gas_match_args *a, iommu_gaddr_t beg, { iommu_gaddr_t bs, start; + /* + * The prev->end is always aligned on the page size, which + * causes page alignment for the entry->start too. + * + * A page sized gap is created between consecutive + * allocations to ensure that out-of-bounds accesses fault. + */ a->entry->start = roundup2(beg + IOMMU_PAGE_SIZE, a->common->alignment); if (a->entry->start + a->offset + a->size > maxaddr) @@ -356,13 +362,6 @@ iommu_gas_match_insert(struct iommu_gas_match_args *a) { bool found __diagused; - /* - * The prev->end is always aligned on the page size, which - * causes page alignment for the entry->start too. - * - * The page sized gap is created between consequent - * allocations to ensure that out-of-bounds accesses fault. - */ a->entry->end = a->entry->start + roundup2(a->size + a->offset, IOMMU_PAGE_SIZE); @@ -487,8 +486,7 @@ iommu_gas_find_space(struct iommu_domain *domain, /* Handle lower region. */ if (common->lowaddr > 0) { - error = iommu_gas_lowermatch(&a, - RB_ROOT(&domain->rb_root)); + error = iommu_gas_lowermatch(&a, RB_ROOT(&domain->rb_root)); if (error == 0) return (0); KASSERT(error == ENOMEM, @@ -636,7 +634,7 @@ iommu_gas_map(struct iommu_domain *domain, ("invalid flags 0x%x", flags)); entry = iommu_gas_alloc_entry(domain, - (flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0); + (flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0); if (entry == NULL) return (ENOMEM); IOMMU_DOMAIN_LOCK(domain); @@ -660,7 +658,7 @@ iommu_gas_map(struct iommu_domain *domain, error = domain->ops->map(domain, entry->start, entry->end - entry->start, ma, eflags, - ((flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0)); + ((flags & IOMMU_MF_CANWAIT) != 0 ? IOMMU_PGF_WAITOK : 0)); if (error == ENOMEM) { iommu_domain_unload_entry(entry, true); return (error);