From nobody Tue Dec 26 01:28:56 2023 X-Original-To: dev-commits-src-main@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 4SzccT287Bz55H05; Tue, 26 Dec 2023 01:28:57 +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 4SzccT1Dv6z3gJG; Tue, 26 Dec 2023 01:28:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703554137; 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=KAfVt25O6YaCQK3zAQcvAmsiSyU5zrpIMhB5+dvoG6c=; b=lBO1nSrJvv2oDU3K76yM8PeZctSO8+Q7PW+kIQrWW4tV2Jmt6ECBNmB4x63TnOp1E8xqjB 0dje2QupHrPW1vCEDyQ3espNvLp/iurX4nvDhHhiCMzMyF3GoRqzqwp5SB/UOowqhP20JB H8Bs7T9VTkM4Z7XVfQytk6zxlYh8WiWRKd877YWLyAu3je0RX+5HMR7u861qe2HMDxQebt Biz5vZ9CvpTYLRGiyZ0Rk5HLsalnfpcH06x+ERt55Y3bVXw660qO53wShd+jZqPUzADsrM tUg8zDORDgFjxLVmsWLIwqkW8JIqNr2rHF3mUlmZ4/fhXU2z311ZvB8eOwG/Uw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703554137; a=rsa-sha256; cv=none; b=V+FBIFnaGM/136KIoDbFhymjWaXXU6z8SenGfrK7otYfQ3BMybmWE1y14XM6eTqPTTIYSe Xu3z8E0T9SZJu5SfH/f87tVMTR+IOQmXR0aRuEwQBGeTAb88BmJ/IpxPivR1B9MNt0uYdX 40+67HFzPCRBku3j4PhWf7xm73VEN09Li6Duu4EO3bg3DhU4I4PBwKVN3qp4Um2LIThke1 TpMHBLJ4RWeiPu8GQr2+D++Js+SY9yC7v/wqLSyFPefDVDZ2xd6u92ehkuXZ4ET4eXeoC2 LBhdGbGjvdDEzcmJZHBR94EM0Tpp0p7V0uVLrDwUqOm1OEPfpKP2LuVjYaTPag== 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=1703554137; 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=KAfVt25O6YaCQK3zAQcvAmsiSyU5zrpIMhB5+dvoG6c=; b=nIPfSPcw6C1x2lMwFM+KEZKMoAEHykgNqiCYK1BG3W1UNXZBoo9JyxTxLPXC+5VgNXTt0G 3ZR6wwaijtu6k77iBKStSO3uY0yQ/DriyYmNGXuSwMMsaSOGHfHx4I5VaFlAZJ4BezVJip Pr0rIoVQozgUkAotih9oVwZKb9ksttMIPaflPsDKH/eJa1wix2YcFYeq1+EETMim7qVL7g MnTnz3vdxhWdgUQGsXXlGbdl1Dw/yAr9cIF013lzgGDXVPjdlezxT8GlaadLtVcRvNy/VO I0JU1WQvRZi+AE/q4vmmK15Q0pwthO2jfWrO8IKupMVDZC7rsydfxvrVKQqbZA== 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 4SzccT03YpzZcG; Tue, 26 Dec 2023 01:28:57 +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 3BQ1Sund035761; Tue, 26 Dec 2023 01:28:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BQ1Supa035758; Tue, 26 Dec 2023 01:28:56 GMT (envelope-from git) Date: Tue, 26 Dec 2023 01:28:56 GMT Message-Id: <202312260128.3BQ1Supa035758@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: f59128775636 - main - iommu_gas: make placeholder entry at the start of the GAS zero size List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: f59128775636846574e092c68e849a56f74577e6 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f59128775636846574e092c68e849a56f74577e6 commit f59128775636846574e092c68e849a56f74577e6 Author: Konstantin Belousov AuthorDate: 2023-12-22 22:19:05 +0000 Commit: Konstantin Belousov CommitDate: 2023-12-26 01:28:22 +0000 iommu_gas: make placeholder entry at the start of the GAS zero size same as the placeholder at the end. This is required to allow GAS to start at zero, for integration with vmm. Also, in iommu_gas_remove(), accept placeholders after remove op. Sponsored by: The FreeBSD Foundation MFC after: 1 week --- 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 "