git: 14fa36d1c1b6 - stable/13 - dev/iommu: Include offset in maxaddr check.

From: Doug Moore <dougm_at_FreeBSD.org>
Date: Mon, 08 Aug 2022 03:57:35 UTC
The branch stable/13 has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=14fa36d1c1b603ae5b61358d6ff8acd858c01f9f

commit 14fa36d1c1b603ae5b61358d6ff8acd858c01f9f
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2022-04-20 22:24:11 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2022-08-08 03:39:38 +0000

    dev/iommu: Include offset in maxaddr check.
    
    If iommu_gas_match_one has to adjust for a boundary crossing, its
    check against maxaddr includes 'offset' in its calculation, to ensure
    that the allocated memory does not exceed the max address. However, if
    there's no boundary crossing adjustment, then the maxaddr check
    disregards 'offset'. Fix that.
    
    Reviewed by:    kib
    Differential Revision:  https://reviews.freebsd.org/D34978
    
    (cherry picked from commit 11fced21ccea1b80327d159a4c27046cb1f46952)
---
 sys/dev/iommu/iommu_gas.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c
index abc7a336117c..801c75c356cf 100644
--- a/sys/dev/iommu/iommu_gas.c
+++ b/sys/dev/iommu/iommu_gas.c
@@ -311,7 +311,7 @@ iommu_gas_match_one(struct iommu_gas_match_args *a, iommu_gaddr_t beg,
 	 */
 	a->entry->start = roundup2(beg + IOMMU_PAGE_SIZE,
 	    a->common->alignment);
-	if (a->entry->start + a->size > maxaddr)
+	if (a->entry->start + a->offset + a->size > maxaddr)
 		return (false);
 
 	/* IOMMU_PAGE_SIZE to create gap after new entry. */