From nobody Thu Jul 21 07:01:25 2022 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 4LpNlT36Dvz4Wsk0; Thu, 21 Jul 2022 07:01:25 +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 4LpNlT2fmQz3T3Y; Thu, 21 Jul 2022 07:01:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658386885; 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=RZ9K2KIGsOnKrOvDriJ8vbMc80q35u/zsY3iJ/2OQXU=; b=uYqnRR4ohvasPzu5XKmmSoAWp5/RCYpowTSWpSeRFirsUYwiRKAY70FeYjkBOgM2Mf7Fft mYUNTTEH46KMbYWQQGTVCsRY1ioWoxhEvov2smel+fPzuEENAl4S5DgJpWo9IwEgkT5n6r rAqViDiWDaghkcCCq1kypmPkuLtd0gcRyzouiiuw7jNDKIj1SPuzFYSxk4bwlJ2PjUHmoS ehesoHt2gvgfP1dWRrh9gqHiNdT05tmqS9gW4nzUr+SUvly+zKnlUtGdu6lzilJb5eF7UL OxXVKhGwlqLktCvs5xY4HhOdejbkJwWCIxEJkRfkQhvm+NAPg9BTxU0JnohxMg== 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 4LpNlT1jSzz1RpB; Thu, 21 Jul 2022 07:01:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26L71P30060156; Thu, 21 Jul 2022 07:01:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26L71PTi060155; Thu, 21 Jul 2022 07:01:25 GMT (envelope-from git) Date: Thu, 21 Jul 2022 07:01:25 GMT Message-Id: <202207210701.26L71PTi060155@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Cox Subject: git: dfabdacb279c - main - iommu_gas: Avoid double unmapping on error 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: alc X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dfabdacb279ca603d008a0e7e952c5c59ac51da4 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658386885; 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=RZ9K2KIGsOnKrOvDriJ8vbMc80q35u/zsY3iJ/2OQXU=; b=rpysaeS/YMmCWXyvan/rQSUfdMywayT2UOUxsFBAvrctfjPXD5uOKKvKlSyDujiHDBz21u 5m2RqzMys5DQUIi5a/vcrwrIuu4CZWDBqijZ6iSkiCXe//oHlw8940Rth2HrIy/OYzZPYC 1jmGOhlT3GI6v9C1FMPMhcVG7e+iSdh45+lQCyzg7HbIoX4OWDGUFF3kXXuMixkDpjxgql 1IwDRrKQNV+HUPBr3xo5yUIsTNzoyXU2nPEnW4uroVn4YLpWy+17kD9VVdbWZalSeCgec1 TvXW1UvZR8NxSCPYfK6tB57XzUuWZ95zUkRiO1gjec5Lnht+nzXC7jCLxd6UpQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658386885; a=rsa-sha256; cv=none; b=MFzpTF0rf8RFWai95WRgMKnfS//sMjZ9XGqMH9tdoiGK7eqtXDGe5RKqPQenAU95Ce99Aj Jin1UW71nk4owtdTs+PPpjSFxKQo2bgYsOD2c2sb3xtCIVcwOGIi7INuFvXauQnjZ/M45/ XPthRXrei/8KUuaqrJPjrDBPGl1+nSQ7D4XYDB8QlSVfN0TxqiOsS6TW6DlLo5D5q2COIw Uh8+ruOSCVseyLz8WxXUrzD5lcRe2EQzYtg1Or9PwGjAejfQBgQjI1rKTmSM+ChVmeLAk0 0icsiPqfbRdkCW83EA3ohUMS7LU1YghtbFOOPnmijGxllFKgGgsSOrqJbfqLOQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by alc: URL: https://cgit.FreeBSD.org/src/commit/?id=dfabdacb279ca603d008a0e7e952c5c59ac51da4 commit dfabdacb279ca603d008a0e7e952c5c59ac51da4 Author: Alan Cox AuthorDate: 2022-07-21 06:53:54 +0000 Commit: Alan Cox CommitDate: 2022-07-21 07:00:46 +0000 iommu_gas: Avoid double unmapping on error In the extremely unlikely case that the iommu_gas_map_region() call in bus_dma_iommu_load_ident() failed, we would attempt to unmap the failed entry twice, first in iommu_gas_map_region(), and a second time in the caller. Once is enough, and twice is problematic because it leads to a second RB_REMOVE call on the same tree node. Like it or not, RB_TREE does not handle that possibility. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D35869 --- sys/dev/iommu/busdma_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index 10e7476b35eb..67e82fe43e58 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -1055,7 +1055,7 @@ bus_dma_iommu_load_ident(bus_dma_tag_t dmat, bus_dmamap_t map1, TAILQ_INSERT_TAIL(&map->map_entries, entry, dmamap_link); IOMMU_DMAMAP_UNLOCK(map); } else { - iommu_domain_unload_entry(entry, true); + iommu_gas_free_entry(domain, entry); } for (i = 0; i < atop(length); i++) vm_page_putfake(ma[i]);