From nobody Wed Jul 13 16:47:32 2022 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 18EA117FBDEE; Wed, 13 Jul 2022 16:47:33 +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 4Ljk7T0GWRz3WFW; Wed, 13 Jul 2022 16:47:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657730853; 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=K2VHTrgqRxt3RtOgohM1q5jCzi6U9xLC8Mmf/Ei/0eo=; b=m/zy0Cyv3cjiLfIN8QkpqySFQt+09C33JbDq265Zb5zLpMMsx/UcwbBY7PCDKCeezeRMFp QrPfM9MezxMBsKLMoN/yE1F6c/qdLVVC6DJGbOFuy/zaJbNvRfPuqU9hFAgqxKbr/lr5ld u4AIbe1HXfxdLBzvtXdJLyzozyf9uBJLP/sTW9tl6cFtW993PzVROuTY9hpFKTbvydRZPL CuYl+MXIT+5S6zOtJL9sDSvyKtFLZ/r9HVJlBx/14brxnGwbj2zVfC/oGHy/YAwC3FjFXF rjYHtXMC4yns3H/AESEbKzMjiADSkiamE02uZSYw7YRsPtHjb+Ed8OUmUIdkJg== 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 4Ljk7S6CgxzVl9; Wed, 13 Jul 2022 16:47:32 +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 26DGlWeF052076; Wed, 13 Jul 2022 16:47:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26DGlWHu052075; Wed, 13 Jul 2022 16:47:32 GMT (envelope-from git) Date: Wed, 13 Jul 2022 16:47:32 GMT Message-Id: <202207131647.26DGlWHu052075@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 5e08ce742141 - stable/13 - vmm: Destroy character devices synchronously. 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: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5e08ce742141c3d8fd6d4c7f4eafdba78327e849 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657730853; 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=K2VHTrgqRxt3RtOgohM1q5jCzi6U9xLC8Mmf/Ei/0eo=; b=DGYVkrsy8r0K8wcO4vwhSar3Ip++3h+bFjoKWVWBPSUIa5nWT5/63Bfq74wtjvV8h9DMYa eXyQOCnEa60htA5t2+SPdG2JrjXlLAdOXWM/WHV/aRHqgn4wdsH9GpIZ1MhQWYIIGnvQO3 6WxaPre3gtVxSbgGGM6duAaMgOn3Q3M1QCxo0ztE5G6mQFTN0gAkLQR+tBtWb8DNMmcUfW yl0DSAYNqpJ1bGx8dF6fXUIAYZWMlXeWoG0lLUF+O7cwozcLcJuzzP8JLXi2b58PIaMtBG qeo4Fd8Q1k5MCpkScDPEEHf+JN2qE//bcFuIQc1H7m3BdMUk5Dm4uaHZ+4NHOg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657730853; a=rsa-sha256; cv=none; b=UuxlvOQ+zZw+N4rlgkZyLpG/h16v1FxlmdNEKFQ9cEk/drhClXvEd0t1j0Dq8q9t5Zx3T3 1mCpe2r+n9Vl0bWqx4Z2qcfuhXkNKDpBZVbdsbkTIXNM+bPaD/xt0jUrLsVD64+0dcxbWy d14Jn5JQ1Kyqr5ysX4cQOvb70W9V9fDJk2Smn/S8JjAHyGiY4R6eIUJF4Lk0ohOVjGAQkr 6cT5kBE4XRpvQnpJ9sU/Uy82dpgKOHDgTX4of/vNAeAmZf6ykVgMMBQI8A2iTFstgGTWd1 1R8bau/fhaxaWA4gucupcJNwPmsa5YXJZtdgKc8YO+ly2ODAfXxCHeJpa7BQZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5e08ce742141c3d8fd6d4c7f4eafdba78327e849 commit 5e08ce742141c3d8fd6d4c7f4eafdba78327e849 Author: John Baldwin AuthorDate: 2022-05-20 16:53:43 +0000 Commit: John Baldwin CommitDate: 2022-07-13 16:18:01 +0000 vmm: Destroy character devices synchronously. This fixes a userland race where bhyveload or bhyve can fail to reuse a VM name after bhyvectl --destroy has returned. Reported by: Michael Dexter Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D35186 (cherry picked from commit 7a0c23da4eaa63f00e53aa18f3ab1f2bb32f593a) --- sys/amd64/vmm/vmm_dev.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sys/amd64/vmm/vmm_dev.c b/sys/amd64/vmm/vmm_dev.c index a83c74219fee..2337c4dec2b1 100644 --- a/sys/amd64/vmm/vmm_dev.c +++ b/sys/amd64/vmm/vmm_dev.c @@ -1052,10 +1052,7 @@ sysctl_vmm_destroy(SYSCTL_HANDLER_ARGS) } /* - * The 'cdev' will be destroyed asynchronously when 'si_threadcount' - * goes down to 0 so we should not do it again in the callback. - * - * Setting 'sc->cdev' to NULL is also used to indicate that the VM + * Setting 'sc->cdev' to NULL is used to indicate that the VM * is scheduled for destruction. */ cdev = sc->cdev; @@ -1063,21 +1060,19 @@ sysctl_vmm_destroy(SYSCTL_HANDLER_ARGS) mtx_unlock(&vmmdev_mtx); /* - * Schedule all cdevs to be destroyed: + * Destroy all cdevs: * * - any new operations on the 'cdev' will return an error (ENXIO). * - * - when the 'si_threadcount' dwindles down to zero the 'cdev' will - * be destroyed and the callback will be invoked in a taskqueue - * context. - * * - the 'devmem' cdevs are destroyed before the virtual machine 'cdev' */ SLIST_FOREACH(dsc, &sc->devmem, link) { KASSERT(dsc->cdev != NULL, ("devmem cdev already destroyed")); - destroy_dev_sched_cb(dsc->cdev, devmem_destroy, dsc); + destroy_dev(dsc->cdev); + devmem_destroy(dsc); } - destroy_dev_sched_cb(cdev, vmmdev_destroy, sc); + destroy_dev(cdev); + vmmdev_destroy(sc); error = 0; out: