diff options
| author | Doug Moore <dougm@FreeBSD.org> | 2022-06-06 21:26:01 +0000 |
|---|---|---|
| committer | Doug Moore <dougm@FreeBSD.org> | 2022-06-06 21:26:01 +0000 |
| commit | b831865fe3b8f66281b39a9cb567c92dc285a1da (patch) | |
| tree | 7e1031208e47b6a03de55a3f42d53ee67ba46587 /sys/dev/iommu | |
| parent | 156745b42d9e6dfa3d9c6dc480db7836683850cf (diff) | |
Diffstat (limited to 'sys/dev/iommu')
| -rw-r--r-- | sys/dev/iommu/iommu_gas.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c index c0d4f84a3f1c..78dd86c1f255 100644 --- a/sys/dev/iommu/iommu_gas.c +++ b/sys/dev/iommu/iommu_gas.c @@ -384,7 +384,12 @@ iommu_gas_lowermatch(struct iommu_gas_match_args *a, struct iommu_map_entry *ent iommu_gas_match_insert(a); return (0); } - if (entry->free_down < a->size + a->offset + IOMMU_PAGE_SIZE) + + /* + * If the subtree doesn't have free space for the requested allocation + * plus two guard pages, give up. + */ + if (entry->free_down < a->size + a->offset + 2 * IOMMU_PAGE_SIZE) return (ENOMEM); if (entry->first >= a->common->lowaddr) return (ENOMEM); @@ -408,7 +413,11 @@ iommu_gas_uppermatch(struct iommu_gas_match_args *a, struct iommu_map_entry *ent { struct iommu_map_entry *child; - if (entry->free_down < a->size + a->offset + IOMMU_PAGE_SIZE) + /* + * If the subtree doesn't have free space for the requested allocation + * plus two guard pages, give up. + */ + if (entry->free_down < a->size + a->offset + 2 * IOMMU_PAGE_SIZE) return (ENOMEM); if (entry->last < a->common->highaddr) return (ENOMEM); |
