git: 26a9c64d9df9 - stable/13 - iommu_gas: initialize start_gap as first node

From: Doug Moore <dougm_at_FreeBSD.org>
Date: Thu, 09 Feb 2023 07:06:29 UTC
The branch stable/13 has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=26a9c64d9df9d4e9ac543a5efeca375918fd1cc5

commit 26a9c64d9df9d4e9ac543a5efeca375918fd1cc5
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2023-02-08 17:04:13 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2023-02-09 07:05:51 +0000

    iommu_gas: initialize start_gap as first node
    
    In iommu_gas.c, domain->start_gap points to one of the nodes on either
    side of the first free, unallocated range. In iommu_gas_init_domain,
    it is initialized to point to the node after the single free
    range. Change it to point to the node before that free range, so that,
    when 'lowaddr' is within the initial free range, the first allocation
    search for free space below 'lowaddr' does not begin and end at an
    address above 'lowaddr'. This fixes problems on a machine with Intel
    DMAR enabled.
    
    Reported by:    jah
    Reviewed by:    dougm
    Tested by:      jah
    Obtained from:  jah
    Fixes:  commit db151ca0c343531256b8839f938a4ecbd8b4fd7e iommu_gas: start space search from 1st free space
    MFC after:      1 day
    
    (cherry picked from commit 87d405eab91169e0b650a7dd2e5097c0b990fac5)
---
 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 86fc3bfa093c..fbef902e2f69 100644
--- a/sys/dev/iommu/iommu_gas.c
+++ b/sys/dev/iommu/iommu_gas.c
@@ -264,7 +264,7 @@ iommu_gas_init_domain(struct iommu_domain *domain)
 	begin->flags = IOMMU_MAP_ENTRY_PLACE | IOMMU_MAP_ENTRY_UNMAPPED;
 	RB_INSERT_PREV(iommu_gas_entries_tree, &domain->rb_root, end, begin);
 
-	domain->start_gap = end;
+	domain->start_gap = begin;
 	domain->first_place = begin;
 	domain->last_place = end;
 	domain->flags |= IOMMU_DOMAIN_GAS_INITED;