From nobody Tue Dec 26 01:28:54 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SzccR0L2fz55Gyv; Tue, 26 Dec 2023 01:28:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SzccQ64Zjz3gBt; Tue, 26 Dec 2023 01:28:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703554134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vDnA6wHvdQG+5UjbRKkTlOZIew5ZBxtyfT/ZvEKjAnY=; b=e4K+0O3nnpYTenxIE2YPUnLkAPN1bmh3rFC5N7x0hOGeqvJpTyEokjb45nsD5O+EkXnSeJ Cq8JB1NGWx7BCbXQVLsbZOQCJvFR0pKNC+6m+V4b01qmtVwCN35B4wsT12657cX1/NdhMS mtB+0JtP8qs1pTF3mfAmpmzdpVqnLboRvk4lpskLA05pH6sFC4JPPd+5kN4DjT646ePbid 0kRvwI1dfvEFxkE8fJzPmoTyzUtsHWWZrfyyDFlYkpSJHYIhpGsmJv/76Msbl1NNPKXeCu ekL2FHTtrhj+MSu3WTTJYt5LlJEZRm74o8yfPthd4huy2sZi9mOVHiDqCWmjng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703554134; a=rsa-sha256; cv=none; b=ty2HUHhHrBwf/UOUo7fbiSCxTBUYROV/HgUQ8udxcRDjGcCm9xMVhi2Pwv4y1VOCkZ0Gk0 oCoGZaq3GrsdfaF1DbzYQRPIkEa/yU9RyuJNb17IVfQvSHzA7DpfP0HsSdM/daLYsXtcHF iGs7HO5gC+PvDEQBVGp2krHn7baOxcy9OxfFNxnucUrn2Plzk1kUjhbNFjAzChH6YOy3Ft GZiFMbdE55iCF9XznFHRxC41ZOuQ9YmIIeBQVQM7fX0MboWB1qJ5w4Bz1e6vBWTQ6/yJqB 0VkMmnAroC4TjJQgeJiWhoVMx2U7NCS3MsLUIxNKVkjYTrr0vnBgWgTShky5ew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703554134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vDnA6wHvdQG+5UjbRKkTlOZIew5ZBxtyfT/ZvEKjAnY=; b=pl8bsufRTw2lCpRbC0c1YqKRO5US55bKkyawNvPIKQoL9zULCIn/ulr3eROAGHqgedYFiq FyELWgqPjvMbTb/OlTnLJixMUi1AoYXBW7bxxwKiLCfw24Zfib+PttqZsGo3MKi11fGP3k MHzeoG8qGTKHTduPwM//ixF2Kk1rXxncHQi9jv1sB3YdteoV6ikiFtkEtMZiBVH+Sn4nJk ovMQbjxRGdnYf7HQbm4/v73o4doWyoTvbxWrm74KNFo8IasvQuaB6D71ug1WDYBdX5Rfyt gFpWjhAg0jjBrVCtV+kClgGR/HHOdWaAzg5bmACzTCQcG3U6V8L6SJYqpCz6DA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SzccQ5BcbzZvD; Tue, 26 Dec 2023 01:28:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BQ1SsW3035661; Tue, 26 Dec 2023 01:28:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BQ1SsPe035658; Tue, 26 Dec 2023 01:28:54 GMT (envelope-from git) Date: Tue, 26 Dec 2023 01:28:54 GMT Message-Id: <202312260128.3BQ1SsPe035658@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: a59c252903e8 - main - IOMMU: add GAS map entry flag IOMMU_MAP_ENTRY_FAKE List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a59c252903e81f46c74903ce5b1cf0960927dbcc Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a59c252903e81f46c74903ce5b1cf0960927dbcc commit a59c252903e81f46c74903ce5b1cf0960927dbcc Author: Konstantin Belousov AuthorDate: 2023-12-22 22:39:27 +0000 Commit: Konstantin Belousov CommitDate: 2023-12-26 01:28:22 +0000 IOMMU: add GAS map entry flag IOMMU_MAP_ENTRY_FAKE to allow to shut down assert in iommu_gas_cmp_entries() when used against fake entry to search for specific place in the tree. Sponsored by: The FreeBSD Foundation MFC after: 1 week --- 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 */