From nobody Tue Jan 02 00:42:45 2024 X-Original-To: dev-commits-src-branches@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 4T3vFx74cqz560MS; Tue, 2 Jan 2024 00:42:45 +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 4T3vFx4RQ1z3S5t; Tue, 2 Jan 2024 00:42:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704156165; 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=WeQ3muhqm3rBitWCtAGdlU7bwPpExpYa3krfvwTYv9Y=; b=HGaYGRnbrgmF+ORTsCg8jjBXFi62FurUtACWq1iL7/i3sWk83Blytk2Sb+VNOR7L6xmHty 9rCeFwFqX5xo34A1WIU0skyxbz9HGQmP5iHX/jLliolVrnQxf1u1QJ/Z2CBnQSVGVUHKh2 AeKdFeib4E3BHcUw4BfP+ZwIrivYyxcV6POVwXtasnlqtRWTJmekVjttUGbxv/dg+1KD6r 2GvCNlwSKBg+iy0PhX6M/bz9seB4o2EAU/3gQI8zUoJwYrArq2dDyGojAySYNdcSQA4/Ui /DHqkccoOUAfnTTYQ+RmdoIZAW+VbqjxhteXuhSPSHiK//9lb4CV0Pkb5Py6qg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704156165; a=rsa-sha256; cv=none; b=tGwoAyXVdz/iDwYr8SLOWqOGU2HqHgBD2nueHgikAMm6FCzZWQTCyiEaHKH4YsXK4hwcS1 +VzjWfssvF47B2nRlZgt6uk5pNpaj9G8kBu4KYYjt7+8212rkACVDGu7IdECD61WJ7Wl+P 8RBvepDCN+sX8Il9uNPL+hZ1B16RyFDwnbFYZpc9YoeH4TIizvh9VFo+YrV4uFh1p1d7Yq QVugNjflEA3asyibORDrN5X3P8eB0DpkP6l6gpfCJ/0SIuutfdjQWMTLHe4swZBX2LxPO+ FDQOCzbA9zwk6jtxs6RMTUZmLo51QzdShbEqa/Scgp81uaJl5pUIQ097HeKL3g== 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=1704156165; 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=WeQ3muhqm3rBitWCtAGdlU7bwPpExpYa3krfvwTYv9Y=; b=P7PhL7nIe3IUwf0zxaskVfCpHJjdveh/3yWXeEXocyGF6ZkEZfSJCUhpq7gYXtn8M/9ETx meFGdWa6LcxXtrRgZK8LGUtvlLdGX6vYVuqbyHdKN1QWHRs2hRTEBevyhAukpSMx4cvpi9 TvpLHx9L/Sw94uHpRwZlJC30FITut2a2q1fDv5qB08zth3G6YPgjdjmKdpWn2il7J1qsJw SSptx6lrUAVPnqAgONMVXofmlPD8VQPLStM6qY8UM+uUNJyufDPWCdrGkKdEoR1vpraMib 9UjuGp7mep/W6Cv2ghFcog3aWfrr7bZGgmAC10ULXoT0E1jhmK2BT2MNNgS2yg== 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 4T3vFx3Xl8zfpR; Tue, 2 Jan 2024 00:42:45 +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 4020gjI9004233; Tue, 2 Jan 2024 00:42:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4020gjow004230; Tue, 2 Jan 2024 00:42:45 GMT (envelope-from git) Date: Tue, 2 Jan 2024 00:42:45 GMT Message-Id: <202401020042.4020gjow004230@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 41478582cb2d - stable/13 - iommu_gas: make placeholder entry at the start of the GAS zero size List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 41478582cb2df925d1065c1b996294db3eafd583 Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=41478582cb2df925d1065c1b996294db3eafd583 commit 41478582cb2df925d1065c1b996294db3eafd583 Author: Konstantin Belousov AuthorDate: 2023-12-22 22:19:05 +0000 Commit: Konstantin Belousov CommitDate: 2024-01-02 00:42:13 +0000 iommu_gas: make placeholder entry at the start of the GAS zero size (cherry picked from commit f59128775636846574e092c68e849a56f74577e6) --- sys/dev/iommu/iommu_gas.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/sys/dev/iommu/iommu_gas.c b/sys/dev/iommu/iommu_gas.c index 9a74854f926f..cfd375c658c3 100644 --- a/sys/dev/iommu/iommu_gas.c +++ b/sys/dev/iommu/iommu_gas.c @@ -118,7 +118,7 @@ static int iommu_gas_cmp_entries(struct iommu_map_entry *a, struct iommu_map_entry *b) { - /* Last entry have zero size, so <= */ + /* First and last entries have zero size, so <= */ KASSERT(a->start <= a->end, ("inverted entry %p (%jx, %jx)", a, (uintmax_t)a->start, (uintmax_t)a->end)); KASSERT(b->start <= b->end, ("inverted entry %p (%jx, %jx)", @@ -244,25 +244,17 @@ iommu_gas_init_domain(struct iommu_domain *domain) KASSERT(RB_EMPTY(&domain->rb_root), ("non-empty entries %p", domain)); - /* - * The end entry must be inserted first because it has a zero-length gap - * between start and end. Initially, all augmentation data for a new - * entry is zero. Function iommu_gas_augment_entry will compute no - * change in the value of (start-end) and no change in the value of - * free_down, so it will return false to suggest that nothing changed in - * the entry. Thus, inserting the end entry second prevents - * augmentation information to be propogated to the begin entry at the - * tree root. So it is inserted first. - */ end->start = domain->end; end->end = domain->end; end->flags = IOMMU_MAP_ENTRY_PLACE | IOMMU_MAP_ENTRY_UNMAPPED; RB_INSERT(iommu_gas_entries_tree, &domain->rb_root, end); begin->start = 0; - begin->end = IOMMU_PAGE_SIZE; + begin->end = 0; begin->flags = IOMMU_MAP_ENTRY_PLACE | IOMMU_MAP_ENTRY_UNMAPPED; RB_INSERT_PREV(iommu_gas_entries_tree, &domain->rb_root, end, begin); + iommu_gas_augment_entry(end); + iommu_gas_augment_entry(begin); domain->start_gap = begin; domain->first_place = begin; @@ -739,7 +731,8 @@ iommu_gas_remove_locked(struct iommu_domain *domain, #ifdef INVARIANTS RB_FOREACH(entry, iommu_gas_entries_tree, &domain->rb_root) { - if ((entry->flags & IOMMU_MAP_ENTRY_RMRR) != 0) + if ((entry->flags & (IOMMU_MAP_ENTRY_RMRR | + IOMMU_MAP_ENTRY_PLACE)) != 0) continue; KASSERT(entry->end <= start || entry->start >= end, ("iommu_gas_remove leftover entry (%#jx, %#jx) range "