git: 7b39a9bc1df3 - main - iommu_gas: Fix a recent regression with IOMMU_MF_CANSPLIT

From: Alan Cox <alc_at_FreeBSD.org>
Date: Sun, 26 Jun 2022 21:32:33 UTC
The branch main has been updated by alc:

URL: https://cgit.FreeBSD.org/src/commit/?id=7b39a9bc1df37502e8186593f3427b7ff0e4cc71

commit 7b39a9bc1df37502e8186593f3427b7ff0e4cc71
Author:     Alan Cox <alc@FreeBSD.org>
AuthorDate: 2022-06-26 16:48:12 +0000
Commit:     Alan Cox <alc@FreeBSD.org>
CommitDate: 2022-06-26 21:31:54 +0000

    iommu_gas: Fix a recent regression with IOMMU_MF_CANSPLIT
    
    As of 19bb5a7244ff, the IOMMU_MF_CANSPLIT case in iommu_gas_match_one()
    must take into account the specified offset.  Otherwise, the recently
    changed end calculation in iommu_gas_match_insert() could produce an
    end address that crosses the specified boundary by one page.
    
    Reviewed by:    dougm
    MFC with:       19bb5a7244ff
---
 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 2647c2ce6612..bb6cde2721a6 100644
--- a/sys/dev/iommu/iommu_gas.c
+++ b/sys/dev/iommu/iommu_gas.c
@@ -350,7 +350,7 @@ iommu_gas_match_one(struct iommu_gas_match_args *a, iommu_gaddr_t beg,
 	 * the next entry, then we do not have gap.  Ignore for now.
 	 */
 	if ((a->gas_flags & IOMMU_MF_CANSPLIT) != 0) {
-		a->size = bs - a->entry->start;
+		a->size = bs - a->entry->start - a->offset;
 		return (true);
 	}