Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Jan 2024 00:41:58 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 5dcf0d72f645 - stable/14 - IOMMU: add GAS map entry flag IOMMU_MAP_ENTRY_FAKE
Message-ID:  <202401020041.4020fw9u096938@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=5dcf0d72f645bee142d28cbdc213cfc1458bc306

commit 5dcf0d72f645bee142d28cbdc213cfc1458bc306
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-12-22 22:39:27 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-01-02 00:41:39 +0000

    IOMMU: add GAS map entry flag IOMMU_MAP_ENTRY_FAKE
    
    (cherry picked from commit a59c252903e81f46c74903ce5b1cf0960927dbcc)
---
 sys/dev/iommu/iommu_gas.c | 6 +++++-
 sys/dev/iommu/iommu_gas.h | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c
index e178acf60478..dc850747512a 100644
--- a/sys/dev/iommu/iommu_gas.c
+++ b/sys/dev/iommu/iommu_gas.c
@@ -123,7 +123,8 @@ iommu_gas_cmp_entries(struct iommu_map_entry *a, struct iommu_map_entry *b)
 	    a, (uintmax_t)a->start, (uintmax_t)a->end));
 	KASSERT(b->start <= b->end, ("inverted entry %p (%jx, %jx)",
 	    b, (uintmax_t)b->start, (uintmax_t)b->end));
-	KASSERT(a->end <= b->start || b->end <= a->start ||
+	KASSERT(((a->flags | b->flags) & IOMMU_MAP_ENTRY_FAKE) != 0 ||
+	    a->end <= b->start || b->end <= a->start ||
 	    a->end == a->start || b->end == b->start,
 	    ("overlapping entries %p (%jx, %jx) f %#x %p (%jx, %jx) f %#x"
 	    " domain %p %p",
@@ -536,11 +537,13 @@ iommu_gas_alloc_region(struct iommu_domain *domain, struct iommu_map_entry *entr
 	if (entry->end >= domain->end)
 		return (EINVAL);
 
+	entry->flags |= IOMMU_MAP_ENTRY_FAKE;
 	next = RB_NFIND(iommu_gas_entries_tree, &domain->rb_root, entry);
 	KASSERT(next != NULL, ("next must be non-null %p %jx", domain,
 	    (uintmax_t)entry->start));
 	prev = RB_PREV(iommu_gas_entries_tree, &domain->rb_root, next);
 	/* prev could be NULL */
+	entry->flags &= ~IOMMU_MAP_ENTRY_FAKE;
 
 	/*
 	 * Adapt to broken BIOSes which specify overlapping RMRR
@@ -658,6 +661,7 @@ iommu_gas_remove_clip_left(struct iommu_domain *domain, iommu_gaddr_t start,
 	bzero(&fentry, sizeof(fentry));
 	fentry.start = start + 1;
 	fentry.end = start + 1;
+	fentry.flags = IOMMU_MAP_ENTRY_FAKE;
 	entry = RB_NFIND(iommu_gas_entries_tree, &domain->rb_root, &fentry);
 
 	if (entry->start >= start ||
diff --git a/sys/dev/iommu/iommu_gas.h b/sys/dev/iommu/iommu_gas.h
index 8069c5a15a34..cdc4bd22d60c 100644
--- a/sys/dev/iommu/iommu_gas.h
+++ b/sys/dev/iommu/iommu_gas.h
@@ -50,6 +50,7 @@
 #define	IOMMU_MAP_ENTRY_UNMAPPED	0x0010	/* No backing pages */
 #define	IOMMU_MAP_ENTRY_REMOVING	0x0020	/* In process of removal by
 						   iommu_gas_remove() */
+#define	IOMMU_MAP_ENTRY_FAKE	0x0040	/* disable assert in cmp() */
 #define	IOMMU_MAP_ENTRY_READ	0x1000	/* Read permitted */
 #define	IOMMU_MAP_ENTRY_WRITE	0x2000	/* Write permitted */
 #define	IOMMU_MAP_ENTRY_SNOOP	0x4000	/* Snoop */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401020041.4020fw9u096938>